Skip to content

Commit

Permalink
Total rewrite of the codebase (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alastors authored Nov 10, 2023
1 parent ee84bc4 commit d44f8e3
Show file tree
Hide file tree
Showing 53 changed files with 2,252 additions and 2,912 deletions.
78 changes: 55 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1692122114
//version: 1699290261
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -89,6 +89,23 @@ def out = services.get(StyledTextOutputFactory).create('an-output')
def projectJavaVersion = JavaLanguageVersion.of(8)

boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false
boolean disableCheckstyle = project.hasProperty("disableCheckstyle") ? project.disableCheckstyle.toBoolean() : false

final String CHECKSTYLE_CONFIG = """
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<!-- Use CHECKSTYLE:OFF and CHECKSTYLE:ON comments to suppress checkstyle lints in a block -->
<module name="SuppressionCommentFilter"/>
<module name="AvoidStarImport">
<!-- Allow static wildcard imports for cases like Opcodes and LWJGL classes, these don't get created accidentally by the IDE -->
<property name="allowStaticMemberImports" value="true"/>
</module>
</module>
</module>
"""

checkPropertyExists("modName")
checkPropertyExists("modId")
Expand Down Expand Up @@ -140,6 +157,17 @@ if (!disableSpotless) {
apply from: Blowdryer.file('spotless.gradle')
}

if (!disableCheckstyle) {
apply plugin: 'checkstyle'
tasks.named("checkstylePatchedMc") { enabled = false }
tasks.named("checkstyleMcLauncher") { enabled = false }
tasks.named("checkstyleIdeVirtualMain") { enabled = false }
tasks.named("checkstyleInjectedTags") { enabled = false }
checkstyle {
config = resources.text.fromString(CHECKSTYLE_CONFIG)
}
}

String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String kotlinSourceDir = "src/main/kotlin/"
Expand Down Expand Up @@ -600,15 +628,10 @@ repositories {
}
maven {
name = "ic2"
url = "https://maven.ic2.player.to/"
metadataSources {
mavenPom()
artifact()
url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/")
content {
includeGroup "net.industrial-craft"
}
}
maven {
name = "ic2-mirror"
url = "https://maven2.ic2.player.to/"
metadataSources {
mavenPom()
artifact()
Expand All @@ -623,7 +646,7 @@ repositories {

def mixinProviderGroup = "io.github.legacymoddingmc"
def mixinProviderModule = "unimixins"
def mixinProviderVersion = "0.1.7.1"
def mixinProviderVersion = "0.1.13"
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
ext.mixinProviderSpec = mixinProviderSpec
Expand Down Expand Up @@ -770,23 +793,14 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
}

dependencies {
def lwjgl3ifyVersion = '1.4.0'
def asmVersion = '9.4'
def lwjgl3ifyVersion = '1.5.1'
if (modId != 'lwjgl3ify') {
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
}
if (modId != 'hodgepodge') {
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.26')
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.17')
}

java17PatchDependencies('net.minecraft:launchwrapper:1.17.2') {transitive = false}
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}")
java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}")
java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1')
java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0")
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
}

Expand Down Expand Up @@ -1173,9 +1187,8 @@ publishing {
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
}
}

repositories {
if (usesMavenPublishing.toBoolean()) {
if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) {
maven {
url = mavenPublishUrl
allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
Expand Down Expand Up @@ -1576,6 +1589,25 @@ def getSecondaryArtifacts() {
return secondaryArtifacts
}

def getURL(String main, String fallback) {
return pingURL(main, 10000) ? main : fallback
}

// credit: https://stackoverflow.com/a/3584332
def pingURL(String url, int timeout) {
url = url.replaceFirst("^https", "http") // Otherwise an exception may be thrown on invalid SSL certificates.
try {
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection()
connection.setConnectTimeout(timeout)
connection.setReadTimeout(timeout)
connection.setRequestMethod("HEAD")
int responseCode = connection.getResponseCode()
return 200 <= responseCode && responseCode <= 399
} catch (IOException ignored) {
return false
}
}

// For easier scripting of things that require variables defined earlier in the buildscript
if (file('addon.late.gradle.kts').exists()) {
apply from: 'addon.late.gradle.kts'
Expand Down
3 changes: 2 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ dependencies {
compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compile('com.github.GTNewHorizons:Baubles:1.0.1.16:dev')
compile('com.github.GTNewHorizons:Thaumic_Exploration:1.1.94-GTNH:dev')
compile('com.github.GTNewHorizons:Electro-Magic-Tools:1.3.3:dev')
compile('com.github.GTNewHorizons:Electro-Magic-Tools:1.3.6:dev')
compile('com.github.GTNewHorizons:Tainted-Magic:7.6.3-GTNH')
compile('com.github.GTNewHorizons:GTNHLib:0.0.13')

runtimeOnly('com.github.GTNewHorizons:TCNEIAdditions:1.2.2:dev')
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ usesShadowedDependencies = false

# Optional parameter to prevent the source code from being published
# noPublishedSources =
enableModernJavaSyntax = true
8 changes: 0 additions & 8 deletions repositories.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ repositories {
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
allowInsecureProtocol
}
maven {
name 'ic2'
url 'https://maven.ic2.player.to/'
metadataSources {
mavenPom()
artifact()
}
}
maven {
url 'https://jitpack.io'
}
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/thaumicboots/IGrief.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package thaumicboots;

import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;

import flaxbeard.thaumicexploration.ThaumicExploration;
import flaxbeard.thaumicexploration.common.ConfigTX;
import thaumicboots.main.utils.compat.ExplorationsHelper;

public interface IGrief {

public default void grief(EntityPlayer player) {
// anti-griefing config
if (ExplorationsHelper.isActive()) {
if (!ConfigTX.allowBootsIce) {
return;
}
for (int x = -5; x < 6; x++) {
for (int z = -5; z < 6; z++) {
int X = (int) (player.posX + x);
int Y = (int) (player.posY - 1);
int Z = (int) (player.posZ + z);

// if the block isn't water
if (player.worldObj.getBlock(X, Y, Z) != Blocks.water) {
continue;
}

// if the block hasn't some water properties
if (player.worldObj.getBlock(X, Y, Z).getMaterial() != Material.water) {
continue;
}

// if the metadata of the block isn't 0
if (player.worldObj.getBlockMetadata(X, Y, Z) != 0) {
continue;
}

// if the player is in water
if (player.isInWater()) {
continue;
}

// ???, someone needs to figure out what this does.
if ((Math.abs(x) + Math.abs(z) >= 8)) {
continue;
}

player.worldObj.setBlock(X, Y, Z, ThaumicExploration.meltyIce);
player.worldObj.spawnParticle("snowballpoof", X, Y + 1, Z, 0.0D, 0.025D, 0.0D);
}
}
}
}
}
39 changes: 39 additions & 0 deletions src/main/java/thaumicboots/api/IComet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package thaumicboots.api;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

public interface IComet extends ISpecialEffect, IGrief {

public default void specialEffect(Item item, EntityPlayer player) {
ItemStack itemStack = player.inventory.armorItemInSlot(0);
if (!itemStack.hasTagCompound()) {
NBTTagCompound par1NBTTagCompound = new NBTTagCompound();
itemStack.setTagCompound(par1NBTTagCompound);
itemStack.stackTagCompound.setInteger("runTicks", 0);
}
grief(player);
int ticks = itemStack.stackTagCompound.getInteger("runTicks");
double motion = Math.abs(player.motionX) + Math.abs(player.motionZ) + Math.abs(player.motionY);
if (motion > 0.1F || !player.onGround || player.isOnLadder()) {
if (ticks < 100) ticks++;
} else {
ticks = 0;
}
if (!player.isWet() && motion > 0.1F) {
player.worldObj.spawnParticle(
"fireworksSpark",
player.posX + Math.random() - 0.5F,
player.boundingBox.minY + 0.25F + ((Math.random() - 0.5) * 0.25F),
player.posZ + Math.random() - 0.5F,
0.0D,
0.025D,
0.0D);
}
itemStack.stackTagCompound.setInteger("runTicks", ticks);
return;
}

}
96 changes: 96 additions & 0 deletions src/main/java/thaumicboots/api/ICometMeteorMix.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package thaumicboots.api;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;

public interface ICometMeteorMix extends IMeteor, IComet {

public default void specialEffect(Item item, EntityPlayer player) {
ItemStack itemStack = player.inventory.armorItemInSlot(0);
if (!itemStack.hasTagCompound()) {
NBTTagCompound par1NBTTagCompound = new NBTTagCompound();
itemStack.setTagCompound(par1NBTTagCompound);
itemStack.stackTagCompound.setBoolean("IsSmashingMix", false);
itemStack.stackTagCompound.setInteger("smashTicksMix", 0);
itemStack.stackTagCompound.setInteger("airTicksMix", 0);
itemStack.stackTagCompound.setInteger("runTicksMix", 0);
}
grief(player);

boolean smashing = itemStack.stackTagCompound.getBoolean("IsSmashingMix");
int ticksSmash = itemStack.stackTagCompound.getInteger("smashTicksMix");
int ticksAir = itemStack.stackTagCompound.getInteger("airTicksMix");
int ticksRun = itemStack.stackTagCompound.getInteger("runTicksMix");
double motionRun = Math.abs(player.motionX) + Math.abs(player.motionZ) + Math.abs(player.motionY);
if (motionRun > 0.1F || !player.onGround || player.isOnLadder()) {
if (ticksRun < 100) ticksRun++;
} else {
ticksRun = 0;
}
if (player.onGround || player.isOnLadder()) {
int size = 0;
if (ticksSmash > 5) size = 1;
if (ticksSmash > 10) size = 2;
if (ticksSmash > 15) size = 3;
smashing = false;
ticksSmash = 0;
ticksAir = 0;
if (size > 0) {
player.worldObj.createExplosion(player, player.posX, player.posY, player.posZ, size, false);
}
}

// COME ON AND SLAM
if (!player.onGround && !player.isOnLadder() && !player.isInWater()) {
if (!player.isSneaking()) {
ticksAir++;
}

if (player.isSneaking() && ticksAir > 5) {
smashing = true;
}
}

if (player.capabilities.isFlying) {
smashing = false;
ticksSmash = 0;
ticksAir = 0;
}
if (smashing) {

for (String particleName : new String[] { "flame", "smoke", "flame" }) {
player.worldObj.spawnParticle(
particleName,
player.posX + Math.random() - 0.5F,
player.posY + Math.random() - 0.5F,
player.posZ + Math.random() - 0.5F,
0.0D,
0.0D,
0.0D);
}

player.motionY -= 0.1F;
ticksSmash++;
}

if (!player.isWet() && motionRun > 0.1F) {
for (String particleName : new String[] { "fireworksSpark", "flame", "flame" }) {
player.worldObj.spawnParticle(
particleName,
player.posX + Math.random() - 0.5F,
player.boundingBox.minY + 0.25F + ((Math.random() - 0.5) * 0.25F),
player.posZ + Math.random() - 0.5F,
0.0D,
0.025D,
0.0D);
}
}

itemStack.stackTagCompound.setInteger("runTicksMix", ticksRun);
itemStack.stackTagCompound.setBoolean("IsSmashingMix", smashing);
itemStack.stackTagCompound.setInteger("smashTicksMix", ticksSmash);
itemStack.stackTagCompound.setInteger("airTicksMix", ticksAir);
}
}
Loading

0 comments on commit d44f8e3

Please sign in to comment.