First work to 1.14
Updated core mod file following examples from McJty's example 1.14 mod
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -20,4 +20,9 @@ build
|
||||
# other
|
||||
eclipse
|
||||
run
|
||||
libs
|
||||
libs
|
||||
|
||||
# Files from Forge MDK
|
||||
forge*changelog.txt
|
||||
|
||||
# Example Mod
|
159
build.gradle
159
build.gradle
@@ -1,72 +1,131 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
maven { url = 'https://files.minecraftforge.net/maven' }
|
||||
jcenter()
|
||||
maven { url = "http://files.minecraftforge.net/maven" }
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
||||
}
|
||||
}
|
||||
apply plugin: 'net.minecraftforge.gradle.forge'
|
||||
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.0'
|
||||
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'modid'
|
||||
|
||||
version = "1.0"
|
||||
group = "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "modid"
|
||||
|
||||
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
||||
compileJava {
|
||||
sourceCompatibility = targetCompatibility = '1.8'
|
||||
}
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
||||
|
||||
minecraft {
|
||||
version = "1.12.2-14.23.4.2705"
|
||||
runDir = "run"
|
||||
|
||||
// the mappings can be changed at any time, and must be in the following format.
|
||||
// snapshot_YYYYMMDD snapshot are built nightly.
|
||||
// stable_# stables are built at the discretion of the MCP team.
|
||||
// The mappings can be changed at any time, and must be in the following format.
|
||||
// snapshot_YYYYMMDD Snapshot are built nightly.
|
||||
// stable_# Stables are built at the discretion of the MCP team.
|
||||
// Use non-default mappings at your own risk. they may not always work.
|
||||
// simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings = "snapshot_20171003"
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: 'snapshot', version: '20190608-1.14.2'
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
// accessTransformer = file('build/resources/main/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
mods {
|
||||
examplemod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
mods {
|
||||
examplemod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// you may put jars on which you depend on in ./libs
|
||||
// or you may define them like so..
|
||||
//compile "some.group:artifact:version:classifier"
|
||||
//compile "some.group:artifact:version"
|
||||
// real examples
|
||||
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
||||
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
||||
// the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
|
||||
//provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
// the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
|
||||
// except that these dependencies get remapped to your current MCP mappings
|
||||
//deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
//deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
// for more info...
|
||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
||||
minecraft 'net.minecraftforge:forge:1.14.2-26.0.43'
|
||||
|
||||
// You may put jars on which you depend on in ./libs or you may define them like so..
|
||||
// compile "some.group:artifact:version:classifier"
|
||||
// compile "some.group:artifact:version"
|
||||
|
||||
// Real examples
|
||||
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
||||
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
||||
|
||||
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
|
||||
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
|
||||
// These dependencies get remapped to your current MCP mappings
|
||||
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
|
||||
|
||||
// For more info...
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
|
||||
}
|
||||
|
||||
processResources {
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace version and mcversion
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
}
|
||||
|
||||
// copy everything else except the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
// Example for how to get properties into the manifest for reading by the runtime..
|
||||
jar {
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title": "examplemod",
|
||||
"Specification-Vendor": "examplemodsareus",
|
||||
"Specification-Version": "1", // We are version 1 of ourselves
|
||||
"Implementation-Title": project.name,
|
||||
"Implementation-Version": "${version}",
|
||||
"Implementation-Vendor" :"examplemodsareus",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
// Example configuration to allow publishing using the maven-publish task
|
||||
// we define a custom artifact that is sourced from the reobfJar output task
|
||||
// and then declare that to be published
|
||||
// Note you'll need to add a repository here
|
||||
def reobfFile = file("$buildDir/reobfJar/output.jar")
|
||||
def reobfArtifact = artifacts.add('default', reobfFile) {
|
||||
type 'jar'
|
||||
builtBy 'reobfJar'
|
||||
}
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifact reobfArtifact
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url "file:///${project.projectDir}/mcmodsrepo"
|
||||
}
|
||||
}
|
||||
}
|
4
gradle.properties
Normal file
4
gradle.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,5 @@
|
||||
#Mon Sep 14 12:28:28 PDT 2015
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
|
||||
|
110
gradlew
vendored
110
gradlew
vendored
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
@@ -6,47 +6,6 @@
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
@@ -61,9 +20,49 @@ while [ -h "$PRG" ] ; do
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >&-
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
@@ -90,7 +89,7 @@ location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
@@ -114,6 +113,7 @@ fi
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
@@ -154,11 +154,19 @@ if $cygwin ; then
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
14
gradlew.bat
vendored
14
gradlew.bat
vendored
@@ -8,14 +8,14 @@
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
@@ -46,10 +46,9 @@ echo location of your Java installation.
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windowz variants
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
@@ -60,11 +59,6 @@ set _SKIP=2
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
8
local.properties
Normal file
8
local.properties
Normal file
@@ -0,0 +1,8 @@
|
||||
## This file must *NOT* be checked into Version Control Systems,
|
||||
# as it contains information specific to your local configuration.
|
||||
#
|
||||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
#Sat Jun 22 00:35:58 CDT 2019
|
||||
sdk.dir=C\:\\Users\\Brenten\\AppData\\Local\\Android\\Sdk
|
84
src/main/java/com/example/examplemod/ExampleMod.java
Normal file
84
src/main/java/com/example/examplemod/ExampleMod.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.example.examplemod;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.InterModComms;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// The value here should match an entry in the META-INF/mods.toml file
|
||||
@Mod("examplemod")
|
||||
public class ExampleMod
|
||||
{
|
||||
// Directly reference a log4j logger.
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
public ExampleMod() {
|
||||
// Register the setup method for modloading
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||
// Register the enqueueIMC method for modloading
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
|
||||
// Register the processIMC method for modloading
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
|
||||
// Register the doClientStuff method for modloading
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
|
||||
|
||||
// Register ourselves for server and other game events we are interested in
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
private void setup(final FMLCommonSetupEvent event)
|
||||
{
|
||||
// some preinit code
|
||||
LOGGER.info("HELLO FROM PREINIT");
|
||||
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
|
||||
}
|
||||
|
||||
private void doClientStuff(final FMLClientSetupEvent event) {
|
||||
// do something that can only be done on the client
|
||||
LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
|
||||
}
|
||||
|
||||
private void enqueueIMC(final InterModEnqueueEvent event)
|
||||
{
|
||||
// some example code to dispatch IMC to another mod
|
||||
InterModComms.sendTo("examplemod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
|
||||
}
|
||||
|
||||
private void processIMC(final InterModProcessEvent event)
|
||||
{
|
||||
// some example code to receive and process InterModComms from other mods
|
||||
LOGGER.info("Got IMC {}", event.getIMCStream().
|
||||
map(m->m.getMessageSupplier().get()).
|
||||
collect(Collectors.toList()));
|
||||
}
|
||||
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
||||
@SubscribeEvent
|
||||
public void onServerStarting(FMLServerStartingEvent event) {
|
||||
// do something when the server starts
|
||||
LOGGER.info("HELLO from server starting");
|
||||
}
|
||||
|
||||
// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
|
||||
// Event bus for receiving Registry Events)
|
||||
@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class RegistryEvents {
|
||||
@SubscribeEvent
|
||||
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
|
||||
// register a new block here
|
||||
LOGGER.info("HELLO from Register Block");
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,7 +12,8 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.yseven.findyourway.CommonProxy;
|
||||
import net.yseven.findyourway.setup.ClientProxy;
|
||||
import net.yseven.findyourway.setup.ServerProxy;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -97,9 +98,9 @@ public class AngleGetter implements IItemPropertyGetter {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void setBlockPos(ItemStack stack) {
|
||||
for (int i = 0; i < CommonProxy.compassList.size(); i++) {
|
||||
if (stack.getItem().getUnlocalizedName().equals(CommonProxy.compassList.get(i).getUnlocalizedName())) {
|
||||
blockPos = CommonProxy.compassList.get(i).getStructurePos();
|
||||
for (int i = 0; i < ServerProxy.compassList.size(); i++) {
|
||||
if (stack.getItem().getUnlocalizedName().equals(ServerProxy.compassList.get(i).getUnlocalizedName())) {
|
||||
blockPos = ServerProxy.compassList.get(i).getStructurePos();
|
||||
} else {
|
||||
if (!ClientProxy.hasAngleErrrored()) {
|
||||
System.out.println("unable to get blockPos from compassList in AngleGetter class");
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.yseven.findyourway;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.yseven.findyourway.setup.ServerProxy;
|
||||
|
||||
public class Config {
|
||||
private static final String CATEGORY_GENERAL = "ggeneral";
|
||||
@@ -12,7 +13,7 @@ public class Config {
|
||||
public static boolean useVillageCompass = true;
|
||||
|
||||
public static void readConfig() {
|
||||
Configuration cfg = CommonProxy.config;
|
||||
Configuration cfg = ServerProxy.config;
|
||||
try {
|
||||
cfg.load();
|
||||
initGeneralConfig(cfg);
|
||||
|
@@ -1,37 +1,43 @@
|
||||
package net.yseven.findyourway;
|
||||
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.yseven.findyourway.setup.ClientProxy;
|
||||
import net.yseven.findyourway.setup.IProxy;
|
||||
import net.yseven.findyourway.setup.ModSetup;
|
||||
import net.yseven.findyourway.setup.ServerProxy;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@Mod(modid = FindYourWay.modId, name = FindYourWay.name, version = FindYourWay.version)
|
||||
@Mod("findyourway")
|
||||
public class FindYourWay {
|
||||
public static final String modId = "findyourway";
|
||||
public static final String name = "Find Your Way";
|
||||
public static final String version = "1.2.1";
|
||||
//TODO Fix the ServerProxy and ClientProxy and add both to the setup package
|
||||
public static IProxy proxy = DistExecutor.runForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy())
|
||||
|
||||
@Mod.Instance(modId)
|
||||
public static FindYourWay instance;
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@SidedProxy(serverSide = "net.yseven.findyourway.CommonProxy", clientSide = "net.yseven.findyourway.Client.ClientProxy")
|
||||
public static CommonProxy proxy;
|
||||
public static ModSetup setup = new ModSetup();
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
proxy.preInit(event);
|
||||
public FindYourWay() {
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
proxy.init(event);
|
||||
private void setup(final FMLCommonSetupEvent event) {
|
||||
setup.init();
|
||||
proxy.init();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
proxy.postInit(event);
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class RegistryEvents {
|
||||
@SubscribeEvent
|
||||
public static void onItemsRegistry(final RegistryEvent.Register<Item> event) {
|
||||
Item.Properties properties = new Item.Properties().group(setup.itemGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.yseven.findyourway.CommonProxy;
|
||||
import net.yseven.findyourway.setup.ServerProxy;
|
||||
|
||||
public class MessageHandlerOnServer implements IMessageHandler<MessageToServer, IMessage> {
|
||||
public IMessage onMessage(final MessageToServer message, MessageContext ctx) {
|
||||
@@ -43,7 +43,7 @@ public class MessageHandlerOnServer implements IMessageHandler<MessageToServer,
|
||||
|
||||
MessageToClient msg = new MessageToClient(structurePos, message.getCompass());
|
||||
if (dimension == sendingPlayer.dimension) {
|
||||
CommonProxy.simpleNetworkWrapper.sendTo(msg, sendingPlayer);
|
||||
ServerProxy.simpleNetworkWrapper.sendTo(msg, sendingPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,14 +12,13 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.yseven.findyourway.Client.AngleGetter;
|
||||
import net.yseven.findyourway.Client.ClientProxy;
|
||||
import net.yseven.findyourway.CommonProxy;
|
||||
import net.yseven.findyourway.setup.ClientProxy;
|
||||
import net.yseven.findyourway.setup.ServerProxy;
|
||||
import net.yseven.findyourway.FindYourWay;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -36,8 +35,8 @@ public class ItemCompassBase extends Item {
|
||||
structureType = structureName;
|
||||
setCreativeTab(CreativeTabs.TOOLS);
|
||||
setMaxStackSize(1);
|
||||
CommonProxy.compassList.add(this);
|
||||
ItemCompassID = CommonProxy.compassList.indexOf(this);
|
||||
ServerProxy.compassList.add(this);
|
||||
ItemCompassID = ServerProxy.compassList.indexOf(this);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@@ -74,15 +73,15 @@ public class ItemCompassBase extends Item {
|
||||
//netcode implementation
|
||||
|
||||
public void toBytes(ByteBuf buf) {
|
||||
if(CommonProxy.compassList.contains(this)) {
|
||||
if(ServerProxy.compassList.contains(this)) {
|
||||
buf.writeInt(ItemCompassID);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemCompassBase fromBytes(ByteBuf buf) {
|
||||
int ID = buf.readInt();
|
||||
for(int i = 0; i <= CommonProxy.compassList.size(); i++) {
|
||||
if(ID == CommonProxy.compassList.get(i).getCompassID()) return CommonProxy.compassList.get(i);
|
||||
for(int i = 0; i <= ServerProxy.compassList.size(); i++) {
|
||||
if(ID == ServerProxy.compassList.get(i).getCompassID()) return ServerProxy.compassList.get(i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@@ -1,12 +1,10 @@
|
||||
package net.yseven.findyourway.Client;
|
||||
package net.yseven.findyourway.setup;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -16,8 +14,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.yseven.findyourway.CommonProxy;
|
||||
import net.yseven.findyourway.FindYourWay;
|
||||
import net.yseven.findyourway.setup.ServerProxy;
|
||||
import net.yseven.findyourway.Network.MessageHandlerOnClient;
|
||||
import net.yseven.findyourway.Network.MessageToClient;
|
||||
import net.yseven.findyourway.Network.MessageToServer;
|
||||
@@ -25,7 +22,7 @@ import net.yseven.findyourway.item.ItemCompassBase;
|
||||
import net.yseven.findyourway.item.ModItems;
|
||||
|
||||
@Mod.EventBusSubscriber(Side.CLIENT)
|
||||
public class ClientProxy extends CommonProxy {
|
||||
public class ClientProxy extends ServerProxy {
|
||||
|
||||
//Get information about the player and world
|
||||
public static Minecraft getMinecraft() {
|
||||
@@ -48,13 +45,13 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
|
||||
public static boolean hasCompass(ItemCompassBase compass) {
|
||||
return getPlayer() != null && CommonProxy.containsCompass(getPlayer().inventory, compass);
|
||||
return getPlayer() != null && ServerProxy.containsCompass(getPlayer().inventory, compass);
|
||||
}
|
||||
|
||||
public static void resetStructurePos(ItemCompassBase compass) {
|
||||
compass.setStructurePos(null);
|
||||
compass.setStructureWorld(getWorld());
|
||||
CommonProxy.simpleNetworkWrapper.sendToServer(new MessageToServer(compass));
|
||||
ServerProxy.simpleNetworkWrapper.sendToServer(new MessageToServer(compass));
|
||||
}
|
||||
|
||||
//Proxy Info
|
||||
@@ -62,7 +59,7 @@ public class ClientProxy extends CommonProxy {
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
super.preInit(event);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
CommonProxy.simpleNetworkWrapper.registerMessage(MessageHandlerOnClient.class, MessageToClient.class, CommonProxy.MESSAGE_TO_CLIENT_ID, Side.CLIENT);
|
||||
ServerProxy.simpleNetworkWrapper.registerMessage(MessageHandlerOnClient.class, MessageToClient.class, ServerProxy.MESSAGE_TO_CLIENT_ID, Side.CLIENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,10 +79,10 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClientTick(TickEvent.ClientTickEvent event) {
|
||||
for(int i = 0; i < CommonProxy.compassList.size(); i++) {
|
||||
if(hasCompass(CommonProxy.compassList.get(i))) {
|
||||
if(getWorld() != CommonProxy.compassList.get(i).getStructureWorld()) {
|
||||
resetStructurePos(CommonProxy.compassList.get(i));
|
||||
for(int i = 0; i < ServerProxy.compassList.size(); i++) {
|
||||
if(hasCompass(ServerProxy.compassList.get(i))) {
|
||||
if(getWorld() != ServerProxy.compassList.get(i).getStructureWorld()) {
|
||||
resetStructurePos(ServerProxy.compassList.get(i));
|
||||
}
|
||||
}
|
||||
}
|
9
src/main/java/net/yseven/findyourway/setup/IProxy.java
Normal file
9
src/main/java/net/yseven/findyourway/setup/IProxy.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package net.yseven.findyourway.setup;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IProxy {
|
||||
void init();
|
||||
|
||||
World getClientWorld();
|
||||
}
|
18
src/main/java/net/yseven/findyourway/setup/ModSetup.java
Normal file
18
src/main/java/net/yseven/findyourway/setup/ModSetup.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package net.yseven.findyourway.setup;
|
||||
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.yseven.findyourway.item.ModItems;
|
||||
|
||||
public class ModSetup {
|
||||
public ItemGroup itemGroup = new ItemGroup("findyourway") {
|
||||
@java.lang.Override
|
||||
public ItemStack createIcon() {
|
||||
return new ItemStack(ModItems.ENDER_COMPASS);
|
||||
}
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package net.yseven.findyourway;
|
||||
package net.yseven.findyourway.setup;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -13,6 +13,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.yseven.findyourway.Config;
|
||||
import net.yseven.findyourway.FindYourWay;
|
||||
import net.yseven.findyourway.Network.MessageHandlerOnServer;
|
||||
import net.yseven.findyourway.Network.MessageHandlerOnServerDummy;
|
||||
import net.yseven.findyourway.Network.MessageToClient;
|
||||
@@ -24,7 +26,7 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class CommonProxy {
|
||||
public class ServerProxy {
|
||||
|
||||
public static ArrayList<ItemCompassBase> compassList = new ArrayList<ItemCompassBase>();
|
||||
public static SimpleNetworkWrapper simpleNetworkWrapper;
|
56
src/main/resources/META-INF/mods.toml
Normal file
56
src/main/resources/META-INF/mods.toml
Normal file
@@ -0,0 +1,56 @@
|
||||
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
||||
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
||||
# The overall format is standard TOML format, v0.5.0.
|
||||
# Note that there are a couple of TOML lists in this file.
|
||||
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||
modLoader="javafml" #mandatory
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||
loaderVersion="[26,)" #mandatory (26 is current forge version)
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
issueTrackerURL="http://my.issue.tracker/" #optional
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId="examplemod" #mandatory
|
||||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
version="${file.jarVersion}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="Example Mod" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification <here>
|
||||
updateJSONURL="http://myurl.me/" #optional
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
displayURL="http://example.com/" #optional
|
||||
# A file name (in the root of the mod JAR) containing a logo for display
|
||||
logoFile="examplemod.png" #optional
|
||||
# A text field displayed in the mod UI
|
||||
credits="Thanks for this example mod goes to Java" #optional
|
||||
# A text field displayed in the mod UI
|
||||
authors="Love, Cheese and small house plants" #optional
|
||||
# The description text for the mod (multi line!) (#mandatory)
|
||||
description='''
|
||||
This is a long form description of the mod. You can write whatever you want here
|
||||
|
||||
Have some lorem ipsum.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis lacinia magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sagittis luctus odio eu tempus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque volutpat ligula eget lacus auctor sagittis. In hac habitasse platea dictumst. Nunc gravida elit vitae sem vehicula efficitur. Donec mattis ipsum et arcu lobortis, eleifend sagittis sem rutrum. Cras pharetra quam eget posuere fermentum. Sed id tincidunt justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
'''
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies.examplemod]] #optional
|
||||
# the modid of the dependency
|
||||
modId="forge" #mandatory
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange="[26,)" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||
side="BOTH"
|
||||
# Here's another dependency
|
||||
[[dependencies.examplemod]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.14.2]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
7
src/main/resources/pack.mcmeta
Normal file
7
src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "examplemod resources",
|
||||
"pack_format": 4,
|
||||
"_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods."
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user