mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-26 19:37:39 +00:00
Update to 1.19.4 (#1376)
This commit is contained in:
@@ -26,6 +26,7 @@ import net.minecraft.client.gui.screens.MenuScreens;
|
||||
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.entity.LivingEntity;
|
||||
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 final class ClientRegistry {
|
||||
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 @@ public final class ClientRegistry {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class ComputerScreen<T extends AbstractComputerMenu> extends Abstra
|
||||
// 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);
|
||||
|
||||
@@ -8,6 +8,7 @@ package dan200.computercraft.client.gui;
|
||||
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 class ItemToast implements Toast {
|
||||
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 class ItemToast implements Toast {
|
||||
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 @@ public class ItemToast implements Toast {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class PrintoutScreen extends AbstractContainerScreen<HeldItemMenu> {
|
||||
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 @@ public class PrintoutScreen extends AbstractContainerScreen<HeldItemMenu> {
|
||||
@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);
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class DynamicImageButton extends Button {
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
|
||||
@@ -245,7 +245,9 @@ public class TerminalWidget extends AbstractWidget {
|
||||
}
|
||||
|
||||
@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 class TerminalWidget extends AbstractWidget {
|
||||
}
|
||||
|
||||
@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());
|
||||
|
||||
@@ -72,9 +72,9 @@ public class ComputerBorderRenderer {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -87,8 +87,9 @@ public class TurtleBlockEntityRenderer implements BlockEntityRenderer<TurtleBloc
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ import net.minecraft.core.BlockPos;
|
||||
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 final class ModRegistry {
|
||||
() -> 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 final class ModRegistry {
|
||||
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());
|
||||
|
||||
@@ -23,9 +23,9 @@ import dan200.computercraft.shared.network.container.ComputerContainerData;
|
||||
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 final class CommandComputerCraft {
|
||||
|
||||
// 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 final class CommandComputerCraft {
|
||||
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,
|
||||
|
||||
@@ -7,6 +7,7 @@ package dan200.computercraft.shared.common;
|
||||
|
||||
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 final class ClearColourRecipe extends CustomRecipe {
|
||||
}
|
||||
|
||||
@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++) {
|
||||
|
||||
@@ -8,6 +8,7 @@ package dan200.computercraft.shared.common;
|
||||
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 final class ColourableRecipe extends CustomRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(CraftingContainer inv) {
|
||||
public ItemStack assemble(CraftingContainer inv, RegistryAccess registryAccess) {
|
||||
var colourable = ItemStack.EMPTY;
|
||||
|
||||
var tracker = new ColourTracker();
|
||||
|
||||
@@ -7,6 +7,7 @@ package dan200.computercraft.shared.computer.recipe;
|
||||
|
||||
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 @@ import net.minecraft.world.level.Level;
|
||||
*/
|
||||
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 abstract class ComputerConvertRecipe extends ShapedRecipe {
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
@@ -11,6 +11,7 @@ import dan200.computercraft.shared.media.items.DiskItem;
|
||||
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 class DiskRecipe extends CustomRecipe {
|
||||
}
|
||||
|
||||
@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 class DiskRecipe extends CustomRecipe {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getResultItem() {
|
||||
public ItemStack getResultItem(RegistryAccess registryAccess) {
|
||||
return DiskItem.createFromIDAndColour(-1, null, Colour.BLUE.getHex());
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package dan200.computercraft.shared.media.recipes;
|
||||
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 final class PrintoutRecipe extends CustomRecipe {
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
@@ -133,7 +133,7 @@ public abstract class SpeakerPeripheral implements IPeripheral {
|
||||
// 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 abstract class SpeakerPeripheral implements IPeripheral {
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import dan200.computercraft.shared.ModRegistry;
|
||||
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 final class PocketComputerUpgradeRecipe extends CustomRecipe {
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
@@ -12,6 +12,7 @@ import dan200.computercraft.shared.ModRegistry;
|
||||
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 final class TurtleUpgradeRecipe extends CustomRecipe {
|
||||
}
|
||||
|
||||
@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;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class TurtleInventoryCrafting extends CraftingContainer {
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ import net.minecraft.resources.ResourceLocation;
|
||||
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 @@ public class TurtleTool extends AbstractTurtleUpgrade {
|
||||
} 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);
|
||||
|
||||
@@ -8,6 +8,7 @@ package dan200.computercraft.shared.util;
|
||||
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 @@ import net.minecraft.world.level.Level;
|
||||
|
||||
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 final class ImpostorRecipe extends ShapedRecipe {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.google.gson.JsonObject;
|
||||
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 @@ import net.minecraft.world.level.Level;
|
||||
|
||||
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 final class ImpostorShapelessRecipe extends ShapelessRecipe {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 9,
|
||||
"pack_format": 12,
|
||||
"description": "CC: Tweaked"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.google.common.io.RecursiveDeleteOption;
|
||||
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 @@ public class Exporter {
|
||||
}
|
||||
|
||||
// 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 @@ public class Exporter {
|
||||
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();
|
||||
|
||||
@@ -97,7 +97,7 @@ class CCTestCommand {
|
||||
var itemEntity = player.drop(item, false);
|
||||
if (itemEntity != null) {
|
||||
itemEntity.setNoPickUpDelay();
|
||||
itemEntity.setOwner(player.getUUID());
|
||||
itemEntity.setThrower(player.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
}
|
||||
@@ -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 &&
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class Recipe_Test {
|
||||
.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")
|
||||
|
||||
@@ -6,6 +6,7 @@ import dan200.computercraft.gametest.api.setupForTest
|
||||
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 @@ object ClientTestHooks {
|
||||
|
||||
@JvmStatic
|
||||
fun onOpenScreen(screen: Screen): Boolean = when {
|
||||
enabled && !loadedWorld && screen is TitleScreen -> {
|
||||
enabled && !loadedWorld && (screen is TitleScreen || screen is AccessibilityOnboardingScreen) -> {
|
||||
loadedWorld = true
|
||||
openWorld()
|
||||
true
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
"GameTestInfoAccessor",
|
||||
"GameTestSequenceAccessor",
|
||||
"GameTestSequenceMixin",
|
||||
"SharedConstantsMixin",
|
||||
"TestCommandAccessor"
|
||||
],
|
||||
"client": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 7,
|
||||
"pack_format": 12,
|
||||
"description": "CC: Test"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user