Skip to content

Commit

Permalink
Initial 1.20.2 work, with MultiLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Dec 4, 2023
1 parent 8c40f9f commit cc05a03
Show file tree
Hide file tree
Showing 79 changed files with 1,365 additions and 589 deletions.
15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* text eol=lf
*.bat text eol=crlf
*.patch text eol=lf
*.java text eol=lf
*.gradle text eol=crlf
*.png binary
*.gif binary
*.exe binary
*.dll binary
*.jar binary
*.lzma binary
*.zip binary
*.pyd binary
*.cfg text eol=lf
*.jks binary
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ out
*.ipr
*.iws
*.iml
.idea
.idea/*
!.idea/scopes

# gradle
build
Expand All @@ -20,5 +21,6 @@ build
# other
eclipse
run
runs
libs
logs
3 changes: 3 additions & 0 deletions .idea/scopes/Fabric_sources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/scopes/Forge_sources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

127 changes: 77 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,69 +1,96 @@
plugins {
id 'idea'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
// Required for NeoGradle
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7"
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

ext.buildnumber=""
if (System.getenv().BUILD_NUMBER) {
ext.buildnumber = ".B" + System.getenv().BUILD_NUMBER
}

version = "${minecraft_version}-${mod_version}${buildnumber}"
group = "dmillerw.ping"

base {
archivesName = "Ping"
}

minecraft {
mappings channel: 'official', version: project.minecraft_version
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

runs {
client {
workingDirectory project.file('run')

mods {
"${mod_id}" {
source sourceSets.main
}
}
subprojects {
apply plugin: 'java'
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.withSourcesJar()

jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${mod_name}" }
}
server {
workingDirectory project.file('run')
manifest {
attributes([
'Specification-Title' : mod_name,
'Specification-Vendor' : mod_author,
'Specification-Version' : project.jar.archiveVersion,
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_author,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Timestamp' : System.currentTimeMillis(),
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Built-On-Minecraft' : minecraft_version
])
}
}

mods {
"${mod_id}" {
source sourceSets.main
}
}
sourcesJar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${mod_name}" }
}
}
}

dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
}
repositories {
mavenCentral()
maven {
name = 'Sponge / Mixin'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'BlameJared Maven (JEI / CraftTweaker / Bookshelf)'
url = 'https://maven.blamejared.com'
}
maven {
name = "Forge Config API Port mod"
url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/"
}
}

def resourceTargets = ['META-INF/mods.toml']
def replaceProperties = [
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
forge_version: forge_version, forge_version_range: forge_version_range,
loader_version_range: loader_version_range,
mod_version: mod_version,
]
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.getRelease().set(17)
}

processResources {
inputs.properties replaceProperties
replaceProperties.put 'project', project
processResources {
def expandProps = [
"version": version,
"group": project.group, //Else we target the task's group.
"minecraft_version": minecraft_version,
"forge_version": forge_version,
"forge_loader_version_range": forge_loader_version_range,
"forge_version_range": forge_version_range,
"minecraft_version_range": minecraft_version_range,
"fabric_version": fabric_version,
"fabric_loader_version": fabric_loader_version,
"mod_name": mod_name,
"mod_author": mod_author,
"mod_id": mod_id,
"license": license,
"description": project.description,
"neoforge_version": neoforge_version,
"neoforge_loader_version_range": neoforge_loader_version_range,
"credits": credits
]

filesMatching(resourceTargets) {
expand replaceProperties
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', '*.mixins.json']) {
expand expandProps
}
inputs.properties(expandProps)
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
// Disables Gradle's custom module metadata from being published to maven. The
// metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers.
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
}
20 changes: 20 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
plugins {
id 'idea'
id 'java'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
}
base {
archivesName = "${mod_name}-common-${minecraft_version}"
}
minecraft {
version(minecraft_version)
if(file("src/main/resources/${mod_id}.accesswidener").exists()){
accessWideners(file("src/main/resources/${mod_id}.accesswidener"))
}
}

dependencies {
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
implementation "fuzs.forgeconfigapiport:forgeconfigapiport-fabric:${forge_config_api_port}"
}
10 changes: 10 additions & 0 deletions common/src/main/java/com/girafi/ping/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.girafi.ping;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class Constants {
public static final String MOD_ID = "ping";
public static final String MOD_NAME = "Ping";
public static final Logger LOG = LogManager.getLogger(MOD_NAME);
}
17 changes: 17 additions & 0 deletions common/src/main/java/com/girafi/ping/PingCommon.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.girafi.ping;

import com.girafi.ping.util.TempConfig;

import java.nio.file.Path;

public class PingCommon {
private static TempConfig config;

public static void setConfigFolder (Path configPath) {
config = TempConfig.load(configPath.resolve(Constants.MOD_ID + ".json").toFile());
}

public static TempConfig config() {
return config;
}
}
32 changes: 32 additions & 0 deletions common/src/main/java/com/girafi/ping/client/ClientHandlerBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.girafi.ping.client;

import com.girafi.ping.data.PingType;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.BlockHitResult;

import javax.annotation.Nullable;
import java.util.Objects;

public class ClientHandlerBase {
public static final ClientHandlerBase INSTANCE = new ClientHandlerBase();

@Nullable
public static ShaderInstance rendertypePing;

public static ShaderInstance getRenderTypePing() {
return Objects.requireNonNull(rendertypePing, "Attempted to call getRenderTypePing before shaders have finished loading.");
}

public static BlockHitResult raytrace(Player player, double distance) {
float eyeHeight = player.getEyeHeight();
return (BlockHitResult) player.pick(distance, eyeHeight, false);
}

public void sendPing(BlockHitResult raytrace, int color, PingType type) {
}

public void sendPing(PingType type) {

}
}

0 comments on commit cc05a03

Please sign in to comment.