Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Update to 1.19.1 (polymer)
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Jul 30, 2022
1 parent 5888c2e commit 1a87c2c
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 149 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.

name: build
on:
pull_request:
push:
paths-ignore: [ '.github/', 'docs/', 'mkdocs.yml' ]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
17 # Latest version
]
# and run on both Linux and Windows
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from LTS java on one OS
uses: actions/upload-artifact@v2
with:
name: Artifacts
path: build/libs/
42 changes: 0 additions & 42 deletions .github/workflows/main-ci.yml

This file was deleted.

10 changes: 4 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/cache@v2
with:
Expand All @@ -20,26 +21,23 @@ jobs:
restore-keys: |
gradle-
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17

- name: Pull submodules
run: git submodule update --init --recursive

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build and publish with Gradle
run: ./gradlew build publish
env:
MAVEN_URL: ${{ secrets.MAVEN_URL }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
CURSEFORGE: ${{ secrets.CURSEFORGE }}
MODRINTH: ${{ secrets.MODRINTH }}
CHANGELOG: ${{ github.event.release.body }}

- name: Upload GitHub release
uses: AButler/[email protected]
with:
Expand Down
89 changes: 10 additions & 79 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
plugins {
id "jacoco"
id "maven-publish"
id "com.github.hierynomus.license" version "0.16.1"
//id "org.jetbrains.kotlin.jvm" version "1.5.21"
id 'fabric-loom' version '0.12-SNAPSHOT'
id "com.modrinth.minotaur" version "2.+"
id 'com.matthewprenger.cursegradle' version '1.4.0'
//id 'com.matthewprenger.cursegradle' version '1.4.0'
}

def javaVersion = JavaLanguageVersion.of(17)
Expand Down Expand Up @@ -77,7 +76,6 @@ repositories {
}

// TODO: Limit these to a set of groups.
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/" }
maven { url = "https://maven.nucleoid.xyz" }
//mavenLocal()
Expand All @@ -86,7 +84,6 @@ repositories {
configurations {
shade
implementation.extendsFrom shade
cctJavadoc
}

dependencies {
Expand Down Expand Up @@ -134,11 +131,9 @@ dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-reflect:1.6.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'

cctJavadoc 'cc.tweaked:cct-javadoc:1.4.5'

modImplementation include("eu.pb4:sgui:1.1.1+1.19")
modImplementation include("eu.pb4:sgui:1.1.3+1.19.1")
modImplementation include("eu.pb4:hologram-api:0.2.2+1.19")
modImplementation include("eu.pb4:polymer:0.2.2+1.19")
modImplementation include("eu.pb4:polymer:0.2.10+1.19.1")
modImplementation include("fr.catcore:server-translations-api:1.4.16+1.19")
modImplementation include("eu.pb4:map-canvas-api:0.1.4+1.19")
}
Expand Down Expand Up @@ -201,23 +196,6 @@ javadoc {
include "dan200/computercraft/api/**/*.java"
}

task luaJavadoc(type: Javadoc) {
description "Generates documentation for Java-side Lua functions."
group "documentation"

source = sourceSets.main.allJava
destinationDir = file("${project.docsDir}/luaJavadoc")
classpath = sourceSets.main.compileClasspath

options.docletpath = configurations.cctJavadoc.files as List
options.doclet = "cc.tweaked.javadoc.LuaDoclet"
options.noTimestamp = false

javadocTool = javaToolchains.javadocToolFor {
languageVersion = javaVersion
}
}

jar {
from "LICENSE"
manifest {
Expand All @@ -233,58 +211,12 @@ jar {
from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
}

[compileJava, compileTestJava].forEach {
it.configure {
options.compilerArgs << "-Xlint" << "-Xlint:-processing"
}
}

sourcesJar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}


import com.hierynomus.gradle.license.tasks.LicenseCheck
import com.hierynomus.gradle.license.tasks.LicenseFormat

license {
mapping("java", "SLASHSTAR_STYLE")
strictCheck true

ext.year = Calendar.getInstance().get(Calendar.YEAR)
}

[licenseMain, licenseFormatMain].forEach {
it.configure {
include("**/*.java")
exclude("dan200/computercraft/api/**")
header file('config/license/main.txt')
}
}

[licenseTest, licenseFormatTest, licenseTestMod, licenseFormatTestMod].forEach {
it.configure {
include("**/*.java")
header file('config/license/main.txt')
}
}

gradle.projectsEvaluated {
tasks.withType(LicenseFormat) {
outputs.upToDateWhen { false }
}
}

task licenseAPI(type: LicenseCheck)
task licenseFormatAPI(type: LicenseFormat)
[licenseAPI, licenseFormatAPI].forEach {
it.configure {
source = sourceSets.main.java
include("dan200/computercraft/api/**")
header file('config/license/api.txt')
}
}

// configure the maven publication
publishing {
publications {
Expand All @@ -304,22 +236,21 @@ if (System.getenv("MODRINTH")) {
modrinth {
token = System.getenv("MODRINTH")

projectId = "eldBwa5V"
versionName = "[" + ((String) project.mc_version) + "] " + version
versionNumber = "" + version + "+" + ((String) project.mc_version)
projectId = "MfXTuV8J"
versionNumber = "" + version // The version of the mod to upload.
versionType = "release"
uploadFile = remapJar
gameVersions = [((String) project.mc_version)]
loaders = ["fabric", "quilt"]
uploadFile = remapJar // This links to a task that builds your mod jar and sets "uploadFile" to the mod jar.
gameVersions = [((String) project.minecraft_version)]
changelog = System.getenv("CHANGELOG")
loaders = ["fabric", "quilt"]
}

remapJar {
finalizedBy project.tasks.modrinth
}
}

if (System.getenv("CURSEFORGE")) {
/*if (System.getenv("CURSEFORGE")) {
curseforge {
apiKey = System.getenv("CURSEFORGE")
Expand Down Expand Up @@ -348,4 +279,4 @@ if (System.getenv("CURSEFORGE")) {
remapJar {
finalizedBy project.tasks.curseforge
}
}
}*/
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import dan200.computercraft.fabric.poly.gui.MapGui;
import eu.pb4.sgui.virtual.VirtualScreenHandlerInterface;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.chat.PlayerChatMessage;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.*;
import net.minecraft.server.MinecraftServer;
Expand All @@ -17,6 +16,8 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Set;

@Mixin(ServerGamePacketListenerImpl.class)
public abstract class ServerGamePacketListenerImplMixin {
@Shadow
Expand All @@ -30,13 +31,14 @@ public abstract class ServerGamePacketListenerImplMixin {
public abstract void send(Packet<?> packet);

@Shadow
public abstract void send(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericFutureListener);
protected abstract PlayerChatMessage getSignedMessage(ServerboundChatPacket serverboundChatPacket);

@Inject(method = "handleChat(Lnet/minecraft/network/protocol/game/ServerboundChatPacket;)V", at = @At("HEAD"), cancellable = true)
private void ccp_onChat(ServerboundChatPacket serverboundChatPacket, CallbackInfo ci) {
if (this.player.containerMenu instanceof VirtualScreenHandlerInterface handler && handler.getGui() instanceof MapGui computerGui) {
this.server.execute(() -> {
computerGui.onChatInput(serverboundChatPacket.getMessage());
computerGui.onChatInput(serverboundChatPacket.message());
this.server.getPlayerList().broadcastMessageHeader(this.getSignedMessage(serverboundChatPacket), Set.of());
});
ci.cancel();
}
Expand Down
32 changes: 14 additions & 18 deletions src/main/java/dan200/computercraft/fabric/poly/gui/ComputerGui.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dan200.computercraft.fabric.poly.gui;

import com.mojang.authlib.GameProfile;
import dan200.computercraft.fabric.poly.ComputerDisplayAccess;
import dan200.computercraft.fabric.poly.Keys;
import dan200.computercraft.fabric.poly.render.*;
Expand All @@ -14,17 +13,17 @@
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
import it.unimi.dsi.fastutil.ints.IntArraySet;
import it.unimi.dsi.fastutil.ints.IntSet;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket;
import net.minecraft.network.protocol.game.ClientboundSetActionBarTextPacket;
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameType;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -34,11 +33,12 @@
import java.util.Map;
import java.util.UUID;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

public final class ComputerGui extends MapGui implements IContainerComputer {

private static final ClientboundPlayerInfoPacket ADDITIONAL_SUGGESTIONS_PACKET;
private static final ClientboundPlayerInfoPacket ADDITIONAL_SUGGESTIONS_REMOVE_PACKET;
private static final Packet<ClientGamePacketListener> ADDITIONAL_SUGGESTIONS_PACKET;
private static final Packet<ClientGamePacketListener> ADDITIONAL_SUGGESTIONS_REMOVE_PACKET;

private static final Map<String, BiConsumer<ComputerGui, String>> ACTIONS = new HashMap<>();

Expand Down Expand Up @@ -69,7 +69,7 @@ public final class ComputerGui extends MapGui implements IContainerComputer {
if (arg != null && !arg.isEmpty()) {
char character = arg.charAt(0);

var args = arg.length() == 1 ? new String[]{ arg } : arg.split(" ", 2);
var args = arg.length() == 1 ? new String[]{arg} : arg.split(" ", 2);

try {
if (args[0].length() > 1) {
Expand Down Expand Up @@ -103,18 +103,14 @@ public final class ComputerGui extends MapGui implements IContainerComputer {
});


ADDITIONAL_SUGGESTIONS_PACKET = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER);
ADDITIONAL_SUGGESTIONS_REMOVE_PACKET = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER);
var list = ACTIONS.keySet().stream().map(x -> ";" + x).collect(Collectors.toList());

int i = 0;
for (var s : ACTIONS.keySet()) {
var entry = new ClientboundPlayerInfoPacket.PlayerUpdate(
new GameProfile(new UUID(0x54345345634l, i++), ";" + s), 999, GameType.SPECTATOR,
Component.literal(";" + s).withStyle(ChatFormatting.DARK_RED), null
);
ADDITIONAL_SUGGESTIONS_PACKET.getEntries().add(entry);
ADDITIONAL_SUGGESTIONS_REMOVE_PACKET.getEntries().add(entry);
}
ADDITIONAL_SUGGESTIONS_PACKET = new ClientboundCustomChatCompletionsPacket(
ClientboundCustomChatCompletionsPacket.Action.ADD, list
);
ADDITIONAL_SUGGESTIONS_REMOVE_PACKET = new ClientboundCustomChatCompletionsPacket(
ClientboundCustomChatCompletionsPacket.Action.REMOVE, list
);
}

public final ComputerDisplayAccess computer;
Expand Down
Loading

0 comments on commit 1a87c2c

Please sign in to comment.