Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Jun 13, 2024
1 parent 06030f9 commit d64c89d
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"

// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10
minecraft_version=1.21-rc1
yarn_mappings=1.21-rc1+build.1
loader_version=0.15.11

# Mod Properties
mod_version = 0.6.0+1.20.6
mod_version = 0.6.0+1.21
maven_group = space.essem
archives_base_name = image2map

# Dependencies
fabric_version=0.97.6+1.20.6
mapcanvas_version=0.3.0+1.20.6
sgui_version=1.5.1+1.20.5
fabric_version=0.100.1+1.21
mapcanvas_version=0.4.0+1.21
sgui_version=1.6.0+1.21
2 changes: 1 addition & 1 deletion src/main/java/space/essem/image2map/CardboardWarning.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.List;

public class CardboardWarning implements PreLaunchEntrypoint {
public static final String MOD_NAME = "Brewery";
public static final String MOD_NAME = "Image2Map";
public static final Logger LOGGER = LogUtils.getLogger();

// Overwrite heavy and generally problematic bukkit implementation
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/space/essem/image2map/Image2Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtString;
import net.minecraft.nbt.*;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
Expand Down Expand Up @@ -214,7 +211,7 @@ public static void giveToPlayer(PlayerEntity player, List<ItemStack> items, Stri
} else {
var bundle = new ItemStack(Items.BUNDLE);
bundle.set(DataComponentTypes.BUNDLE_CONTENTS, new BundleContentsComponent(items));
bundle.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT.with(ImageData.CODEC,
bundle.set(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT.with(NbtOps.INSTANCE, ImageData.CODEC,
ImageData.ofBundle(MathHelper.ceil(width / 128d), MathHelper.ceil(height / 128d))).getOrThrow());

bundle.set(DataComponentTypes.LORE, new LoreComponent(List.of(Text.literal(input))));
Expand Down Expand Up @@ -277,7 +274,7 @@ public static boolean clickItemFrame(PlayerEntity player, Hand hand, ItemFrameEn
if (mapData.isSuccess() && mapData.getOrThrow().isReal()) {
map = map.copy();
var newData = mapData.getOrThrow().withDirection(right, down, facing);
map.apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT, x -> x.with(ImageData.CODEC, newData).getOrThrow());
map.apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT, x -> x.with(NbtOps.INSTANCE, ImageData.CODEC, newData).getOrThrow());

var frame = frames[mapData.getOrThrow().x() + mapData.getOrThrow().y() * width];

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/space/essem/image2map/gui/MapGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public MapGui(ServerPlayerEntity player, int width, int height) {
//this.cursorX = this.canvas.getWidth();
//this.cursorY = this.canvas.getHeight(); // MapDecoration.Type.TARGET_POINT
//this.cursor = null;//this.canvas.createIcon(MapIcon.Type.TARGET_POINT, true, this.cursorX, this.cursorY, (byte) 14, null);
player.networkHandler.sendPacket(this.entity.createSpawnPacket());
player.networkHandler.sendPacket(new EntitySpawnS2CPacket(this.entity.getId(), this.entity.getUuid(),
this.entity.getX(), this.entity.getY(), this.entity.getZ(), this.entity.getPitch(), entity.getYaw(), entity.getType(), 0, Vec3d.ZERO, entity.getHeadYaw()));

player.networkHandler.sendPacket(new EntityTrackerUpdateS2CPacket(this.entity.getId(), this.entity.getDataTracker().getChangedEntries()));
player.networkHandler.sendPacket(new SetCameraEntityS2CPacket(this.entity));
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/space/essem/image2map/renderer/MapRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.item.Items;
import net.minecraft.item.map.MapState;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.NbtString;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
Expand Down Expand Up @@ -75,8 +76,8 @@ public static List<ItemStack> toVanillaItems(CanvasImage image, ServerWorld worl

for (int ys = 0; ys < ySections; ys++) {
for (int xs = 0; xs < xSections; xs++) {
var id = world.getNextMapId();
var state = MapState.of(0, 0, (byte) 0, false, false, RegistryKey.of(RegistryKeys.WORLD, new Identifier("image2map", "generated")));
var id = world.increaseAndGetMapId();
var state = MapState.of(0, 0, (byte) 0, false, false, RegistryKey.of(RegistryKeys.WORLD, Identifier.of("image2map", "generated")));

for (int xl = 0; xl < 128; xl++) {
for (int yl = 0; yl < 128; yl++) {
Expand All @@ -94,7 +95,7 @@ public static List<ItemStack> toVanillaItems(CanvasImage image, ServerWorld worl
var stack = new ItemStack(Items.FILLED_MAP);
stack.set(DataComponentTypes.MAP_ID, id);
var data = ImageData.ofSimple(xs, ys, xSections, ySections);
stack.apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT, x -> x.with(ImageData.CODEC, data).getOrThrow());
stack.apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT, x -> x.with(NbtOps.INSTANCE, ImageData.CODEC, data).getOrThrow());
stack.set(DataComponentTypes.LORE, new LoreComponent(List.of(
Text.literal(xs + " / " + ys).formatted(Formatting.GRAY),
Text.literal(url)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
],
"depends": {
"fabricloader": ">=0.14.0",
"fabric": "*"
"fabric-api": "*"
}
}
2 changes: 1 addition & 1 deletion src/main/resources/image2map.mixins.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"required": true,
"package": "space.essem.image2map.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [
"BundleItemMixin",
"EntityPassengersSetS2CPacketAccessor",
Expand Down

0 comments on commit d64c89d

Please sign in to comment.