Skip to content

Commit

Permalink
increase biome update notification to everyone in render distance
Browse files Browse the repository at this point in the history
  • Loading branch information
Glease committed Apr 7, 2024
1 parent db2c575 commit e752bba
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 10 deletions.
1 change: 1 addition & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
This project is licensed under GNU Affero General Public License 3.0 with additional exception for use with Minecraft Forge
and in a modpack.
All Sources and its corresponding object code (unless explicitly stated in the source file header) uses this license.

See file LICENSE for a complete text on GNU Affero General Public License 3.0.
See file LICENSE.forge-exception for the detailed exception text.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

A mod that adds a bit of functionality, a bit of performance and a bit of robustness into thaumcraft 4.

## Maven

This project is hosted at https://maven.glease.net/repos/releases/.
Snapshot releases are also available at https://maven.glease.net/repos/snapshots/.

No HTTP browsing at the moment.

## Creating derivation

### License
Expand Down
110 changes: 105 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ buildscript {
}
}

plugins {
id 'maven-publish'
}

apply plugin: 'forge'
apply plugin: 'com.matthewprenger.cursegradle'
apply plugin: 'se.bjurr.gitchangelog.git-changelog-gradle-plugin'
Expand Down Expand Up @@ -61,11 +65,33 @@ repositories {
}
}

configurations {
create("runtimeOnlyNonPublishable") {
description = "Runtime only dependencies that are not published alongside the jar"
canBeConsumed = false
canBeResolved = false
}

create("devOnlyNonPublishable") {
description = "Runtime and compiletime dependencies that are not published alongside the jar (compileOnly + runtimeOnlyNonPublishable)"
canBeConsumed = false
canBeResolved = false
}

compileOnly.extendsFrom(devOnlyNonPublishable)
runtimeOnlyNonPublishable.extendsFrom(devOnlyNonPublishable)

runtimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
testRuntimeClasspath.extendsFrom(runtimeOnlyNonPublishable)

implementation.extendsFrom(apiImplementation)
}

dependencies {
compile "com.azanor.baubles:Baubles:1.7.10-1.0.1.10:deobf"
compile "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev"
devOnlyNonPublishable "com.azanor.baubles:Baubles:1.7.10-1.0.1.10:deobf"
apiImplementation "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev"
devOnlyNonPublishable "com.github.GTNewHorizons:NotEnoughItems:2.3.54-GTNH:dev"
compileOnly "MineTweaker3:MineTweaker3-API:3.0.11.23"
compile "com.github.GTNewHorizons:NotEnoughItems:2.3.54-GTNH:dev"
}

processResources
Expand All @@ -86,9 +112,15 @@ processResources
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}

from(layout.projectDirectory) {
include 'COPYING'
include 'LICENSE*'
}
}

jar {
from sourceSets.api.output
manifest {
attributes "FMLCorePlugin": "net.glease.tc4tweak.asm.LoadingPlugin"
attributes "FMLCorePluginContainsFMLMod": true
Expand All @@ -97,7 +129,12 @@ jar {

task sourceJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
from sourceSets.api.allSource
from(layout.projectDirectory) {
include 'COPYING'
include 'LICENSE*'
}
archiveClassifier = 'sources'
manifest {
attributes "FMLCorePlugin": "net.glease.tc4tweak.asm.LoadingPlugin"
attributes "FMLCorePluginContainsFMLMod": true
Expand All @@ -106,16 +143,24 @@ task sourceJar(type: Jar) {

task devJar(type: Jar) {
from sourceSets.main.output
classifier = 'dev'
from sourceSets.api.output
archiveClassifier = 'dev'
manifest {
attributes "FMLCorePlugin": "net.glease.tc4tweak.asm.LoadingPlugin"
attributes "FMLCorePluginContainsFMLMod": true
}
}

task apiJar(type: Jar) {
from sourceSets.api.output
from sourceSets.api.allSource
archiveClassifier = 'api'
}

artifacts {
archives(devJar)
archives(sourceJar)
archives(apiJar)
}

curseforge {
Expand All @@ -133,6 +178,7 @@ curseforge {
mainArtifact(jar)
addArtifact(devJar)
addArtifact(sourceJar)
addArtifact(apiJar)
}
}

Expand Down Expand Up @@ -186,6 +232,60 @@ task signJar() {
}
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'tc4tweaks'
pom {
name = 'TC4Tweaks'
description = 'A mod that adds a bit of functionality and a bit of performance into thaumcraft 4.'
url = 'https://github.com/Glease/TC4Tweaks/'
licenses {
license {
name = 'GNU Affero General Public License 3.0 with additional exception for use with Minecraft Forge and in a modpack'
url = 'https://github.com/Glease/TC4Tweaks/blob/master/COPYING'
}
}
developers {
developer {
id = 'glee8e'
name = 'glee8e'
}
}
scm {
connection = 'scm:git:https://github.com/Glease/TC4Tweaks.git'
developerConnection = 'scm:git:https://github.com/Glease/TC4Tweaks.git'
url = 'https://github.com/Glease/TC4Tweaks/'
}
}

artifact apiJar
artifact sourceJar
artifact devJar
for (f in tasks.signJar.outputs.files) {
artifact(f) {
builtBy tasks.signJar
}
}

repositories {
maven {
def root = project.hasProperty('mavenRoot') ? project.mavenRoot : 'build/maven'
def releasesRepoUrl = "${root}/repos/releases"
def snapshotsRepoUrl = "${root}/repos/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
if (project.hasProperty('mavenUser') && project.hasProperty('mavenPass')) {
credentials {
username project.mavenUser
password project.mavenPass
}
}
}
}
}
}
}

assemble.dependsOn signJar
tasks.whenTaskAdded { it->
if (it.name.startsWith('curseforge')) {
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/net/glease/tc4tweak/asm/ASMCallhookServer.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package net.glease.tc4tweak.asm;

import java.lang.reflect.Method;
import java.util.Map.Entry;
import java.util.concurrent.ThreadLocalRandom;

import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.glease.tc4tweak.ConfigurationHandler;
import net.glease.tc4tweak.TC4Tweak;
import net.glease.tc4tweak.asm.PacketAspectCombinationToServerVisitor.PacketAspectCombinationToServerAccess;
Expand Down Expand Up @@ -63,6 +65,7 @@

public class ASMCallhookServer {
private static final Marker securityMarker = MarkerManager.getMarker("SuspiciousPackets");
private static Method getRenderDistanceChunks;
private ASMCallhookServer() {
}

Expand Down Expand Up @@ -445,4 +448,21 @@ public static boolean infusionItemMatches(ItemStack playerInput, ItemStack recip
(playerInput.getItemDamage() == recipeSpec.getItemDamage() || recipeSpec.getItemDamage() == 32767) &&
playerInput.stackSize <= playerInput.getMaxStackSize();
}

@Callhook(adder = UtilsVisitor.class, module = ASMConstants.Modules.Bugfix)
public static double getViewDistance(World w) {
int chunks;
try {
if (getRenderDistanceChunks == null) {
// the latest mcp mapping calls it getRenderDistanceChunks,
// but it remains as a srg name in the mapping comes with forge 1614
getRenderDistanceChunks = ReflectionHelper.findMethod(World.class, null, new String[]{"getRenderDistanceChunks", "func_152379_p", "p"});
}
chunks = (Integer) getRenderDistanceChunks.invoke(w);
} catch (ReflectiveOperationException | ReflectionHelper.UnableToFindMethodException ex) {
log.error("error calling World#getRenderDistanceChunks", ex);
chunks = 12;
}
return chunks * 16D;
}
}
28 changes: 24 additions & 4 deletions src/main/java/net/glease/tc4tweak/asm/UtilsVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
if ("generateLoot".equals(name)) {
log.debug("Visiting {}{}", name, desc);
return new GenerateLootVisitor(mv);
return new GenerateLootVisitor(api, mv);
} else if ("setBiomeAt".equals(name)) {
log.debug("Visiting {}{}", name, desc);
return new SetBiomeAtVisitor(api, mv);
}
return mv;
}

private class GenerateLootVisitor extends MethodVisitor {
public GenerateLootVisitor(MethodVisitor mv) {
super(UtilsVisitor.this.api, mv);
private static class GenerateLootVisitor extends MethodVisitor {
public GenerateLootVisitor(int api, MethodVisitor mv) {
super(api, mv);
}

@Override
Expand All @@ -50,4 +53,21 @@ public void visitMethodInsn(int opcode, String owner, String name, String desc,
}
}
}

private static class SetBiomeAtVisitor extends MethodVisitor {
public SetBiomeAtVisitor(int api, MethodVisitor mv) {
super(api, mv);
}

@Override
public void visitLdcInsn(Object cst) {
if (cst instanceof Double && Math.abs((double) cst) - 32D < 0.001D) {
log.trace("Replaced LDC {} with ALOAD_0 + getViewDistance", cst);
super.visitVarInsn(ALOAD, 0);
super.visitMethodInsn(INVOKESTATIC, ASMCALLHOOKSERVER_INTERNAL_NAME, "getViewDistance", "(Lnet/minecraft/world/World;)D", false);
} else {
super.visitLdcInsn(cst);
}
}
}
}
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.21
1.5.22

0 comments on commit e752bba

Please sign in to comment.