mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-04-23 03:03:19 +00:00
Remove PrintoutItem.getType
Kinda surprised this is still around! Not sure why I kept it post the-flattening really, it's been redundant for a while.
This commit is contained in:
parent
b97634b717
commit
749b3df227
@ -12,6 +12,7 @@ import dan200.computercraft.client.pocket.ClientPocketComputers;
|
||||
import dan200.computercraft.client.render.text.FixedWidthFontRenderer;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.core.util.Colour;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.lectern.CustomLecternBlockEntity;
|
||||
import dan200.computercraft.shared.media.items.PrintoutItem;
|
||||
import dan200.computercraft.shared.pocket.items.PocketComputerItem;
|
||||
@ -57,9 +58,9 @@ public class CustomLecternRenderer implements BlockEntityRenderer<CustomLecternB
|
||||
poseStack.translate(0, -0.125f, 0);
|
||||
|
||||
var item = lectern.getItem();
|
||||
if (item.getItem() instanceof PrintoutItem printout) {
|
||||
if (item.getItem() instanceof PrintoutItem) {
|
||||
var vertexConsumer = LecternPrintoutModel.MATERIAL.buffer(buffer, RenderType::entitySolid);
|
||||
if (printout.getType() == PrintoutItem.Type.BOOK) {
|
||||
if (item.is(ModRegistry.Items.PRINTED_BOOK.get())) {
|
||||
printoutModel.renderBook(poseStack, vertexConsumer, packedLight, packedOverlay);
|
||||
} else {
|
||||
printoutModel.renderPages(poseStack, vertexConsumer, packedLight, packedOverlay, PrintoutItem.getPageCount(item));
|
||||
|
@ -6,6 +6,7 @@ package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.media.items.PrintoutItem;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
@ -51,7 +52,7 @@ public final class PrintoutItemRenderer extends ItemMapLikeRenderer {
|
||||
|
||||
private static void drawPrintout(PoseStack transform, MultiBufferSource render, ItemStack stack, int light) {
|
||||
var pages = PrintoutItem.getPageCount(stack);
|
||||
var book = ((PrintoutItem) stack.getItem()).getType() == PrintoutItem.Type.BOOK;
|
||||
var book = stack.is(ModRegistry.Items.PRINTED_BOOK.get());
|
||||
|
||||
double width = LINE_MAX_LENGTH * FONT_WIDTH + X_TEXT_MARGIN * 2;
|
||||
double height = LINES_PER_PAGE * FONT_HEIGHT + Y_TEXT_MARGIN * 2;
|
||||
|
@ -264,11 +264,11 @@ public final class ModRegistry {
|
||||
REGISTRY.register("treasure_disk", () -> new TreasureDiskItem(properties().stacksTo(1)));
|
||||
|
||||
public static final RegistryEntry<PrintoutItem> PRINTED_PAGE = REGISTRY.register("printed_page",
|
||||
() -> new PrintoutItem(properties().stacksTo(1), PrintoutItem.Type.PAGE));
|
||||
() -> new PrintoutItem(properties().stacksTo(1)));
|
||||
public static final RegistryEntry<PrintoutItem> PRINTED_PAGES = REGISTRY.register("printed_pages",
|
||||
() -> new PrintoutItem(properties().stacksTo(1), PrintoutItem.Type.PAGES));
|
||||
() -> new PrintoutItem(properties().stacksTo(1)));
|
||||
public static final RegistryEntry<PrintoutItem> PRINTED_BOOK = REGISTRY.register("printed_book",
|
||||
() -> new PrintoutItem(properties().stacksTo(1), PrintoutItem.Type.BOOK));
|
||||
() -> new PrintoutItem(properties().stacksTo(1)));
|
||||
|
||||
public static final RegistryEntry<BlockItem> SPEAKER = ofBlock(Blocks.SPEAKER, BlockItem::new);
|
||||
public static final RegistryEntry<BlockItem> DISK_DRIVE = ofBlock(Blocks.DISK_DRIVE, BlockItem::new);
|
||||
|
@ -33,17 +33,8 @@ public class PrintoutItem extends Item {
|
||||
public static final int LINE_MAX_LENGTH = 25;
|
||||
public static final int MAX_PAGES = 16;
|
||||
|
||||
public enum Type {
|
||||
PAGE,
|
||||
PAGES,
|
||||
BOOK
|
||||
}
|
||||
|
||||
private final Type type;
|
||||
|
||||
public PrintoutItem(Properties settings, Type type) {
|
||||
public PrintoutItem(Properties settings) {
|
||||
super(settings);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -103,10 +94,6 @@ public class PrintoutItem extends Item {
|
||||
return ModRegistry.Items.PRINTED_BOOK.get().createFromTitleAndText(title, text, colours);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static String getTitle(ItemStack stack) {
|
||||
var nbt = stack.getTag();
|
||||
return nbt != null && nbt.contains(NBT_TITLE) ? nbt.getString(NBT_TITLE) : "";
|
||||
|
@ -58,7 +58,7 @@ public final class PrintoutRecipe extends CustomRecipe {
|
||||
for (var x = 0; x < inventory.getWidth(); x++) {
|
||||
var stack = inventory.getItem(x + y * inventory.getWidth());
|
||||
if (!stack.isEmpty()) {
|
||||
if (stack.getItem() instanceof PrintoutItem printout && printout.getType() != PrintoutItem.Type.BOOK) {
|
||||
if (!stack.is(ModRegistry.Items.PRINTED_BOOK.get())) {
|
||||
if (printouts == null) printouts = new ItemStack[9];
|
||||
printouts[numPrintouts] = stack;
|
||||
numPages += PrintoutItem.getPageCount(stack);
|
||||
|
@ -5,6 +5,7 @@
|
||||
package dan200.computercraft.shared.peripheral.printer;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.common.AbstractContainerBlockEntity;
|
||||
import dan200.computercraft.shared.computer.terminal.NetworkedTerminal;
|
||||
import dan200.computercraft.shared.container.BasicWorldlyContainer;
|
||||
@ -159,9 +160,7 @@ public final class PrinterBlockEntity extends AbstractContainerBlockEntity imple
|
||||
}
|
||||
|
||||
static boolean isPaper(ItemStack stack) {
|
||||
var item = stack.getItem();
|
||||
return item == Items.PAPER
|
||||
|| (item instanceof PrintoutItem printout && printout.getType() == PrintoutItem.Type.PAGE);
|
||||
return stack.is(Items.PAPER) || stack.is(ModRegistry.Items.PRINTED_PAGE.get());
|
||||
}
|
||||
|
||||
private boolean canInputPage() {
|
||||
|
@ -439,14 +439,14 @@ class Turtle_Test {
|
||||
object :
|
||||
BasicItemDetailProvider<PrintoutItem>("printout", PrintoutItem::class.java) {
|
||||
override fun provideDetails(data: MutableMap<in String, Any>, stack: ItemStack, item: PrintoutItem) {
|
||||
data["type"] = item.type.toString().lowercase()
|
||||
data["pages"] = PrintoutItem.getPageCount(stack)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
thenOnComputer {
|
||||
val details = getTurtleItemDetail(detailed = true)
|
||||
assertEquals(mapOf("type" to "page"), details["printout"]) {
|
||||
assertEquals(mapOf("pages" to 1), details["printout"]) {
|
||||
"Printout information is returned (whole map is $details)"
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user