Skip to content

Commit

Permalink
Merge pull request #21 from gnembon/staging
Browse files Browse the repository at this point in the history
view distance and gradle changes
  • Loading branch information
gnembon authored Aug 3, 2018
2 parents 24deada + 2dfe305 commit 9a155d1
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.patch -text
/jsons/*.json -text
52 changes: 44 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import net.minecraftforge.gradle.patcher.PatcherConstants
import net.minecraftforge.gradle.patcher.TaskReobfuscate
import net.minecraftforge.gradle.patcher.TaskSubprojectCall
import net.minecraftforge.gradle.util.json.version.OS
import org.apache.commons.io.FileUtils
import org.apache.commons.io.IOUtils


Expand Down Expand Up @@ -114,6 +115,20 @@ task('setup' + capitalizedName) {
task('createRelease')
project.afterEvaluate { createRelease.dependsOn tasks.getByName(project.name + 'OutputJar') }

gradle.taskGraph.whenReady
{ graph ->
if (graph.hasTask(':copyCodeToSrc'))
warnOverwrite()
}

void warnOverwrite()
{
ant.input(message: 'WARNING: this will overwrite your working changes. Continue? (y/n)', addproperty: 'answer', defaultValue: 'y')
def answer = ant.properties.answer.toLowerCase()
if (answer != 'y' && answer != 'yes')
throw new Exception('User canceled execution')
}


// ===== MODIFY EXISTING TASKS =====

Expand Down Expand Up @@ -275,7 +290,7 @@ outputJar.destinationDir = file('build/localCache/outputTrash')

// ===== MAKE ALL SOURCES IN SAME DIRECTORY =====

task('copy' + capitalizedName + 'FromSrc', type: Copy) {
task('copy' + capitalizedName + 'FromSrc', type: Sync) {
from('src/')
{
eachFile
Expand All @@ -288,7 +303,7 @@ task('copy' + capitalizedName + 'FromSrc', type: Copy) {
includeEmptyDirs = false
dependsOn extractCleanSources
}
task(copyMcFromSrc, type: Copy) {
task(copyMcFromSrc, type: Sync) {
from('src/')
{
include 'mcp/**'
Expand All @@ -306,25 +321,22 @@ task(copyMcFromSrc, type: Copy) {
includeEmptyDirs = false
dependsOn extractCleanSources
}
task('copy' + capitalizedName + 'ToSrc', type: Copy) {
task('copyCodeToSrc', type: Sync) {
from project.name + 'Src/'
into 'src/'
}
task(copyMcToSrc, type: Copy) {
from "projects/${capitalizedName}/src/main/java"
into 'src/'
dependsOn tasks.getByName('extract' + capitalizedName + 'Sources')
includeEmptyDirs = false
}
task(copyResources, type: Copy) {
task(copyResources, type: Sync) {
from "projects/${capitalizedName}/src/main/resources"
into 'resources/'
dependsOn tasks.getByName('extract' + capitalizedName + 'Resources')
includeEmptyDirs = false
}

tasks.getByName('makeJar' + capitalizedName).dependsOn tasks.getByName('copy' + capitalizedName + 'FromSrc'), copyMcFromSrc
genIdeProjects.dependsOn tasks.getByName('copy' + capitalizedName + 'ToSrc'), copyMcToSrc, copyResources
genIdeProjects.dependsOn copyCodeToSrc, copyResources

clean {
delete 'src'
Expand Down Expand Up @@ -358,6 +370,30 @@ if (gradle.useJavadocs)
project.afterEvaluate { tasks.getByName('gen' + capitalizedName + 'Patches').dependsOn stripJavadoc }
}

task(deleteUnnecessaryPatches) << {
fileTree('patches/').visit
{ file ->
def fileName = file.getPath()
if (fileName.endsWith('.patch'))
{
fileName = fileName.substring(0, fileName.length() - 6)
if (FileUtils.contentEquals(project.file('src/' + fileName), project.file('projects/Clean/src/main/java/' + fileName)))
{
delete file.getFile()
}
}
}
}
deleteUnnecessaryPatches.dependsOn extractCleanSources
afterEvaluate {
tasks.getByName('gen' + capitalizedName + 'Patches').dependsOn.each { deleteUnnecessaryPatches.dependsOn it }
tasks.each
{ task ->
if (task.dependsOn.contains(tasks.getByName('gen' + capitalizedName + 'Patches')))
task.dependsOn deleteUnnecessaryPatches
}
}


// ===== REMOVE UNNECESSARY TASKS =====

Expand Down
13 changes: 13 additions & 0 deletions carpetmodSrc/carpet/CarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import carpet.carpetclient.CarpetClientRuleChanger;
import carpet.utils.TickingArea;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
Expand Down Expand Up @@ -253,6 +254,9 @@ private static void set_defaults()
.extraInfo("Turning nether RNG manipulation on or off."),
rule("endRNG", "creative", "Turning end RNG manipulation on or off.")
.extraInfo("Turning end RNG manipulation on or off."),
rule("viewDistance", "creative", "Changes the view distance of the server.")
.extraInfo("Set to 0 to not override the value in server settings.")
.choices("0", "12 16 32 64").setNotStrict(),
rule("tickingAreas", "creative", "Enable use of ticking areas.")
.extraInfo("As set by the /tickingarea comamnd.",
"Ticking areas work as if they are the spawn chunks."),
Expand Down Expand Up @@ -385,6 +389,15 @@ else if("shulkerSpawningInEndCities".equalsIgnoreCase(rule))
shulkerSpawningInEndCities = false;
}
}
else if ("viewDistance".equalsIgnoreCase(rule))
{
int viewDistance = getInt("viewDistance");
if (viewDistance < 2)
viewDistance = ((DedicatedServer) CarpetServer.minecraft_server).getIntProperty("view-distance", 10);
if (viewDistance > 64)
viewDistance = 64;
if (viewDistance != CarpetServer.minecraft_server.getPlayerList().getViewDistance())
CarpetServer.minecraft_server.getPlayerList().setViewDistance(viewDistance);
else if ("tickingAreas".equalsIgnoreCase(rule))
{
if (CarpetSettings.getBool("tickingAreas") && CarpetServer.minecraft_server.worlds != null)
Expand Down

0 comments on commit 9a155d1

Please sign in to comment.