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 25, 2024
1 parent 30736ed commit 710d2e8
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 50 deletions.
22 changes: 10 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,16 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// 1.109.6
//modImplementation "maven.modrinth:cc-tweaked:7U8gSlIr"
modImplementation "cc.tweaked:cc-tweaked-1.20.6-fabric:1.111.0"

modImplementation include('eu.pb4:sgui:1.5.1+1.20.5')
modImplementation include('eu.pb4:player-data-api:0.5.0+1.20.5')
modImplementation include('eu.pb4:map-canvas-api:0.3.0+1.20.6')
modImplementation include('eu.pb4:factorytools:0.2.2+1.20.6')
modImplementation 'eu.pb4:polymer-core:0.8.2+1.20.6'
modImplementation 'eu.pb4:polymer-resource-pack:0.8.2+1.20.6'
modImplementation 'eu.pb4:polymer-autohost:0.8.2+1.20.6'
modImplementation 'eu.pb4:polymer-virtual-entity:0.8.2+1.20.6'
modImplementation "cc.tweaked:cc-tweaked-1.21-fabric:1.111.0"

modImplementation include('eu.pb4:sgui:1.6.0+1.21')
modImplementation include('eu.pb4:player-data-api:0.6.0+1.21')
modImplementation include('eu.pb4:map-canvas-api:0.4.1+1.21')
modImplementation include('eu.pb4:factorytools:0.3.1+1.21')
modImplementation 'eu.pb4:polymer-core:0.9.2+1.21'
modImplementation 'eu.pb4:polymer-resource-pack:0.9.2+1.21'
modImplementation 'eu.pb4:polymer-autohost:0.9.2+1.21'
modImplementation 'eu.pb4:polymer-virtual-entity:0.9.2+1.21'


modCompileOnly ("nl.theepicblock:PolyMc:5.6.1+1.20.4") {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

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

# Mod Properties
mod_version=1.111.0.1+1.20.6
mod_version=1.111.0.2+1.21
maven_group=eu.pb4.cctpatch
archives_base_name=cc-tweaked-polymer-patch

# Dependencies
fabric_version=0.97.6+1.20.6
fabric_version=0.100.1+1.21
1 change: 0 additions & 1 deletion src/main/java/eu/pb4/cctpatch/impl/config/BaseGson.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public class BaseGson {

.registerTypeHierarchyAdapter(Item.class, new RegistrySerializer<>(Registries.ITEM))
.registerTypeHierarchyAdapter(Block.class, new RegistrySerializer<>(Registries.BLOCK))
.registerTypeHierarchyAdapter(Enchantment.class, new RegistrySerializer<>(Registries.ENCHANTMENT))
.registerTypeHierarchyAdapter(SoundEvent.class, new RegistrySerializer<>(Registries.SOUND_EVENT))
.registerTypeHierarchyAdapter(StatusEffect.class, new RegistrySerializer<>(Registries.STATUS_EFFECT))
.registerTypeHierarchyAdapter(EntityType.class, new RegistrySerializer<>(Registries.ENTITY_TYPE))
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eu/pb4/cctpatch/impl/poly/PolymerSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.util.Identifier;

public class PolymerSetup {
public static final Identifier GUI_FONT = new Identifier("cct-patch", "gui");
public static final Identifier GUI_FONT = Identifier.of("cct-patch", "gui");

public static void setup() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private static BiConsumer<ComputerGui, String> holdKey(int key) {
}

public void render() {
if (this.computer.getComputer().isOn()) {
if (this.computer.isOn()) {
this.closeButton.texture = GuiTextures.SHUTDOWN_ACTIVE;
} else {
this.closeButton.texture = GuiTextures.SHUTDOWN_ICON;
Expand Down
41 changes: 38 additions & 3 deletions src/main/java/eu/pb4/cctpatch/impl/poly/gui/MapGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import eu.pb4.polymer.core.api.utils.PolymerUtils;
import eu.pb4.polymer.virtualentity.api.ElementHolder;
import eu.pb4.polymer.virtualentity.api.VirtualEntityUtils;
import eu.pb4.polymer.virtualentity.api.attachment.HolderAttachment;
import eu.pb4.polymer.virtualentity.api.attachment.ManualAttachment;
import eu.pb4.polymer.virtualentity.api.elements.BlockDisplayElement;
import eu.pb4.polymer.virtualentity.api.elements.DisplayElement;
Expand Down Expand Up @@ -45,7 +46,9 @@
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
import net.minecraft.network.packet.s2c.play.*;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
Expand All @@ -57,12 +60,14 @@
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;

import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;

public class MapGui extends HotbarGui {

private static final Identifier DISTANCE_STORAGE_ID = new Identifier("cct-patch", "view_shift");
private static final Identifier DISTANCE_STORAGE_ID = Identifier.of("cct-patch", "view_shift");
private static final Vec3d DEFAULT_SHIFT = new Vec3d(0, 0, 1);
private static final Packet<?> COMMAND_PACKET;
public final CombinedPlayerCanvas canvas;
Expand All @@ -76,6 +81,7 @@ public class MapGui extends HotbarGui {
public final DisplayElement cameraPoint;

public final ElementHolder holder = new ElementHolder();
private final BlockPos zeroPos;

public float xRot;
public float yRot;
Expand All @@ -90,14 +96,14 @@ public MapGui(ServerPlayerEntity player) {
this.pos = pos;
var dir = Direction.NORTH;
this.canvas = DrawableCanvas.create(5, 3);
var zeroPos = pos.offset(dir).offset(dir.rotateYClockwise(), 2).up();
this.zeroPos = pos.offset(dir).offset(dir.rotateYClockwise(), 2).up();
this.virtualDisplay = VirtualDisplay.of(this.canvas, zeroPos, dir, 0, true);
this.renderer = CanvasRenderer.of(new CanvasImage(this.canvas.getWidth(), this.canvas.getHeight()));
this.renderer.add(new ImageButton(560, 32, GuiTextures.CLOSE_ICON, (a, b, c) -> this.close()));

this.canvas.addPlayer(player);
this.virtualDisplay.addPlayer(player);
this.holder.setAttachment(new ManualAttachment(this.holder, player.getServerWorld(), () -> Vec3d.of(zeroPos).add(1, 1,1 - 1 / 32f)));
this.holder.setAttachment(new SelfHolder());
this.holder.startWatching(player);

this.cameraPoint = new BlockDisplayElement();
Expand Down Expand Up @@ -313,4 +319,33 @@ public boolean preventPacket(Packet<?> packet) {

return false;
}

private class SelfHolder implements HolderAttachment {

@Override
public ElementHolder holder() {
return MapGui.this.holder;
}

@Override
public void destroy() {

}

@Override
public Vec3d getPos() {
return Vec3d.of(zeroPos).add(1, 1,1 - 1 / 32f);
}

@Override
public ServerWorld getWorld() {
return MapGui.this.getPlayer().getServerWorld();
}

@Override
public void updateCurrentlyTracking(Collection<ServerPlayNetworkHandler> currentlyTracking) {}

@Override
public void updateTracking(ServerPlayNetworkHandler tracking) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import eu.pb4.mapcanvas.api.core.CanvasImage;
import eu.pb4.mapcanvas.api.font.DefaultFonts;
import eu.pb4.mapcanvas.api.utils.CanvasUtils;
import net.minecraft.component.DataComponentType;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public static PocketComputerModel from(Identifier identifier) {
var blinkingModel = PolymerResourcePackUtils.requestModel(Items.FILLED_MAP, identifier.withPrefixedPath("item/").withSuffixedPath("_blinking"));
var onModelNoScreen = PolymerResourcePackUtils.requestModel(BaseItemProvider.requestItem(), identifier.withPrefixedPath("item/").withSuffixedPath("_on"));
var blinkingModelNoScreen = PolymerResourcePackUtils.requestModel(BaseItemProvider.requestItem(), identifier.withPrefixedPath("item/").withSuffixedPath("_blinking"));
var dyedModel = PolymerResourcePackUtils.requestModel(Items.FIREWORK_STAR, new Identifier("computercraft:item/pocket_computer_colour"));
var onDyedModel = PolymerResourcePackUtils.requestModel(Items.FILLED_MAP, new Identifier("computercraft:item/pocket_computer_colour_on"));
var onDyedModelNoScreen = PolymerResourcePackUtils.requestModel(Items.FIREWORK_STAR, new Identifier("computercraft:item/pocket_computer_colour_on"));
var blinkingDyedModel = PolymerResourcePackUtils.requestModel(Items.FILLED_MAP, new Identifier("computercraft:item/pocket_computer_colour_blinking"));
var blinkingDyedModelNoScreen = PolymerResourcePackUtils.requestModel(Items.FIREWORK_STAR, new Identifier("computercraft:item/pocket_computer_colour_blinking"));
var dyedModel = PolymerResourcePackUtils.requestModel(Items.FIREWORK_STAR, Identifier.of("computercraft:item/pocket_computer_colour"));
var onDyedModel = PolymerResourcePackUtils.requestModel(Items.FILLED_MAP, Identifier.of("computercraft:item/pocket_computer_colour_on"));
var onDyedModelNoScreen = PolymerResourcePackUtils.requestModel(Items.FIREWORK_STAR, Identifier.of("computercraft:item/pocket_computer_colour_on"));
var blinkingDyedModel = PolymerResourcePackUtils.requestModel(Items.FILLED_MAP, Identifier.of("computercraft:item/pocket_computer_colour_blinking"));
var blinkingDyedModelNoScreen = PolymerResourcePackUtils.requestModel(Items.FIREWORK_STAR, Identifier.of("computercraft:item/pocket_computer_colour_blinking"));
return new PocketComputerModel(defaultModel, onModel, onModelNoScreen, blinkingModel, blinkingModelNoScreen, dyedModel, onDyedModel, onDyedModelNoScreen, blinkingDyedModel, blinkingDyedModelNoScreen);
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/eu/pb4/cctpatch/impl/poly/model/TurtleModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
import java.util.function.Consumer;

public class TurtleModel extends BlockModel {
public static final ModemModel NORMAL_MODEM_MODEL = ModemModel.of(new Identifier(ComputerCraftAPI.MOD_ID, "block/turtle_modem_normal"));
public static final ModemModel ADVANCED_MODEM_MODEL = ModemModel.of(new Identifier(ComputerCraftAPI.MOD_ID, "block/turtle_modem_advanced"));
public static final SidedModel SPEAKER_MODEL = SidedModel.of(new Identifier(ComputerCraftAPI.MOD_ID, "block/turtle_speaker"));
public static final SidedModel CRAFTING_MODEL = SidedModel.of(new Identifier(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table"));
public static final ItemStack COLORED_TURTLE_MODEL = BaseItemProvider.requestModel(Items.FIREWORK_STAR, new Identifier(ComputerCraftAPI.MOD_ID, "block/turtle_colour"));
public static final Identifier ELF_OVERLAY_MODEL = new Identifier(ComputerCraftAPI.MOD_ID, "block/turtle_elf_overlay");
public static final ModemModel NORMAL_MODEM_MODEL = ModemModel.of(Identifier.of(ComputerCraftAPI.MOD_ID, "block/turtle_modem_normal"));
public static final ModemModel ADVANCED_MODEM_MODEL = ModemModel.of(Identifier.of(ComputerCraftAPI.MOD_ID, "block/turtle_modem_advanced"));
public static final SidedModel SPEAKER_MODEL = SidedModel.of(Identifier.of(ComputerCraftAPI.MOD_ID, "block/turtle_speaker"));
public static final SidedModel CRAFTING_MODEL = SidedModel.of(Identifier.of(ComputerCraftAPI.MOD_ID, "block/turtle_crafting_table"));
public static final ItemStack COLORED_TURTLE_MODEL = BaseItemProvider.requestModel(Items.FIREWORK_STAR, Identifier.of(ComputerCraftAPI.MOD_ID, "block/turtle_colour"));
public static final Identifier ELF_OVERLAY_MODEL = Identifier.of(ComputerCraftAPI.MOD_ID, "block/turtle_elf_overlay");

private static final Map<Identifier, ItemStack> OVERLAYS = new HashMap<>();
private final ItemDisplayElement base;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public FakeRegistrationHelper() {

@Override
public <U extends T> RegistryEntry<U> register(String s, Supplier<U> supplier) {
var x = new RegistryEntry<>(new Identifier("computercraft", s), supplier.get());
var x = new RegistryEntry<>(Identifier.of("computercraft", s), supplier.get());
consumer.accept(x.id, x.obj);
return x;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dan200.computercraft.shared.platform.RegistrationHelper;
import eu.pb4.cctpatch.impl.util.FakeRegistrationHelper;
import eu.pb4.polymer.rsm.api.RegistrySyncUtils;
import net.minecraft.component.DataComponentType;
import net.minecraft.component.ComponentType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
Expand All @@ -16,7 +16,7 @@
public class ModRegistryDataComponentsMixin {
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Ldan200/computercraft/shared/platform/PlatformHelper;createRegistrationHelper(Lnet/minecraft/registry/RegistryKey;)Ldan200/computercraft/shared/platform/RegistrationHelper;"))
private static RegistrationHelper<?> registryNoMore(PlatformHelper instance, RegistryKey<Registry<?>> registryRegistryKey) {
return new FakeRegistrationHelper<DataComponentType<?>>((id, obj) -> {
return new FakeRegistrationHelper<ComponentType<?>>((id, obj) -> {
Registry.register(Registries.DATA_COMPONENT_TYPE, id, obj);
RegistrySyncUtils.setServerEntry(Registries.DATA_COMPONENT_TYPE, obj);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.pb4.cctpatch.mixin.mod.item;

import dan200.computercraft.shared.computer.items.AbstractComputerItem;
import dan200.computercraft.shared.peripheral.modem.wired.CableBlockItem;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemUsageContext;
Expand All @@ -12,9 +13,9 @@
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(AbstractComputerItem.class)
public abstract class AbstractComputerItemMixin extends BlockItem {
public AbstractComputerItemMixin(Block block, Settings settings) {
@Mixin({AbstractComputerItem.class, CableBlockItem.class})
public abstract class PlaceAnimationFixItemMixin extends BlockItem {
public PlaceAnimationFixItemMixin(Block block, Settings settings) {
super(block, settings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import eu.pb4.polymer.core.api.item.PolymerItem;
import eu.pb4.polymer.core.api.item.PolymerItemUtils;
import it.unimi.dsi.fastutil.ints.IntList;
import net.minecraft.client.item.TooltipType;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.DyedColorComponent;
import net.minecraft.component.type.FireworkExplosionComponent;
Expand All @@ -21,6 +20,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtIntArray;
import net.minecraft.network.packet.s2c.play.InventoryS2CPacket;
Expand Down Expand Up @@ -51,7 +51,7 @@ public int getPolymerCustomModelData(ItemStack itemStack, @Nullable ServerPlayer
}
@Override
public ItemStack getPolymerItemStack(ItemStack itemStack, TooltipType context, RegistryWrapper.WrapperLookup lookup, @Nullable ServerPlayerEntity player) {
var stack = PolymerItemUtils.createItemStack(itemStack, context, player);
var stack = PolymerItemUtils.createItemStack(itemStack, context, lookup, player);
var data = this.model.getModelData(itemStack, isPlayerboundPacket());
var color = DyedColorComponent.getColor(stack, Colour.WHITE.getARGB());
if (data.item() == Items.FIREWORK_STAR) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import eu.pb4.polymer.resourcepack.api.PolymerModelData;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import it.unimi.dsi.fastutil.ints.IntList;
import net.minecraft.client.item.TooltipType;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.DyedColorComponent;
import net.minecraft.component.type.FireworkExplosionComponent;
Expand Down Expand Up @@ -63,7 +63,7 @@ public ItemStack getPolymerItemStack(ItemStack itemStack, TooltipType context, R
@Override
public void onRegistered(Identifier selfId) {
this.defaultModel = PolymerResourcePackUtils.requestModel(BaseItemProvider.requestItem(),
new Identifier(selfId.getNamespace(), "item/" + selfId.getPath()));
this.dyedModel = PolymerResourcePackUtils.requestModel(Items.FIREWORK_STAR, new Identifier("computercraft:block/turtle_colour"));
Identifier.of(selfId.getNamespace(), "item/" + selfId.getPath()));
this.dyedModel = PolymerResourcePackUtils.requestModel(Items.FIREWORK_STAR, Identifier.of("computercraft:block/turtle_colour"));
}
}
2 changes: 1 addition & 1 deletion src/main/resources/cc-tweaked-polymer-patch.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"mod.ext.ServerInputStateMixin",
"mod.ext.ServerMonitorMixin",
"mod.ext.TerminalMixin",
"mod.item.AbstractComputerItemMixin",
"mod.item.PlaceAnimationFixItemMixin",
"mod.item.GenericItemMixin",
"mod.item.ModRegistryCreativeTabsMixin",
"mod.item.ModRegistryDataComponentsMixin",
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
],
"depends": {
"fabricloader": ">=0.15.0",
"computercraft": ">=1.109.6",
"minecraft": "~1.20.5",
"java": ">=17",
"computercraft": ">=1.101.0",
"minecraft": ">=1.21-",
"java": ">=21",
"fabric-api": "*"
}
}

0 comments on commit 710d2e8

Please sign in to comment.