1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 22:53:22 +00:00

Update to 1.19.4 (#1376)

This commit is contained in:
Jonathan Coates 2023-03-15 21:04:11 +00:00 committed by GitHub
parent 44f945c040
commit 3e6e3e70e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
132 changed files with 320 additions and 226 deletions

View File

@ -9,4 +9,4 @@ isUnstable=false
modVersion=1.103.1
# Minecraft properties: We want to configure this here so we can read it in settings.gradle
mcVersion=1.19.3
mcVersion=1.19.4

View File

@ -3,9 +3,9 @@
# Minecraft
# MC version is specified in gradle.properties, as we need that in settings.gradle.
# Remember to update corresponding versions in fabric.mod.json/mods.toml
fabric-api = "0.75.1+1.19.3"
fabric-api = "0.75.3+1.19.4"
fabric-loader = "0.14.17"
forge = "44.1.0"
forge = "45.0.6"
forgeSpi = "6.0.0"
mixin = "0.8.5"
parchment = "2023.03.12"
@ -27,13 +27,13 @@ nightConfig = "3.6.5"
slf4j = "1.7.36"
# Minecraft mods
iris = "1.19.3-v1.4.6"
iris = "1.5.2+1.19.4"
jei = "11.3.0.262"
modmenu = "5.0.1"
modmenu = "6.1.0-rc.1"
oculus = "1.2.5"
rei = "10.0.578"
rubidium = "0.6.1"
sodium = "mc1.19.3-0.4.6"
sodium = "mc1.19.4-0.4.10"
# Testing
byteBuddy = "1.14.2"

View File

@ -26,6 +26,7 @@
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.resources.ResourceLocation;
@ -34,8 +35,6 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import javax.annotation.Nullable;
import java.io.IOException;
@ -70,6 +69,11 @@ public static void register() {
ComputerCraftAPIClient.registerTurtleUpgradeModeller(ModRegistry.TurtleSerialisers.WIRELESS_MODEM_NORMAL.get(), new TurtleModemModeller(false));
ComputerCraftAPIClient.registerTurtleUpgradeModeller(ModRegistry.TurtleSerialisers.WIRELESS_MODEM_ADVANCED.get(), new TurtleModemModeller(true));
ComputerCraftAPIClient.registerTurtleUpgradeModeller(ModRegistry.TurtleSerialisers.TOOL.get(), TurtleUpgradeModeller.flatItem());
BlockEntityRenderers.register(ModRegistry.BlockEntities.MONITOR_NORMAL.get(), MonitorBlockEntityRenderer::new);
BlockEntityRenderers.register(ModRegistry.BlockEntities.MONITOR_ADVANCED.get(), MonitorBlockEntityRenderer::new);
BlockEntityRenderers.register(ModRegistry.BlockEntities.TURTLE_NORMAL.get(), TurtleBlockEntityRenderer::new);
BlockEntityRenderers.register(ModRegistry.BlockEntities.TURTLE_ADVANCED.get(), TurtleBlockEntityRenderer::new);
}
/**
@ -166,17 +170,6 @@ private static int getTurtleColour(ItemStack stack, int layer) {
return layer == 0 ? ((IColouredItem) stack.getItem()).getColour(stack) : 0xFFFFFF;
}
public static void registerBlockEntityRenderers(BlockEntityRenderRegistry register) {
register.register(ModRegistry.BlockEntities.MONITOR_NORMAL.get(), MonitorBlockEntityRenderer::new);
register.register(ModRegistry.BlockEntities.MONITOR_ADVANCED.get(), MonitorBlockEntityRenderer::new);
register.register(ModRegistry.BlockEntities.TURTLE_NORMAL.get(), TurtleBlockEntityRenderer::new);
register.register(ModRegistry.BlockEntities.TURTLE_ADVANCED.get(), TurtleBlockEntityRenderer::new);
}
public interface BlockEntityRenderRegistry {
<T extends BlockEntity> void register(BlockEntityType<? extends T> type, BlockEntityRendererProvider<T> provider);
}
public static void registerShaders(ResourceProvider resources, BiConsumer<ShaderInstance, Consumer<ShaderInstance>> load) throws IOException {
RenderTypes.registerShaders(resources, load);
}

View File

@ -34,7 +34,7 @@ public void renderBg(PoseStack stack, float partialTicks, int mouseX, int mouseY
// Draw a border around the terminal
var terminal = getTerminal();
ComputerBorderRenderer.render(
stack.last().pose(), ComputerBorderRenderer.getTexture(family), terminal.getX(), terminal.getY(), getBlitOffset(),
stack.last().pose(), ComputerBorderRenderer.getTexture(family), terminal.getX(), terminal.getY(),
FULL_BRIGHT_LIGHTMAP, terminal.getWidth(), terminal.getHeight()
);
ComputerSidebar.renderBackground(stack, leftPos, topPos + sidebarYOffset);

View File

@ -8,6 +8,7 @@
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.components.toasts.Toast;
import net.minecraft.client.gui.components.toasts.ToastComponent;
import net.minecraft.network.chat.Component;
@ -84,7 +85,7 @@ public Visibility render(PoseStack transform, ToastComponent component, long tim
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
if (width == 160 && message.size() <= 1) {
component.blit(transform, 0, 0, 0, 64, width, height());
GuiComponent.blit(transform, 0, 0, 0, 64, width, height());
} else {
var height = height();
@ -102,7 +103,7 @@ public Visibility render(PoseStack transform, ToastComponent component, long tim
var textX = MARGIN;
if (!stack.isEmpty()) {
textX += MARGIN + IMAGE_SIZE;
component.getMinecraft().getItemRenderer().renderAndDecorateFakeItem(stack, MARGIN, MARGIN + height() / 2 - IMAGE_SIZE);
component.getMinecraft().getItemRenderer().renderAndDecorateFakeItem(transform, stack, MARGIN, MARGIN + height() / 2 - IMAGE_SIZE);
}
component.getMinecraft().font.draw(transform, title, textX, MARGIN, 0xff500050);
@ -117,11 +118,11 @@ private static void renderBackgroundRow(PoseStack transform, ToastComponent comp
var leftOffset = 5;
var rightOffset = Math.min(60, x - leftOffset);
component.blit(transform, 0, y, 0, 32 + u, leftOffset, height);
GuiComponent.blit(transform, 0, y, 0, 32 + u, leftOffset, height);
for (var k = leftOffset; k < x - rightOffset; k += 64) {
component.blit(transform, k, y, 32, 32 + u, Math.min(64, x - k - rightOffset), height);
GuiComponent.blit(transform, k, y, 32, 32 + u, Math.min(64, x - k - rightOffset), height);
}
component.blit(transform, x - rightOffset, y, 160 - rightOffset, 32 + u, rightOffset, height);
GuiComponent.blit(transform, x - rightOffset, y, 160 - rightOffset, 32 + u, rightOffset, height);
}
}

View File

@ -87,7 +87,7 @@ protected void renderBg(PoseStack transform, float partialTicks, int mouseX, int
RenderSystem.enableDepthTest();
var renderer = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
drawBorder(transform, renderer, leftPos, topPos, getBlitOffset(), page, pages, book, FULL_BRIGHT_LIGHTMAP);
drawBorder(transform, renderer, leftPos, topPos, 0, page, pages, book, FULL_BRIGHT_LIGHTMAP);
drawText(transform, renderer, leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, PrintoutItem.LINES_PER_PAGE * page, FULL_BRIGHT_LIGHTMAP, text, colours);
renderer.endBatch();
}
@ -95,9 +95,10 @@ protected void renderBg(PoseStack transform, float partialTicks, int mouseX, int
@Override
public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) {
// We must take the background further back in order to not overlap with our printed pages.
setBlitOffset(getBlitOffset() - 1);
stack.pushPose();
stack.translate(0, 0, -1);
renderBackground(stack);
setBlitOffset(getBlitOffset() + 1);
stack.popPose();
super.render(stack, mouseX, mouseY, partialTicks);
}

View File

@ -58,7 +58,7 @@ public DynamicImageButton(
}
@Override
public void renderButton(PoseStack stack, int mouseX, int mouseY, float partialTicks) {
public void renderWidget(PoseStack stack, int mouseX, int mouseY, float partialTicks) {
RenderSystem.setShaderTexture(0, texture);
RenderSystem.disableDepthTest();

View File

@ -245,7 +245,9 @@ public void update() {
}
@Override
public void onFocusedChanged(boolean focused) {
public void setFocused(boolean focused) {
super.setFocused(focused);
if (!focused) {
// When blurring, we should make all keys go up
for (var key = 0; key < keysDown.size(); key++) {
@ -264,7 +266,7 @@ public void onFocusedChanged(boolean focused) {
}
@Override
public void render(PoseStack transform, int mouseX, int mouseY, float partialTicks) {
public void renderWidget(PoseStack transform, int mouseX, int mouseY, float partialTicks) {
if (!visible) return;
var bufferSource = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());

View File

@ -72,9 +72,9 @@ public static RenderType getRenderType(ResourceLocation location) {
return RenderType.text(location);
}
public static void render(Matrix4f transform, ResourceLocation location, int x, int y, int z, int light, int width, int height) {
public static void render(Matrix4f transform, ResourceLocation location, int x, int y, int light, int width, int height) {
var source = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
render(transform, source.getBuffer(getRenderType(location)), x, y, z, light, width, height, false, 1, 1, 1);
render(transform, source.getBuffer(getRenderType(location)), x, y, 1, light, width, height, false, 1, 1, 1);
source.endBatch();
}

View File

@ -87,8 +87,9 @@ public void render(TurtleBlockEntity turtle, float partialTicks, PoseStack trans
var matrix = transform.last().pose();
var opacity = (int) (mc.options.getBackgroundOpacity(0.25f) * 255) << 24;
var width = -font.width(label) / 2.0f;
font.drawInBatch(label, width, (float) 0, 0x20ffffff, false, matrix, buffers, true, opacity, lightmapCoord);
font.drawInBatch(label, width, (float) 0, 0xffffffff, false, matrix, buffers, false, 0, lightmapCoord);
// TODO: Check this looks okay
font.drawInBatch(label, width, (float) 0, 0x20ffffff, false, matrix, buffers, Font.DisplayMode.SEE_THROUGH, opacity, lightmapCoord);
font.drawInBatch(label, width, (float) 0, 0xffffffff, false, matrix, buffers, Font.DisplayMode.NORMAL, 0, lightmapCoord);
transform.popPose();
}

View File

@ -82,6 +82,7 @@
import net.minecraft.core.cauldron.CauldronInteraction;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.*;
import net.minecraft.world.item.crafting.CustomRecipe;
@ -295,10 +296,10 @@ public static class Menus {
() -> ContainerData.toType(ComputerContainerData::new, TurtleMenu::ofMenuData));
public static final RegistryEntry<MenuType<DiskDriveMenu>> DISK_DRIVE = REGISTRY.register("disk_drive",
() -> new MenuType<>(DiskDriveMenu::new));
() -> new MenuType<>(DiskDriveMenu::new, FeatureFlags.VANILLA_SET));
public static final RegistryEntry<MenuType<PrinterMenu>> PRINTER = REGISTRY.register("printer",
() -> new MenuType<>(PrinterMenu::new));
() -> new MenuType<>(PrinterMenu::new, FeatureFlags.VANILLA_SET));
public static final RegistryEntry<MenuType<HeldItemMenu>> PRINTOUT = REGISTRY.register("printout",
() -> ContainerData.toType(HeldItemContainerData::new, HeldItemMenu::createPrintout));
@ -409,10 +410,10 @@ public static CreativeModeTab.Builder registerCreativeTab(CreativeModeTab.Builde
return builder
.icon(() -> new ItemStack(Items.COMPUTER_NORMAL.get()))
.title(Component.translatable("itemGroup.computercraft"))
.displayItems((flags, out, isOp) -> {
.displayItems((context, out) -> {
out.accept(new ItemStack(Items.COMPUTER_NORMAL.get()));
out.accept(new ItemStack(Items.COMPUTER_ADVANCED.get()));
if (isOp) out.accept(new ItemStack(Items.COMPUTER_COMMAND.get()));
if (context.hasPermissions()) out.accept(new ItemStack(Items.COMPUTER_COMMAND.get()));
addTurtle(out, Items.TURTLE_NORMAL.get());
addTurtle(out, Items.TURTLE_ADVANCED.get());
addPocket(out, Items.POCKET_COMPUTER_NORMAL.get());

View File

@ -23,9 +23,9 @@
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.RelativeMovement;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
@ -67,7 +67,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
// Unless we're on a server, limit the number of rows we can send.
Level world = source.getLevel();
var pos = new BlockPos(source.getPosition());
var pos = BlockPos.containing(source.getPosition());
computers.sort((a, b) -> {
if (a.getLevel() == b.getLevel() && a.getLevel() == world) {
@ -158,7 +158,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
if (player.getCommandSenderWorld() == world) {
player.connection.teleport(
pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0,
EnumSet.noneOf(ClientboundPlayerPositionPacket.RelativeArgument.class)
EnumSet.noneOf(RelativeMovement.class)
);
} else {
player.teleportTo(world,

View File

@ -7,6 +7,7 @@
import dan200.computercraft.shared.ModRegistry;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
@ -48,7 +49,7 @@ public boolean matches(CraftingContainer inv, Level world) {
}
@Override
public ItemStack assemble(CraftingContainer inv) {
public ItemStack assemble(CraftingContainer inv, RegistryAccess registryAccess) {
var colourable = ItemStack.EMPTY;
for (var i = 0; i < inv.getContainerSize(); i++) {

View File

@ -8,6 +8,7 @@
import dan200.computercraft.shared.ModRegistry;
import dan200.computercraft.shared.util.ColourTracker;
import dan200.computercraft.shared.util.ColourUtils;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
@ -43,7 +44,7 @@ public boolean matches(CraftingContainer inv, Level world) {
}
@Override
public ItemStack assemble(CraftingContainer inv) {
public ItemStack assemble(CraftingContainer inv, RegistryAccess registryAccess) {
var colourable = ItemStack.EMPTY;
var tracker = new ColourTracker();

View File

@ -7,6 +7,7 @@
import dan200.computercraft.shared.computer.items.IComputerItem;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
@ -20,10 +21,16 @@
*/
public abstract class ComputerConvertRecipe extends ShapedRecipe {
private final String group;
private final ItemStack result;
public ComputerConvertRecipe(ResourceLocation identifier, String group, CraftingBookCategory category, int width, int height, NonNullList<Ingredient> ingredients, ItemStack result) {
super(identifier, group, category, width, height, ingredients, result);
this.group = group;
this.result = result;
}
public ItemStack getResultItem() {
return result;
}
protected abstract ItemStack convert(IComputerItem item, ItemStack stack);
@ -40,7 +47,7 @@ public boolean matches(CraftingContainer inventory, Level world) {
}
@Override
public ItemStack assemble(CraftingContainer inventory) {
public ItemStack assemble(CraftingContainer inventory, RegistryAccess registryAccess) {
// Find our computer item and convert it.
for (var i = 0; i < inventory.getContainerSize(); i++) {
var stack = inventory.getItem(i);

View File

@ -11,6 +11,7 @@
import dan200.computercraft.shared.platform.PlatformHelper;
import dan200.computercraft.shared.util.ColourTracker;
import dan200.computercraft.shared.util.ColourUtils;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
@ -54,7 +55,7 @@ public boolean matches(CraftingContainer inv, Level world) {
}
@Override
public ItemStack assemble(CraftingContainer inv) {
public ItemStack assemble(CraftingContainer inv, RegistryAccess registryAccess) {
var tracker = new ColourTracker();
for (var i = 0; i < inv.getContainerSize(); i++) {
@ -77,7 +78,7 @@ public boolean canCraftInDimensions(int x, int y) {
}
@Override
public ItemStack getResultItem() {
public ItemStack getResultItem(RegistryAccess registryAccess) {
return DiskItem.createFromIDAndColour(-1, null, Colour.BLUE.getHex());
}

View File

@ -8,6 +8,7 @@
import dan200.computercraft.shared.ModRegistry;
import dan200.computercraft.shared.media.items.PrintoutItem;
import dan200.computercraft.shared.platform.PlatformHelper;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
@ -36,17 +37,17 @@ public boolean canCraftInDimensions(int x, int y) {
}
@Override
public ItemStack getResultItem() {
public ItemStack getResultItem(RegistryAccess registryAccess) {
return PrintoutItem.createMultipleFromTitleAndText(null, null, null);
}
@Override
public boolean matches(CraftingContainer inventory, Level world) {
return !assemble(inventory).isEmpty();
return !assemble(inventory, world.registryAccess()).isEmpty();
}
@Override
public ItemStack assemble(CraftingContainer inventory) {
public ItemStack assemble(CraftingContainer inventory, RegistryAccess registryAccess) {
// See if we match the recipe, and extract the input disk ID and dye colour
var numPages = 0;
var numPrintouts = 0;

View File

@ -133,7 +133,7 @@ public void update() {
// free again.
PlatformHelper.get().sendToAllTracking(
new SpeakerAudioClientMessage(getSource(), position, dfpwmState.getVolume(), dfpwmState.pullPending(now)),
level.getChunkAt(new BlockPos(pos))
level.getChunkAt(BlockPos.containing(pos))
);
syncedPosition(position);
@ -152,7 +152,7 @@ public void update() {
// TODO: What to do when entities move away? How do we notify people left behind that they're gone.
PlatformHelper.get().sendToAllTracking(
new SpeakerMoveClientMessage(getSource(), position),
level.getChunkAt(new BlockPos(pos))
level.getChunkAt(BlockPos.containing(pos))
);
syncedPosition(position);
}

View File

@ -11,6 +11,7 @@
import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.pocket.items.PocketComputerItem;
import dan200.computercraft.shared.pocket.items.PocketComputerItemFactory;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
@ -30,17 +31,17 @@ public boolean canCraftInDimensions(int x, int y) {
}
@Override
public ItemStack getResultItem() {
public ItemStack getResultItem(RegistryAccess registryAccess) {
return PocketComputerItemFactory.create(-1, null, -1, ComputerFamily.NORMAL, null);
}
@Override
public boolean matches(CraftingContainer inventory, Level world) {
return !assemble(inventory).isEmpty();
return !assemble(inventory, world.registryAccess()).isEmpty();
}
@Override
public ItemStack assemble(CraftingContainer inventory) {
public ItemStack assemble(CraftingContainer inventory, RegistryAccess registryAccess) {
// Scan the grid for a pocket computer
var computer = ItemStack.EMPTY;
var computerX = -1;

View File

@ -12,6 +12,7 @@
import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.turtle.items.ITurtleItem;
import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;
@ -31,17 +32,17 @@ public boolean canCraftInDimensions(int x, int y) {
}
@Override
public ItemStack getResultItem() {
public ItemStack getResultItem(RegistryAccess registryAccess) {
return TurtleItemFactory.create(-1, null, -1, ComputerFamily.NORMAL, null, null, 0, null);
}
@Override
public boolean matches(CraftingContainer inventory, Level world) {
return !assemble(inventory).isEmpty();
return !assemble(inventory, world.registryAccess()).isEmpty();
}
@Override
public ItemStack assemble(CraftingContainer inventory) {
public ItemStack assemble(CraftingContainer inventory, RegistryAccess registryAccess) {
// Scan the grid for a row containing a turtle and 1 or 2 items
var leftItem = ItemStack.EMPTY;
var turtle = ItemStack.EMPTY;

View File

@ -74,7 +74,7 @@ public List<ItemStack> doCrafting(Level world, int maxCount) {
var results = new ArrayList<ItemStack>();
for (var i = 0; i < maxCount && recipe.matches(this, world); i++) {
var result = recipe.assemble(this);
var result = recipe.assemble(this, world.registryAccess());
if (result.isEmpty()) break;
results.add(result);

View File

@ -19,7 +19,6 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.TagKey;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.decoration.ArmorStand;
@ -127,7 +126,7 @@ private TurtleCommandResult attack(ITurtleAccess turtle, Direction direction) {
} else if (result == InteractionResult.PASS && hitEntity.isAttackable() && !hitEntity.skipAttackInteraction(player)) {
var damage = (float) player.getAttributeValue(Attributes.ATTACK_DAMAGE) * damageMulitiplier;
if (damage > 0.0f) {
var source = DamageSource.playerAttack(player);
var source = player.damageSources().playerAttack(player);
if (hitEntity instanceof ArmorStand) {
// Special case for armor stands: attack twice to guarantee destroy
hitEntity.hurt(source, damage);

View File

@ -8,6 +8,7 @@
import com.google.gson.JsonObject;
import dan200.computercraft.shared.ModRegistry;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
@ -21,10 +22,12 @@
public final class ImpostorRecipe extends ShapedRecipe {
private final String group;
private final ItemStack result;
private ImpostorRecipe(ResourceLocation id, String group, CraftingBookCategory category, int width, int height, NonNullList<Ingredient> ingredients, ItemStack result) {
super(id, group, category, width, height, ingredients, result);
this.group = group;
this.result = result;
}
@Override
@ -32,13 +35,17 @@ public String getGroup() {
return group;
}
ItemStack getResultItem() {
return result;
}
@Override
public boolean matches(CraftingContainer inv, Level world) {
return false;
}
@Override
public ItemStack assemble(CraftingContainer inventory) {
public ItemStack assemble(CraftingContainer inventory, RegistryAccess registryAccess) {
return ItemStack.EMPTY;
}

View File

@ -10,6 +10,7 @@
import com.google.gson.JsonParseException;
import dan200.computercraft.shared.ModRegistry;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
@ -20,10 +21,12 @@
public final class ImpostorShapelessRecipe extends ShapelessRecipe {
private final String group;
private final ItemStack result;
private ImpostorShapelessRecipe(ResourceLocation id, String group, CraftingBookCategory category, ItemStack result, NonNullList<Ingredient> ingredients) {
super(id, group, category, result, ingredients);
this.group = group;
this.result = result;
}
@Override
@ -31,13 +34,17 @@ public String getGroup() {
return group;
}
ItemStack getResultItem() {
return result;
}
@Override
public boolean matches(CraftingContainer inv, Level world) {
return false;
}
@Override
public ItemStack assemble(CraftingContainer inventory) {
public ItemStack assemble(CraftingContainer inventory, RegistryAccess access) {
return ItemStack.EMPTY;
}

View File

@ -4,11 +4,12 @@ accessWidener v1 named
# that we actually use
accessible method net/minecraft/client/renderer/item/ItemProperties register (Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/item/ClampedItemPropertyFunction;)V
accessible method net/minecraft/client/renderer/blockentity/BlockEntityRenderers register (Lnet/minecraft/world/level/block/entity/BlockEntityType;Lnet/minecraft/client/renderer/blockentity/BlockEntityRendererProvider;)V
accessible class net/minecraft/world/item/CreativeModeTab$Output
# Containers
accessible class net/minecraft/world/inventory/MenuType$MenuSupplier
accessible method net/minecraft/world/inventory/MenuType <init> (Lnet/minecraft/world/inventory/MenuType$MenuSupplier;)V
accessible method net/minecraft/world/inventory/MenuType <init> (Lnet/minecraft/world/inventory/MenuType$MenuSupplier;Lnet/minecraft/world/flag/FeatureFlagSet;)V
accessible class net/minecraft/client/gui/screens/MenuScreens$ScreenConstructor
accessible method net/minecraft/client/gui/screens/MenuScreens register (Lnet/minecraft/world/inventory/MenuType;Lnet/minecraft/client/gui/screens/MenuScreens$ScreenConstructor;)V

View File

@ -1,6 +1,6 @@
{
"pack": {
"pack_format": 9,
"pack_format": 12,
"description": "CC: Tweaked"
}
}

View File

@ -10,6 +10,7 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@ -79,8 +80,9 @@ private static void export(Path root, ImageRenderer renderer) throws IOException
}
// Now find all CC recipes.
for (var recipe : Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(RecipeType.CRAFTING)) {
var result = recipe.getResultItem();
var level = Minecraft.getInstance().level;
for (var recipe : level.getRecipeManager().getAllRecipesFor(RecipeType.CRAFTING)) {
var result = recipe.getResultItem(level.registryAccess());
if (!RegistryWrappers.ITEMS.getKey(result.getItem()).getNamespace().equals(ComputerCraftAPI.MOD_ID)) {
continue;
}
@ -120,13 +122,16 @@ private static void export(Path root, ImageRenderer renderer) throws IOException
if (Files.exists(itemDir)) MoreFiles.deleteRecursively(itemDir, RecursiveDeleteOption.ALLOW_INSECURE);
renderer.setupState();
var transform = new PoseStack();
transform.setIdentity();
for (var item : items) {
var stack = new ItemStack(item);
var location = RegistryWrappers.ITEMS.getKey(item);
dump.itemNames.put(location.toString(), stack.getHoverName().getString());
renderer.captureRender(itemDir.resolve(location.getNamespace()).resolve(location.getPath() + ".png"),
() -> Minecraft.getInstance().getItemRenderer().renderAndDecorateFakeItem(stack, 0, 0)
() -> Minecraft.getInstance().getItemRenderer().renderAndDecorateFakeItem(transform, stack, 0, 0)
);
}
renderer.clearState();

View File

@ -97,7 +97,7 @@ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
var itemEntity = player.drop(item, false);
if (itemEntity != null) {
itemEntity.setNoPickUpDelay();
itemEntity.setOwner(player.getUUID());
itemEntity.setThrower(player.getUUID());
}
}

View File

@ -1,24 +0,0 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.mixin.gametest;
import net.minecraft.SharedConstants;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
// TODO(1.19.4): Remove this
@Mixin(SharedConstants.class)
class SharedConstantsMixin {
/**
* Disable DFU initialisation.
*
* @author SquidDev
* @reason This doesn't have any impact on gameplay, and slightly speeds up tests.
*/
@Overwrite
public static void enableDataFixerOptimizations() {
}
}

View File

@ -39,6 +39,7 @@ class MinecraftMixin implements MinecraftExtensions {
private final AtomicBoolean isStable = new AtomicBoolean(false);
@Inject(method = "runTick", at = @At("TAIL"))
@SuppressWarnings("UnusedMethod")
private void updateStable(boolean render, CallbackInfo ci) {
isStable.set(
level != null && player != null &&

View File

@ -23,6 +23,7 @@ public class WorldOpenFlowsMixin {
* @reason Makes it easier to run tests. We can switch to an @Inject if this becomes a problem.
*/
@Overwrite
@SuppressWarnings("UnusedMethod")
private void askForBackup(Screen screen, String level, boolean customised, Runnable action) {
action.run();
}

View File

@ -40,7 +40,7 @@ fun Craft_result_has_nbt(context: GameTestHelper) = context.sequence {
.getRecipeFor(RecipeType.CRAFTING, container, context.level)
if (!recipe.isPresent) throw GameTestAssertException("No recipe matches")
val result = recipe.get().assemble(container)
val result = recipe.get().assemble(container, context.level.registryAccess())
val owner = CompoundTag()
owner.putString("Name", "dan200")

View File

@ -6,6 +6,7 @@
import net.minecraft.client.CloudStatus
import net.minecraft.client.Minecraft
import net.minecraft.client.ParticleStatus
import net.minecraft.client.gui.screens.AccessibilityOnboardingScreen
import net.minecraft.client.gui.screens.Screen
import net.minecraft.client.gui.screens.TitleScreen
import net.minecraft.client.tutorial.TutorialSteps
@ -49,7 +50,7 @@
@JvmStatic
fun onOpenScreen(screen: Screen): Boolean = when {
enabled && !loadedWorld && screen is TitleScreen -> {
enabled && !loadedWorld && (screen is TitleScreen || screen is AccessibilityOnboardingScreen) -> {
loadedWorld = true
openWorld()
true

View File

@ -11,7 +11,6 @@
"GameTestInfoAccessor",
"GameTestSequenceAccessor",
"GameTestSequenceMixin",
"SharedConstantsMixin",
"TestCommandAccessor"
],
"client": [

View File

@ -1,6 +1,6 @@
{
"pack": {
"pack_format": 7,
"pack_format": 12,
"description": "CC: Test"
}
}

View File

@ -14,7 +14,6 @@
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.fabricmc.fabric.api.event.client.player.ClientPickBlockGatherCallback;
@ -35,7 +34,6 @@ public static void init() {
ClientRegistry.register();
ClientRegistry.registerItemColours(ColorProviderRegistry.ITEM::register);
ClientRegistry.registerBlockEntityRenderers(BlockEntityRendererRegistry::register);
ClientRegistry.registerMainThread();

View File

@ -33,11 +33,11 @@ public CustomBakedModel(BakedModel wrapped) {
@Override
public final void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier<RandomSource> randomSupplier, RenderContext context) {
context.fallbackConsumer().accept(this);
context.bakedModelConsumer().accept(this);
}
@Override
public final void emitItemQuads(ItemStack stack, Supplier<RandomSource> randomSupplier, RenderContext context) {
context.fallbackConsumer().accept(this);
context.bakedModelConsumer().accept(this);
}
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"item": "minecraft:stone"}, "R": {"tag": "c:redstone_dusts"}},
"pattern": [" # ", "#R#", " # "],
"result": {"count": 6, "item": "computercraft:cable"}
"result": {"count": 6, "item": "computercraft:cable"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"tag": "c:gold_ingots"}, "G": {"tag": "c:glass_panes"}, "R": {"tag": "c:redstone_dusts"}},
"pattern": ["###", "#R#", "#G#"],
"result": {"item": "computercraft:computer_advanced"}
"result": {"item": "computercraft:computer_advanced"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"family": "ADVANCED",
"key": {"#": {"tag": "c:gold_ingots"}, "C": {"item": "computercraft:computer_normal"}},
"pattern": ["###", "#C#", "# #"],
"result": {"item": "computercraft:computer_advanced"}
"result": {"item": "computercraft:computer_advanced"},
"show_notification": true
}

View File

@ -7,5 +7,6 @@
"R": {"item": "minecraft:command_block"}
},
"pattern": ["###", "#R#", "#G#"],
"result": {"item": "computercraft:computer_command"}
"result": {"item": "computercraft:computer_command"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"item": "minecraft:stone"}, "G": {"tag": "c:glass_panes"}, "R": {"tag": "c:redstone_dusts"}},
"pattern": ["###", "#R#", "#G#"],
"result": {"item": "computercraft:computer_normal"}
"result": {"item": "computercraft:computer_normal"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"item": "minecraft:stone"}, "R": {"tag": "c:redstone_dusts"}},
"pattern": ["###", "#R#", "#R#"],
"result": {"item": "computercraft:disk_drive"}
"result": {"item": "computercraft:disk_drive"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"tag": "c:gold_ingots"}, "G": {"tag": "c:glass_panes"}},
"pattern": ["###", "#G#", "###"],
"result": {"count": 4, "item": "computercraft:monitor_advanced"}
"result": {"count": 4, "item": "computercraft:monitor_advanced"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"item": "minecraft:stone"}, "G": {"tag": "c:glass_panes"}},
"pattern": ["###", "#G#", "###"],
"result": {"item": "computercraft:monitor_normal"}
"result": {"item": "computercraft:monitor_normal"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:pocket_advanced",
"key": {"#": {"item": "computercraft:speaker"}, "P": {"item": "computercraft:pocket_computer_advanced"}},
"pattern": ["#", "P"],
"result": {"item": "computercraft:pocket_computer_advanced", "nbt": "{Upgrade:\"computercraft:speaker\"}"}
"result": {"item": "computercraft:pocket_computer_advanced", "nbt": "{Upgrade:\"computercraft:speaker\"}"},
"show_notification": true
}

View File

@ -10,5 +10,6 @@
"result": {
"item": "computercraft:pocket_computer_advanced",
"nbt": "{Upgrade:\"computercraft:wireless_modem_advanced\"}"
}
},
"show_notification": true
}

View File

@ -10,5 +10,6 @@
"result": {
"item": "computercraft:pocket_computer_advanced",
"nbt": "{Upgrade:\"computercraft:wireless_modem_normal\"}"
}
},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"tag": "c:gold_ingots"}, "A": {"item": "minecraft:golden_apple"}, "G": {"tag": "c:glass_panes"}},
"pattern": ["###", "#A#", "#G#"],
"result": {"item": "computercraft:pocket_computer_advanced"}
"result": {"item": "computercraft:pocket_computer_advanced"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"family": "ADVANCED",
"key": {"#": {"tag": "c:gold_ingots"}, "C": {"item": "computercraft:pocket_computer_normal"}},
"pattern": ["###", "#C#", "# #"],
"result": {"item": "computercraft:pocket_computer_advanced"}
"result": {"item": "computercraft:pocket_computer_advanced"},
"show_notification": true
}

View File

@ -7,5 +7,6 @@
"G": {"tag": "c:glass_panes"}
},
"pattern": ["###", "#A#", "#G#"],
"result": {"item": "computercraft:pocket_computer_normal"}
"result": {"item": "computercraft:pocket_computer_normal"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:pocket_normal",
"key": {"#": {"item": "computercraft:speaker"}, "P": {"item": "computercraft:pocket_computer_normal"}},
"pattern": ["#", "P"],
"result": {"item": "computercraft:pocket_computer_normal", "nbt": "{Upgrade:\"computercraft:speaker\"}"}
"result": {"item": "computercraft:pocket_computer_normal", "nbt": "{Upgrade:\"computercraft:speaker\"}"},
"show_notification": true
}

View File

@ -10,5 +10,6 @@
"result": {
"item": "computercraft:pocket_computer_normal",
"nbt": "{Upgrade:\"computercraft:wireless_modem_advanced\"}"
}
},
"show_notification": true
}

View File

@ -10,5 +10,6 @@
"result": {
"item": "computercraft:pocket_computer_normal",
"nbt": "{Upgrade:\"computercraft:wireless_modem_normal\"}"
}
},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"item": "minecraft:stone"}, "D": {"tag": "c:dyes"}, "R": {"tag": "c:redstone_dusts"}},
"pattern": ["###", "#R#", "#D#"],
"result": {"item": "computercraft:printer"}
"result": {"item": "computercraft:printer"},
"show_notification": true
}

View File

@ -7,5 +7,6 @@
"R": {"tag": "c:redstone_dusts"}
},
"pattern": ["###", "#N#", "#R#"],
"result": {"item": "computercraft:speaker"}
"result": {"item": "computercraft:speaker"},
"show_notification": true
}

View File

@ -8,5 +8,6 @@
"I": {"tag": "c:wooden_chests"}
},
"pattern": ["###", "#C#", "#I#"],
"result": {"item": "computercraft:turtle_advanced"}
"result": {"item": "computercraft:turtle_advanced"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_advanced",
"key": {"#": {"item": "computercraft:speaker"}, "T": {"item": "computercraft:turtle_advanced"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"computercraft:speaker\"}"}
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"computercraft:speaker\"}"},
"show_notification": true
}

View File

@ -7,5 +7,6 @@
"result": {
"item": "computercraft:turtle_advanced",
"nbt": "{RightUpgrade:\"computercraft:wireless_modem_advanced\"}"
}
},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_advanced",
"key": {"#": {"item": "computercraft:wireless_modem_normal"}, "T": {"item": "computercraft:turtle_advanced"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"computercraft:wireless_modem_normal\"}"}
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"computercraft:wireless_modem_normal\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_advanced",
"key": {"#": {"item": "minecraft:crafting_table"}, "T": {"item": "computercraft:turtle_advanced"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:crafting_table\"}"}
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:crafting_table\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_advanced",
"key": {"#": {"item": "minecraft:diamond_axe"}, "T": {"item": "computercraft:turtle_advanced"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_axe\"}"}
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_axe\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_advanced",
"key": {"#": {"item": "minecraft:diamond_hoe"}, "T": {"item": "computercraft:turtle_advanced"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_hoe\"}"}
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_hoe\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_advanced",
"key": {"#": {"item": "minecraft:diamond_pickaxe"}, "T": {"item": "computercraft:turtle_advanced"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_pickaxe\"}"}
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_pickaxe\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_advanced",
"key": {"#": {"item": "minecraft:diamond_shovel"}, "T": {"item": "computercraft:turtle_advanced"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_shovel\"}"}
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_shovel\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_advanced",
"key": {"#": {"item": "minecraft:diamond_sword"}, "T": {"item": "computercraft:turtle_advanced"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_sword\"}"}
"result": {"item": "computercraft:turtle_advanced", "nbt": "{RightUpgrade:\"minecraft:diamond_sword\"}"},
"show_notification": true
}

View File

@ -8,5 +8,6 @@
"C": {"item": "computercraft:turtle_normal"}
},
"pattern": ["###", "#C#", " B "],
"result": {"item": "computercraft:turtle_advanced"}
"result": {"item": "computercraft:turtle_advanced"},
"show_notification": true
}

View File

@ -8,5 +8,6 @@
"I": {"tag": "c:wooden_chests"}
},
"pattern": ["###", "#C#", "#I#"],
"result": {"item": "computercraft:turtle_normal"}
"result": {"item": "computercraft:turtle_normal"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_normal",
"key": {"#": {"item": "computercraft:speaker"}, "T": {"item": "computercraft:turtle_normal"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"computercraft:speaker\"}"}
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"computercraft:speaker\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_normal",
"key": {"#": {"item": "computercraft:wireless_modem_advanced"}, "T": {"item": "computercraft:turtle_normal"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"computercraft:wireless_modem_advanced\"}"}
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"computercraft:wireless_modem_advanced\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_normal",
"key": {"#": {"item": "computercraft:wireless_modem_normal"}, "T": {"item": "computercraft:turtle_normal"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"computercraft:wireless_modem_normal\"}"}
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"computercraft:wireless_modem_normal\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_normal",
"key": {"#": {"item": "minecraft:crafting_table"}, "T": {"item": "computercraft:turtle_normal"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:crafting_table\"}"}
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:crafting_table\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_normal",
"key": {"#": {"item": "minecraft:diamond_axe"}, "T": {"item": "computercraft:turtle_normal"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_axe\"}"}
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_axe\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_normal",
"key": {"#": {"item": "minecraft:diamond_hoe"}, "T": {"item": "computercraft:turtle_normal"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_hoe\"}"}
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_hoe\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_normal",
"key": {"#": {"item": "minecraft:diamond_pickaxe"}, "T": {"item": "computercraft:turtle_normal"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_pickaxe\"}"}
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_pickaxe\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_normal",
"key": {"#": {"item": "minecraft:diamond_shovel"}, "T": {"item": "computercraft:turtle_normal"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_shovel\"}"}
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_shovel\"}"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:turtle_normal",
"key": {"#": {"item": "minecraft:diamond_sword"}, "T": {"item": "computercraft:turtle_normal"}},
"pattern": ["#T"],
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_sword\"}"}
"result": {"item": "computercraft:turtle_normal", "nbt": "{RightUpgrade:\"minecraft:diamond_sword\"}"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"item": "minecraft:stone"}, "R": {"tag": "c:redstone_dusts"}},
"pattern": ["###", "#R#", "###"],
"result": {"item": "computercraft:wired_modem"}
"result": {"item": "computercraft:wired_modem"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"tag": "c:gold_ingots"}, "E": {"item": "minecraft:ender_eye"}},
"pattern": ["###", "#E#", "###"],
"result": {"item": "computercraft:wireless_modem_advanced"}
"result": {"item": "computercraft:wireless_modem_advanced"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"item": "minecraft:stone"}, "E": {"item": "minecraft:ender_pearl"}},
"pattern": ["###", "#E#", "###"],
"result": {"item": "computercraft:wireless_modem_normal"}
"result": {"item": "computercraft:wireless_modem_normal"},
"show_notification": true
}

View File

@ -21,8 +21,9 @@
*/
@Mixin(TagsProvider.class)
class TagsProviderMixin {
@Inject(at = @At("HEAD"), method = "method_46834", cancellable = true)
public void onVerifyPresent(Predicate<?> predicate, TagEntry tag, CallbackInfoReturnable<Boolean> cir) {
@Inject(at = @At("HEAD"), method = "method_49658", cancellable = true)
@SuppressWarnings("UnusedMethod")
private static void onVerifyPresent(Predicate<?> predicate1, Predicate<?> predicate2, TagEntry tag, CallbackInfoReturnable<Boolean> cir) {
var element = ((TagEntryAccessor) tag).computercraft$elementOrTag();
if (element.tag() && element.id().getNamespace().equals("minecraft")) cir.setReturnValue(false);
}

View File

@ -9,11 +9,8 @@
import dan200.computercraft.core.asm.NamedMethod;
import dan200.computercraft.core.asm.PeripheralMethod;
import dan200.computercraft.shared.peripheral.generic.methods.InventoryMethods;
import net.fabricmc.fabric.api.transfer.v1.item.InventoryStorage;
import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.Container;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
@ -27,18 +24,11 @@
public class GenericPeripheralProvider {
interface Lookup<T> {
@Nullable
T find(Level world, BlockPos pos, @Nullable BlockState state, @Nullable BlockEntity blockEntity, Direction context);
T find(Level world, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, Direction context);
}
private static final List<Lookup<?>> lookups = List.of(
(world, pos, state, blockEntity, context) -> {
// Try to avoid using the sided version of InventoryStorage where possible.
if (blockEntity instanceof Container container && (container = InventoryMethods.extractContainer(container)) != null) {
return InventoryStorage.of(container, null);
}
return ItemStorage.SIDED.find(world, pos, state, blockEntity, context);
}
InventoryMethods::extractContainer
);
@Nullable

View File

@ -18,12 +18,16 @@
import net.fabricmc.fabric.api.transfer.v1.item.InventoryStorage;
import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleSlotStorage;
import net.minecraft.world.Container;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import javax.annotation.Nullable;
import java.util.HashMap;
@ -122,10 +126,21 @@ public static int pullItems(
return moveItem(from, fromSlot - 1, to, toSlot.orElse(0) - 1, actualLimit);
}
public static @Nullable Container extractContainer(Container container) {
return container instanceof ChestBlockEntity chest && chest.getBlockState().getBlock() instanceof ChestBlock chestBlock
? ChestBlock.getContainer(chestBlock, chest.getBlockState(), chest.getLevel(), chest.getBlockPos(), true)
: container;
@SuppressWarnings("NullAway") // FIXME: Doesn't cope with @Nullable type parameter.
public static @Nullable Storage<ItemVariant> extractContainer(Level level, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, @Nullable Direction direction) {
// ItemStorage returns a CombinedStorage rather than an InventoryStorage for double chests.
if (blockEntity instanceof ChestBlockEntity && state.getBlock() instanceof ChestBlock chestBlock) {
var inventory = ChestBlock.getContainer(chestBlock, state, level, pos, true);
return inventory == null ? null : InventoryStorage.of(inventory, null);
}
var internal = ItemStorage.SIDED.find(level, pos, state, blockEntity, null);
if (internal instanceof InventoryStorage || direction == null) return internal;
var external = ItemStorage.SIDED.find(level, pos, state, blockEntity, direction);
if (external instanceof InventoryStorage) return external;
return internal != null ? internal : external;
}
@Nullable
@ -136,12 +151,9 @@ private static InventoryStorage extractHandler(IPeripheral peripheral) {
if (object instanceof BlockEntity blockEntity && blockEntity.isRemoved()) return null;
if (object instanceof InventoryStorage storage) return storage;
if (object instanceof Container container && (container = extractContainer(container)) != null) {
return InventoryStorage.of(container, null);
}
if (object instanceof BlockEntity blockEntity && direction != null) {
var found = ItemStorage.SIDED.find(blockEntity.getLevel(), blockEntity.getBlockPos(), blockEntity.getBlockState(), blockEntity, direction);
if (object instanceof BlockEntity blockEntity) {
var found = extractContainer(blockEntity.getLevel(), blockEntity.getBlockPos(), blockEntity.getBlockState(), blockEntity, direction);
if (found instanceof InventoryStorage storage) return storage;
}

View File

@ -47,6 +47,7 @@
import net.minecraft.server.level.ServerChunkCache;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.Container;
import net.minecraft.world.InteractionHand;
@ -201,7 +202,7 @@ public ContainerTransfer.Slotted wrapContainer(Container container) {
}
@Override
@SuppressWarnings("UnstableApiUsage")
@SuppressWarnings({ "UnstableApiUsage", "NullAway" }) // FIXME: SIDED is treated as nullable by NullAway
public @Nullable ContainerTransfer getContainer(ServerLevel level, BlockPos pos, Direction side) {
var storage = ItemStorage.SIDED.find(level, pos, side);
if (storage != null) return FabricContainerTransfer.of(storage);
@ -289,8 +290,8 @@ public ServerPlayer createFakePlayer(ServerLevel world, GameProfile name) {
@Override
public boolean hasToolUsage(ItemStack stack) {
var item = stack.getItem();
return item instanceof ShovelItem || stack.is(ConventionalItemTags.SHOVELS) ||
item instanceof HoeItem || stack.is(ConventionalItemTags.HOES);
return item instanceof ShovelItem || stack.is(ItemTags.SHOVELS) ||
item instanceof HoeItem || stack.is(ItemTags.HOES);
}
@Override

View File

@ -46,9 +46,9 @@
}
],
"depends": {
"fabricloader": ">=0.14.11",
"fabric-api": ">=0.75.1",
"minecraft": ">=1.19.3 <1.20"
"fabricloader": ">=0.14.17",
"fabric-api": ">=0.75.3",
"minecraft": ">=1.19.4 <1.20"
},
"accessWidener": "computercraft.accesswidener"
}

View File

@ -7,7 +7,6 @@
import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.client.model.turtle.TurtleModelLoader;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelEvent;
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
@ -49,8 +48,6 @@ public static void onItemColours(RegisterColorHandlersEvent.Item event) {
@SubscribeEvent
public static void setupClient(FMLClientSetupEvent event) {
ClientRegistry.register();
ClientRegistry.registerBlockEntityRenderers(BlockEntityRenderers::register);
event.enqueueWork(ClientRegistry::registerMainThread);
}
}

View File

@ -7,8 +7,8 @@
import com.mojang.blaze3d.vertex.PoseStack;
import dan200.computercraft.client.model.TransformedBakedModel;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.model.BakedModelWrapper;
@ -26,8 +26,8 @@ public TurtleModel(BakedModel familyModel, BakedModel colourModel) {
}
@Override
public BakedModel applyTransform(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack, boolean applyLeftHandTransform) {
originalModel.applyTransform(cameraTransformType, poseStack, applyLeftHandTransform);
public BakedModel applyTransform(ItemDisplayContext transform, PoseStack poseStack, boolean applyLeftHandTransform) {
originalModel.applyTransform(transform, poseStack, applyLeftHandTransform);
return this;
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"tag": "forge:stone"}, "R": {"tag": "forge:dusts/redstone"}},
"pattern": [" # ", "#R#", " # "],
"result": {"count": 6, "item": "computercraft:cable"}
"result": {"count": 6, "item": "computercraft:cable"},
"show_notification": true
}

View File

@ -7,5 +7,6 @@
"R": {"tag": "forge:dusts/redstone"}
},
"pattern": ["###", "#R#", "#G#"],
"result": {"item": "computercraft:computer_advanced"}
"result": {"item": "computercraft:computer_advanced"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"family": "ADVANCED",
"key": {"#": {"tag": "forge:ingots/gold"}, "C": {"item": "computercraft:computer_normal"}},
"pattern": ["###", "#C#", "# #"],
"result": {"item": "computercraft:computer_advanced"}
"result": {"item": "computercraft:computer_advanced"},
"show_notification": true
}

View File

@ -7,5 +7,6 @@
"R": {"item": "minecraft:command_block"}
},
"pattern": ["###", "#R#", "#G#"],
"result": {"item": "computercraft:computer_command"}
"result": {"item": "computercraft:computer_command"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"tag": "forge:stone"}, "G": {"tag": "forge:glass_panes"}, "R": {"tag": "forge:dusts/redstone"}},
"pattern": ["###", "#R#", "#G#"],
"result": {"item": "computercraft:computer_normal"}
"result": {"item": "computercraft:computer_normal"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"tag": "forge:stone"}, "R": {"tag": "forge:dusts/redstone"}},
"pattern": ["###", "#R#", "#R#"],
"result": {"item": "computercraft:disk_drive"}
"result": {"item": "computercraft:disk_drive"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"tag": "forge:ingots/gold"}, "G": {"tag": "forge:glass_panes"}},
"pattern": ["###", "#G#", "###"],
"result": {"count": 4, "item": "computercraft:monitor_advanced"}
"result": {"count": 4, "item": "computercraft:monitor_advanced"},
"show_notification": true
}

View File

@ -3,5 +3,6 @@
"category": "redstone",
"key": {"#": {"tag": "forge:stone"}, "G": {"tag": "forge:glass_panes"}},
"pattern": ["###", "#G#", "###"],
"result": {"item": "computercraft:monitor_normal"}
"result": {"item": "computercraft:monitor_normal"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"group": "computercraft:pocket_advanced",
"key": {"#": {"item": "computercraft:speaker"}, "P": {"item": "computercraft:pocket_computer_advanced"}},
"pattern": ["#", "P"],
"result": {"item": "computercraft:pocket_computer_advanced", "nbt": "{Upgrade:\"computercraft:speaker\"}"}
"result": {"item": "computercraft:pocket_computer_advanced", "nbt": "{Upgrade:\"computercraft:speaker\"}"},
"show_notification": true
}

View File

@ -10,5 +10,6 @@
"result": {
"item": "computercraft:pocket_computer_advanced",
"nbt": "{Upgrade:\"computercraft:wireless_modem_advanced\"}"
}
},
"show_notification": true
}

View File

@ -10,5 +10,6 @@
"result": {
"item": "computercraft:pocket_computer_advanced",
"nbt": "{Upgrade:\"computercraft:wireless_modem_normal\"}"
}
},
"show_notification": true
}

View File

@ -7,5 +7,6 @@
"G": {"tag": "forge:glass_panes"}
},
"pattern": ["###", "#A#", "#G#"],
"result": {"item": "computercraft:pocket_computer_advanced"}
"result": {"item": "computercraft:pocket_computer_advanced"},
"show_notification": true
}

View File

@ -4,5 +4,6 @@
"family": "ADVANCED",
"key": {"#": {"tag": "forge:ingots/gold"}, "C": {"item": "computercraft:pocket_computer_normal"}},
"pattern": ["###", "#C#", "# #"],
"result": {"item": "computercraft:pocket_computer_advanced"}
"result": {"item": "computercraft:pocket_computer_advanced"},
"show_notification": true
}

Some files were not shown because too many files have changed in this diff Show More