Skip to content

Commit 8f4d403

Browse files
committed
Merge branch 'mc-1.20.x' into mc-1.21.x
2 parents 70a7478 + 63ba3fe commit 8f4d403

File tree

22 files changed

+577
-255
lines changed

22 files changed

+577
-255
lines changed

buildSrc/src/main/kotlin/cc/tweaked/gradle/XmlUtil.kt

Lines changed: 0 additions & 16 deletions
This file was deleted.

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ junitPlatform = "1.11.4"
5858
jmh = "1.37"
5959

6060
# Build tools
61-
cctJavadoc = "1.8.3"
61+
cctJavadoc = "1.8.4"
6262
checkstyle = "10.21.2"
6363
errorProne-core = "2.36.0"
6464
errorProne-plugin = "4.1.0"
65-
fabric-loom = "1.9.2"
65+
fabric-loom = "1.10.3"
6666
githubRelease = "2.5.2"
6767
gradleVersions = "0.50.0"
6868
ideaExt = "1.1.7"
@@ -75,7 +75,7 @@ shadow = "8.3.1"
7575
spotless = "6.23.3"
7676
taskTree = "2.1.1"
7777
teavm = "0.11.0-SQUID.1"
78-
vanillaExtract = "0.2.0"
78+
vanillaExtract = "0.2.1"
7979
versionCatalogUpdate = "0.8.1"
8080

8181
[libraries]

projects/common-api/src/main/java/dan200/computercraft/api/detail/ComponentDetailProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ public ComponentDetailProvider(DataComponentType<T> component) {
5151
* This method is always called on the server thread, so it is safe to interact with the world here, but you should
5252
* take care to avoid long blocking operations as this will stall the server and other computers.
5353
*
54-
* @param data The full details to be returned for this item stack. New properties should be added to this map.
55-
* @param item The component to provide details for.
54+
* @param data The full details to be returned for this item stack. New properties should be added to this map.
55+
* @param component The component to provide details for.
5656
*/
57-
public abstract void provideComponentDetails(Map<? super String, Object> data, T item);
57+
public abstract void provideComponentDetails(Map<? super String, Object> data, T component);
5858

5959
@Override
6060
public final void provideDetails(Map<? super String, Object> data, DataComponentHolder holder) {

projects/common/src/client/java/dan200/computercraft/client/ClientRegistry.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
import net.minecraft.world.item.component.DyedItemColor;
5353
import net.minecraft.world.level.ItemLike;
5454
import org.jspecify.annotations.Nullable;
55+
import org.slf4j.Logger;
56+
import org.slf4j.LoggerFactory;
5557

5658
import java.io.File;
5759
import java.io.IOException;
@@ -69,6 +71,8 @@
6971
* @see ModRegistry The common registry for actual game objects.
7072
*/
7173
public final class ClientRegistry {
74+
private static final Logger LOG = LoggerFactory.getLogger(ClientRegistry.class);
75+
7276
private ClientRegistry() {
7377
}
7478

@@ -192,7 +196,18 @@ private static int getTurtleColour(ItemStack stack, int layer) {
192196
}
193197

194198
public static void registerShaders(ResourceProvider resources, BiConsumer<ShaderInstance, Consumer<ShaderInstance>> load) throws IOException {
195-
RenderTypes.registerShaders(resources, load);
199+
RenderTypes.registerShaders(resources, (name, create, onLoaded) -> {
200+
ShaderInstance shader;
201+
try {
202+
shader = create.get();
203+
} catch (Exception e) {
204+
LOG.error("Failed to load {}", name, e);
205+
onLoaded.accept(null);
206+
return;
207+
}
208+
209+
load.accept(shader, onLoaded);
210+
});
196211
}
197212

198213
private record UnclampedPropertyFunction(

projects/common/src/client/java/dan200/computercraft/client/render/CustomLecternRenderer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
1313
import dan200.computercraft.core.terminal.Terminal;
1414
import dan200.computercraft.core.util.Colour;
15+
import dan200.computercraft.shared.ModRegistry;
1516
import dan200.computercraft.shared.lectern.CustomLecternBlockEntity;
1617
import dan200.computercraft.shared.media.items.PrintoutData;
1718
import dan200.computercraft.shared.media.items.PrintoutItem;
@@ -59,9 +60,9 @@ public void render(CustomLecternBlockEntity lectern, float partialTick, PoseStac
5960
poseStack.translate(0, -0.125f, 0);
6061

6162
var item = lectern.getItem();
62-
if (item.getItem() instanceof PrintoutItem printout) {
63+
if (item.getItem() instanceof PrintoutItem) {
6364
var vertexConsumer = LecternPrintoutModel.MATERIAL.buffer(buffer, RenderType::entitySolid);
64-
if (printout.getType() == PrintoutItem.Type.BOOK) {
65+
if (item.is(ModRegistry.Items.PRINTED_BOOK.get())) {
6566
printoutModel.renderBook(poseStack, vertexConsumer, packedLight, packedOverlay);
6667
} else {
6768
printoutModel.renderPages(poseStack, vertexConsumer, packedLight, packedOverlay, PrintoutData.getOrEmpty(item).pages());

projects/common/src/client/java/dan200/computercraft/client/render/PrintoutItemRenderer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.mojang.math.Axis;
99
import dan200.computercraft.shared.ModRegistry;
1010
import dan200.computercraft.shared.media.items.PrintoutData;
11-
import dan200.computercraft.shared.media.items.PrintoutItem;
1211
import net.minecraft.client.renderer.MultiBufferSource;
1312
import net.minecraft.world.entity.EntityType;
1413
import net.minecraft.world.entity.decoration.ItemFrame;
@@ -53,7 +52,7 @@ private static void drawPrintout(PoseStack transform, MultiBufferSource render,
5352
var pageData = stack.getOrDefault(ModRegistry.DataComponents.PRINTOUT.get(), PrintoutData.EMPTY);
5453

5554
var pages = pageData.pages();
56-
var book = ((PrintoutItem) stack.getItem()).getType() == PrintoutItem.Type.BOOK;
55+
var book = stack.is(ModRegistry.Items.PRINTED_BOOK.get());
5756

5857
double width = LINE_LENGTH * FONT_WIDTH + X_TEXT_MARGIN * 2;
5958
double height = LINES_PER_PAGE * FONT_HEIGHT + Y_TEXT_MARGIN * 2;

projects/common/src/client/java/dan200/computercraft/client/render/RenderTypes.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
import net.minecraft.client.renderer.ShaderInstance;
1717
import net.minecraft.resources.ResourceLocation;
1818
import net.minecraft.server.packs.resources.ResourceProvider;
19+
import org.apache.commons.io.function.IOSupplier;
1920
import org.jspecify.annotations.Nullable;
2021

2122
import java.io.IOException;
2223
import java.util.Objects;
23-
import java.util.function.BiConsumer;
2424
import java.util.function.Consumer;
2525

2626
/**
@@ -68,9 +68,12 @@ public static ShaderInstance getTerminalShader() {
6868
return Objects.requireNonNull(GameRenderer.getRendertypeTextShader(), "Text shader has not been registered");
6969
}
7070

71-
public static void registerShaders(ResourceProvider resources, BiConsumer<ShaderInstance, Consumer<ShaderInstance>> load) throws IOException {
72-
load.accept(
73-
new MonitorTextureBufferShader(
71+
public interface ShaderLoader {
72+
void tryLoad(String name, IOSupplier<ShaderInstance> create, Consumer<@Nullable ShaderInstance> accept) throws IOException;
73+
}
74+
75+
public static void registerShaders(ResourceProvider resources, ShaderLoader load) throws IOException {
76+
load.tryLoad("monitor shader", () -> new MonitorTextureBufferShader(
7477
resources,
7578
ComputerCraftAPI.MOD_ID + "/monitor_tbo",
7679
MONITOR_TBO.format()

projects/common/src/main/java/dan200/computercraft/shared/ModRegistry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@ private static Item.Properties printoutProperties() {
284284
}
285285

286286
public static final RegistryEntry<PrintoutItem> PRINTED_PAGE = REGISTRY.register("printed_page",
287-
() -> new PrintoutItem(printoutProperties(), PrintoutItem.Type.PAGE));
287+
() -> new PrintoutItem(printoutProperties()));
288288
public static final RegistryEntry<PrintoutItem> PRINTED_PAGES = REGISTRY.register("printed_pages",
289-
() -> new PrintoutItem(printoutProperties(), PrintoutItem.Type.PAGES));
289+
() -> new PrintoutItem(printoutProperties()));
290290
public static final RegistryEntry<PrintoutItem> PRINTED_BOOK = REGISTRY.register("printed_book",
291-
() -> new PrintoutItem(printoutProperties(), PrintoutItem.Type.BOOK));
291+
() -> new PrintoutItem(printoutProperties()));
292292

293293
public static final RegistryEntry<BlockItem> SPEAKER = ofBlock(Blocks.SPEAKER, BlockItem::new);
294294
public static final RegistryEntry<BlockItem> DISK_DRIVE = ofBlock(Blocks.DISK_DRIVE, BlockItem::new);

projects/common/src/main/java/dan200/computercraft/shared/media/items/PrintoutItem.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,8 @@
2020
import java.util.List;
2121

2222
public class PrintoutItem extends Item {
23-
public enum Type {
24-
PAGE,
25-
PAGES,
26-
BOOK
27-
}
28-
29-
private final Type type;
30-
31-
public PrintoutItem(Properties settings, Type type) {
23+
public PrintoutItem(Properties settings) {
3224
super(settings);
33-
this.type = type;
3425
}
3526

3627
@Override
@@ -49,8 +40,4 @@ public InteractionResultHolder<ItemStack> use(Level world, Player player, Intera
4940
}
5041
return new InteractionResultHolder<>(InteractionResult.sidedSuccess(world.isClientSide), stack);
5142
}
52-
53-
public Type getType() {
54-
return type;
55-
}
5643
}

projects/common/src/main/java/dan200/computercraft/shared/peripheral/printer/PrinterBlockEntity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ static boolean isInk(ItemStack stack) {
170170
}
171171

172172
static boolean isPaper(ItemStack stack) {
173-
var item = stack.getItem();
174-
return item == Items.PAPER || item == ModRegistry.Items.PRINTED_PAGE.get();
173+
return stack.is(Items.PAPER) || stack.is(ModRegistry.Items.PRINTED_PAGE.get());
175174
}
176175

177176
private boolean canInputPage() {

0 commit comments

Comments
 (0)