Skip to content

Commit 5aaa471

Browse files
committed
Updated to latest forgegradle, incremented minor version, added command base
1 parent ba88607 commit 5aaa471

File tree

5 files changed

+138
-66
lines changed

5 files changed

+138
-66
lines changed

build.gradle

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
buildscript {
22
repositories {
3-
maven { url = 'https://files.minecraftforge.net/maven' }
4-
jcenter()
3+
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
4+
maven { url = 'https://maven.minecraftforge.net' }
55
mavenCentral()
66
}
77
dependencies {
8-
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
8+
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
99
}
1010
}
11-
1211
apply plugin: 'net.minecraftforge.gradle'
13-
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
1412

15-
version = "1.2.1"
16-
group = "com.demmodders.datmoddingapi" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
17-
archivesBaseName = "datmoddingapi"
13+
version = "1.3.0"
14+
group = "com.demmodders" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
1815

19-
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
16+
java {
17+
archivesBaseName = "datmoddingapi"
18+
toolchain.languageVersion = JavaLanguageVersion.of(8)
19+
}
2020

2121
minecraft {
22-
// The mappings can be changed at any time, and must be in the following format.
23-
// snapshot_YYYYMMDD Snapshot are built nightly.
24-
// stable_# Stables are built at the discretion of the MCP team.
25-
// Use non-default mappings at your own risk. they may not always work.
22+
// The mappings can be changed at any time and must be in the following format.
23+
// Channel: Version:
24+
// snapshot YYYYMMDD Snapshot are built nightly.
25+
// stable # Stables are built at the discretion of the MCP team.
26+
// official MCVersion Official field/method names from Mojang mapping files
27+
//
28+
// You must be aware of the Mojang license when using the 'official' mappings.
29+
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
30+
//
31+
// Use non-default mappings at your own risk. They may not always work.
2632
// Simply re-run your setup task after changing the mappings to update your workspace.
2733
mappings channel: 'stable', version: '39-1.12'
28-
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
2934

3035
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
3136

@@ -36,13 +41,19 @@ minecraft {
3641
workingDirectory project.file('run')
3742

3843
// Recommended logging data for a userdev environment
39-
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
44+
// The markers can be added/removed as needed separated by commas.
45+
// "SCAN": For mods scan.
46+
// "REGISTRIES": For firing of registry events.
47+
// "REGISTRYDUMP": For getting the contents of all registries.
48+
property 'forge.logging.markers', 'REGISTRIES'
4049

4150
// Recommended logging level for the console
51+
// You can set various levels here.
52+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
4253
property 'forge.logging.console.level', 'debug'
4354

4455
mods {
45-
datannouncements {
56+
randomspawn2 {
4657
source sourceSets.main
4758
}
4859
}
@@ -52,30 +63,34 @@ minecraft {
5263
workingDirectory project.file('run')
5364

5465
// Recommended logging data for a userdev environment
55-
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
66+
// The markers can be added/removed as needed separated by commas.
67+
// "SCAN": For mods scan.
68+
// "REGISTRIES": For firing of registry events.
69+
// "REGISTRYDUMP": For getting the contents of all registries.
70+
property 'forge.logging.markers', 'REGISTRIES'
5671

5772
// Recommended logging level for the console
73+
// You can set various levels here.
74+
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
5875
property 'forge.logging.console.level', 'debug'
5976

6077
mods {
61-
datannouncements {
78+
randomspawn2 {
6279
source sourceSets.main
6380
}
6481
}
6582
}
6683
}
6784
}
6885

86+
// Include resources generated by data generators.
87+
sourceSets.main.resources { srcDir 'src/generated/resources' }
88+
6989
dependencies {
7090
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
7191
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
7292
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
73-
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2854'
74-
75-
// for more info...
76-
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
77-
// http://www.gradle.org/docs/current/userguide/dependency_management.html
78-
93+
minecraft 'net.minecraftforge:forge:1.12.2-14.23.5.2855'
7994
}
8095

8196
jar.finalizedBy('reobfJar')
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

src/main/java/com/demmodders/datmoddingapi/DatModdingAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class DatModdingAPI
1212
{
1313
public static final String MODID = "datmoddingapi";
1414
public static final String NAME = "Dat Modding API";
15-
public static final String VERSION = "1.2.1";
15+
public static final String VERSION = "1.3.0";
1616
public static final String MC_VERSION = "[1.12.2]";
1717

1818
@Mod.EventHandler
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.demmodders.datmoddingapi.commands;
2+
3+
import com.demmodders.datmoddingapi.util.DemConstants;
4+
import com.demmodders.datmoddingapi.util.Permissions;
5+
import net.minecraft.command.CommandBase;
6+
import net.minecraft.command.ICommandSender;
7+
import net.minecraft.server.MinecraftServer;
8+
import net.minecraft.util.text.ITextComponent;
9+
import net.minecraft.util.text.TextComponentString;
10+
11+
public abstract class DatCommandBase extends CommandBase {
12+
/**
13+
* Sends the given message to the given recipient
14+
* @param recipient The ICommandSender (console, player, etc) receiving the message
15+
* @param message The message being sent to the ICommandSender
16+
*/
17+
protected void sendMessage(ICommandSender recipient, ITextComponent message) {
18+
recipient.sendMessage(message);
19+
}
20+
21+
/**
22+
* Sends an informational message to the given recipient
23+
* @param recipient The ICommandSender (console, player, etc) receiving the message
24+
* @param message The message being sent to the ICommandSender
25+
*/
26+
protected void sendInfo(ICommandSender recipient, String message) {
27+
sendMessage(recipient, new TextComponentString(DemConstants.TextColour.INFO + message));
28+
}
29+
30+
/**
31+
* Sends an error message to the given recipient
32+
* @param recipient The ICommandSender (console, player, etc) receiving the message
33+
* @param message The message being sent to the ICommandSender
34+
*/
35+
protected void sendError(ICommandSender recipient, String message) {
36+
sendMessage(recipient, new TextComponentString(DemConstants.TextColour.ERROR + message));
37+
}
38+
39+
/**
40+
* Gets the permission node for this command
41+
* @return The permission node
42+
*/
43+
protected abstract String getPermissionNode();
44+
45+
@Override
46+
public boolean checkPermission(MinecraftServer server, ICommandSender sender) {
47+
return Permissions.checkPermission(sender, getPermissionNode(), getRequiredPermissionLevel());
48+
}
49+
}
Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,48 @@
1-
package com.demmodders.datmoddingapi.util;
2-
3-
import net.minecraft.util.math.BlockPos;
4-
import net.minecraft.world.World;
5-
import net.minecraftforge.fml.common.FMLCommonHandler;
6-
7-
public class BlockPosUtil {
8-
public static BlockPos findSafeZ(int Dim, BlockPos blockPos, int maxDistance){
9-
BlockPos test = new BlockPos(blockPos);
10-
World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(Dim);
11-
if (world.getBlockState(blockPos).getMaterial().blocksMovement()) {
12-
while (test.getY() < blockPos.getY() + maxDistance){
13-
test = test.up();
14-
if (!world.getBlockState(test).getMaterial().blocksMovement()){
15-
if (!world.getBlockState(test.up()).getMaterial().blocksMovement()){
16-
return test;
17-
} else {
18-
test = test.up();
19-
}
20-
}
21-
}
22-
} else if (!world.getBlockState(blockPos.down()).getMaterial().blocksMovement() && !world.getBlockState(blockPos.down()).getMaterial().isLiquid()){
23-
while (test.getY() > blockPos.getY() - maxDistance){
24-
test = test.down();
25-
if (test.getY() < 0) {
26-
return null;
27-
} else if (!world.getBlockState(test).getMaterial().blocksMovement()){
28-
if (!world.getBlockState(test.down()).getMaterial().blocksMovement()){
29-
return test.up();
30-
} else {
31-
test = test.down();
32-
}
33-
}
34-
}
35-
} else {
36-
return blockPos;
37-
}
38-
return null;
39-
}
40-
}
1+
package com.demmodders.datmoddingapi.util;
2+
3+
import net.minecraft.util.math.BlockPos;
4+
import net.minecraft.world.World;
5+
import net.minecraftforge.fml.common.FMLCommonHandler;
6+
7+
public class BlockPosUtil {
8+
/**
9+
* Finds a safe location along the z axis
10+
* Warning, thuis function isn't very good or well written, I'd avoid it
11+
* @param Dim The dimension the position is in
12+
* @param blockPos The starting position
13+
* @param maxDistance The maximum distance to search
14+
* @return A safe blockpos, or null
15+
*/
16+
public static BlockPos findSafeZ(int Dim, BlockPos blockPos, int maxDistance){
17+
BlockPos test = new BlockPos(blockPos);
18+
World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(Dim);
19+
if (world.getBlockState(blockPos).getMaterial().blocksMovement()) {
20+
while (test.getY() < blockPos.getY() + maxDistance){
21+
test = test.up();
22+
if (!world.getBlockState(test).getMaterial().blocksMovement()){
23+
if (!world.getBlockState(test.up()).getMaterial().blocksMovement()){
24+
return test;
25+
} else {
26+
test = test.up();
27+
}
28+
}
29+
}
30+
} else if (!world.getBlockState(blockPos.down()).getMaterial().blocksMovement() && !world.getBlockState(blockPos.down()).getMaterial().isLiquid()){
31+
while (test.getY() > blockPos.getY() - maxDistance){
32+
test = test.down();
33+
if (test.getY() < 0) {
34+
return null;
35+
} else if (!world.getBlockState(test).getMaterial().blocksMovement()){
36+
if (!world.getBlockState(test.down()).getMaterial().blocksMovement()){
37+
return test.up();
38+
} else {
39+
test = test.down();
40+
}
41+
}
42+
}
43+
} else {
44+
return blockPos;
45+
}
46+
return null;
47+
}
48+
}

0 commit comments

Comments
 (0)