mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-21 19:43:28 +01:00
basic pipe looks
This commit is contained in:
parent
06c965b9a0
commit
44595ab0a8
18 changed files with 964 additions and 0 deletions
22
.gitignore
vendored
Normal file
22
.gitignore
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
/rebuild.bat
|
||||
/doAllTheThings.bat
|
||||
/.gradle
|
||||
/build
|
||||
/out
|
||||
/idea
|
||||
/.idea
|
||||
/*.iml
|
||||
/*.ipr
|
||||
/*.iws
|
||||
/lib
|
||||
/classes
|
||||
/bin/
|
||||
/run/
|
||||
|
||||
*.classpath
|
||||
*.project
|
||||
.settings/org.eclipse.buildship.core.prefs
|
||||
*.launch
|
||||
.settings/org.eclipse.jdt.core.prefs
|
||||
*.prefs
|
||||
.cache
|
23
Jenkinsfile
vendored
Normal file
23
Jenkinsfile
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
pipeline {
|
||||
agent any
|
||||
stages {
|
||||
stage('Clean') {
|
||||
steps {
|
||||
sh 'chmod +x ./gradlew'
|
||||
sh './gradlew clean --no-daemon'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh './gradlew build --no-daemon'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Upload Artifacts') {
|
||||
steps {
|
||||
archiveArtifacts 'build/libs/**.jar'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
153
build.gradle
Normal file
153
build.gradle
Normal file
|
@ -0,0 +1,153 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
maven { url = 'https://files.minecraftforge.net/maven' }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
||||
}
|
||||
}
|
||||
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 = '0.1'
|
||||
group = 'de.ellpeck.prettypipes' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'PrettyPipes'
|
||||
|
||||
if (System.getenv('BUILD_NUMBER') != null) {
|
||||
version += "." + System.getenv('BUILD_NUMBER')
|
||||
}
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20200128-1.15.1'
|
||||
|
||||
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', 'info'
|
||||
|
||||
mods {
|
||||
prettypipes {
|
||||
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', 'info'
|
||||
|
||||
mods {
|
||||
prettypipes {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data {
|
||||
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', 'info'
|
||||
|
||||
args '--mod', 'prettypipes', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/'), '--existing', file('src/generated/resources')
|
||||
|
||||
mods {
|
||||
prettypipes {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets.main.resources {
|
||||
srcDir 'src/generated/resources'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = "https://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
embed
|
||||
compile.extendsFrom(embed)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft 'net.minecraftforge:forge:1.15.2-31.1.19'
|
||||
embed "org.jgrapht:jgrapht-core:1.4.0"
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2:api")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2")
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading by the runtime..
|
||||
jar {
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title" : "prettypipes",
|
||||
"Specification-Vendor" : "Ellpeck",
|
||||
"Specification-Version" : "1", // We are version 1 of ourselves
|
||||
"Implementation-Title" : project.name,
|
||||
"Implementation-Version" : "${version}",
|
||||
"Implementation-Vendor" : "Ellpeck",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
])
|
||||
}
|
||||
from configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
|
||||
task deobfJar(type: Jar) {
|
||||
from(sourceSets.main.output)
|
||||
archiveName = "${baseName}-${version}-deobf.${extension}"
|
||||
}
|
||||
artifacts {
|
||||
archives deobfJar
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
groupId project.group
|
||||
artifactId project.archivesBaseName
|
||||
version project.version
|
||||
from components.java
|
||||
|
||||
artifact deobfJar {
|
||||
classifier 'deobf'
|
||||
}
|
||||
|
||||
pom.withXml {
|
||||
def node = asNode()
|
||||
if (node.dependencies.size() > 0)
|
||||
node.remove(node.dependencies)
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url "file://" + System.getenv("local_maven")
|
||||
}
|
||||
}
|
||||
}
|
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
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Sun Oct 20 21:47:13 CEST 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
172
gradlew
vendored
Normal file
172
gradlew
vendored
Normal file
|
@ -0,0 +1,172 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
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
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
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
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
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`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# 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" "$@"
|
84
gradlew.bat
vendored
Normal file
84
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
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
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
17
src/main/java/de/ellpeck/prettypipes/PrettyPipes.java
Normal file
17
src/main/java/de/ellpeck/prettypipes/PrettyPipes.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package de.ellpeck.prettypipes;
|
||||
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
@Mod(PrettyPipes.ID)
|
||||
public final class PrettyPipes {
|
||||
|
||||
public static final String ID = "prettypipes";
|
||||
|
||||
public PrettyPipes() {
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
bus.addListener(Registry::setup);
|
||||
bus.addListener(Registry::setupClient);
|
||||
}
|
||||
}
|
44
src/main/java/de/ellpeck/prettypipes/Registry.java
Normal file
44
src/main/java/de/ellpeck/prettypipes/Registry.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package de.ellpeck.prettypipes;
|
||||
|
||||
import de.ellpeck.prettypipes.blocks.PipeBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Bus.MOD)
|
||||
public final class Registry {
|
||||
|
||||
public static Block pipe;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event) {
|
||||
event.getRegistry().registerAll(
|
||||
pipe = new PipeBlock().setRegistryName("pipe")
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(RegistryEvent.Register<Item> event) {
|
||||
ForgeRegistries.BLOCKS.getValues().stream()
|
||||
.filter(b -> b.getRegistryName().getNamespace().equals(PrettyPipes.ID))
|
||||
.forEach(b -> event.getRegistry().register(new BlockItem(b, new Item.Properties().group(ItemGroup.MISC)).setRegistryName(b.getRegistryName())));
|
||||
}
|
||||
|
||||
public static void setup(FMLCommonSetupEvent event) {
|
||||
|
||||
}
|
||||
|
||||
public static void setupClient(FMLClientSetupEvent event) {
|
||||
RenderTypeLookup.setRenderLayer(pipe, RenderType.cutout());
|
||||
}
|
||||
}
|
125
src/main/java/de/ellpeck/prettypipes/blocks/PipeBlock.java
Normal file
125
src/main/java/de/ellpeck/prettypipes/blocks/PipeBlock.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
package de.ellpeck.prettypipes.blocks;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class PipeBlock extends Block {
|
||||
|
||||
public static final Map<Direction, EnumProperty<ConnectionType>> DIRECTIONS = new HashMap<>();
|
||||
private static final Map<BlockState, VoxelShape> SHAPE_CACHE = new HashMap<>();
|
||||
private static final VoxelShape CENTER_SHAPE = makeCuboidShape(5, 5, 5, 11, 11, 11);
|
||||
private static final Map<Direction, VoxelShape> DIR_SHAPES = ImmutableMap.<Direction, VoxelShape>builder()
|
||||
.put(Direction.UP, makeCuboidShape(5, 10, 5, 11, 16, 11))
|
||||
.put(Direction.DOWN, makeCuboidShape(5, 0, 5, 11, 6, 11))
|
||||
.put(Direction.NORTH, makeCuboidShape(5, 5, 0, 11, 11, 6))
|
||||
.put(Direction.SOUTH, makeCuboidShape(5, 5, 10, 11, 11, 16))
|
||||
.put(Direction.EAST, makeCuboidShape(10, 5, 5, 16, 11, 11))
|
||||
.put(Direction.WEST, makeCuboidShape(0, 5, 5, 6, 11, 11))
|
||||
.build();
|
||||
|
||||
static {
|
||||
for (Direction dir : Direction.values())
|
||||
DIRECTIONS.put(dir, EnumProperty.create(dir.getName(), ConnectionType.class));
|
||||
}
|
||||
|
||||
public PipeBlock() {
|
||||
super(Block.Properties.create(Material.ROCK).hardnessAndResistance(2).sound(SoundType.STONE).notSolid());
|
||||
|
||||
BlockState state = this.getDefaultState();
|
||||
for (EnumProperty<ConnectionType> prop : DIRECTIONS.values())
|
||||
state = state.with(prop, ConnectionType.DISCONNECTED);
|
||||
this.setDefaultState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(DIRECTIONS.values().toArray(new EnumProperty[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) {
|
||||
BlockState newState = this.createState(worldIn, pos);
|
||||
if (newState != state)
|
||||
worldIn.setBlockState(pos, newState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext context) {
|
||||
return this.createState(context.getWorld(), context.getPos());
|
||||
}
|
||||
|
||||
private BlockState createState(World world, BlockPos pos) {
|
||||
BlockState state = this.getDefaultState();
|
||||
for (Map.Entry<Direction, EnumProperty<ConnectionType>> entry : DIRECTIONS.entrySet()) {
|
||||
BlockPos neighborPos = pos.offset(entry.getKey());
|
||||
boolean canConnect = this.canConnect(world, neighborPos);
|
||||
state = state.with(entry.getValue(), canConnect ? ConnectionType.CONNECTED : ConnectionType.DISCONNECTED);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
private boolean canConnect(World world, BlockPos offset) {
|
||||
if (!world.isBlockLoaded(offset))
|
||||
return false;
|
||||
BlockState state = world.getBlockState(offset);
|
||||
return state.getBlock() == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
VoxelShape shape = SHAPE_CACHE.get(state);
|
||||
if (shape != null)
|
||||
return shape;
|
||||
|
||||
shape = CENTER_SHAPE;
|
||||
for (Map.Entry<Direction, EnumProperty<ConnectionType>> entry : DIRECTIONS.entrySet()) {
|
||||
if (state.get(entry.getValue()) == ConnectionType.CONNECTED)
|
||||
shape = VoxelShapes.or(shape, DIR_SHAPES.get(entry.getKey()));
|
||||
}
|
||||
SHAPE_CACHE.put(state, shape);
|
||||
return shape;
|
||||
}
|
||||
|
||||
public enum ConnectionType implements IStringSerializable {
|
||||
CONNECTED,
|
||||
DISCONNECTED;
|
||||
|
||||
private final String name;
|
||||
|
||||
ConnectionType() {
|
||||
this.name = this.name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
32
src/main/resources/META-INF/mods.toml
Normal file
32
src/main/resources/META-INF/mods.toml
Normal file
|
@ -0,0 +1,32 @@
|
|||
# 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="[28,)" #mandatory (28 is current forge version)
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
issueTrackerURL="https://github.com/Ellpeck/PrettyPipes" #optional
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId="prettypipes" #mandatory
|
||||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
version="${version}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="Pretty Pipes" #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="Commission for Violet" #optional
|
||||
# A text field displayed in the mod UI
|
||||
authors="Ellpeck" #optional
|
||||
# The description text for the mod (multi line!) (#mandatory)
|
||||
description='''
|
||||
wow pipes, how creative'''
|
62
src/main/resources/assets/prettypipes/blockstates/pipe.json
Normal file
62
src/main/resources/assets/prettypipes/blockstates/pipe.json
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
"multipart": [
|
||||
{
|
||||
"apply": {
|
||||
"model": "prettypipes:block/pipe_center"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"north": "connected"
|
||||
},
|
||||
"apply": {
|
||||
"model": "prettypipes:block/pipe_end"
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"south": "connected"
|
||||
},
|
||||
"apply": {
|
||||
"model": "prettypipes:block/pipe_end",
|
||||
"y": 180
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"east": "connected"
|
||||
},
|
||||
"apply": {
|
||||
"model": "prettypipes:block/pipe_end",
|
||||
"y": 90
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"west": "connected"
|
||||
},
|
||||
"apply": {
|
||||
"model": "prettypipes:block/pipe_end",
|
||||
"y": 270
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"down": "connected"
|
||||
},
|
||||
"apply": {
|
||||
"model": "prettypipes:block/pipe_end",
|
||||
"x": 90
|
||||
}
|
||||
},
|
||||
{
|
||||
"when": {
|
||||
"up": "connected"
|
||||
},
|
||||
"apply": {
|
||||
"model": "prettypipes:block/pipe_end",
|
||||
"x": 270
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
{
|
||||
"credit": "Made with Blockbench",
|
||||
"textures": {
|
||||
"0": "prettypipes:block/pipe",
|
||||
"particle": "prettypipes:block/pipe"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [5, 5, 5],
|
||||
"to": [6, 11, 6],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 1, 1], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [5, 5, 10],
|
||||
"to": [6, 11, 11],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 1, 1], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [10, 5, 10],
|
||||
"to": [11, 11, 11],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 1, 1], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [10, 5, 5],
|
||||
"to": [11, 11, 6],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 1, 6], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 1, 1], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [6, 10, 10],
|
||||
"to": [10, 11, 11],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 4, 1], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [6, 5, 10],
|
||||
"to": [10, 6, 11],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 4, 1], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [6, 5, 5],
|
||||
"to": [10, 6, 6],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 4, 1], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [5, 5, 6],
|
||||
"to": [6, 6, 10],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 1, 4], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 1, 4], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [5, 10, 6],
|
||||
"to": [6, 11, 10],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 1, 4], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 1, 4], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [10, 10, 6],
|
||||
"to": [11, 11, 10],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 1, 4], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 1, 4], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [10, 5, 6],
|
||||
"to": [11, 6, 10],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 1, 4], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 1, 4], "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [6, 10, 5],
|
||||
"to": [10, 11, 6],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 4, 1], "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 4, 1], "texture": "#0"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"credit": "Made with Blockbench",
|
||||
"textures": {
|
||||
"0": "prettypipes:block/pipe",
|
||||
"particle": "prettypipes:block/pipe"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"from": [5, 10, 0],
|
||||
"to": [6, 11, 5],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 5, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 5, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 5, 1], "rotation": 90, "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 5, 1], "rotation": 270, "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [5, 5, 0],
|
||||
"to": [6, 6, 5],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 5, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 5, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 5, 1], "rotation": 90, "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 5, 1], "rotation": 270, "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [10, 5, 0],
|
||||
"to": [11, 6, 5],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 5, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 5, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 5, 1], "rotation": 90, "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 5, 1], "rotation": 270, "texture": "#0"}
|
||||
}
|
||||
},
|
||||
{
|
||||
"from": [10, 10, 0],
|
||||
"to": [11, 11, 5],
|
||||
"faces": {
|
||||
"north": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"east": {"uv": [0, 0, 5, 1], "texture": "#0"},
|
||||
"south": {"uv": [0, 0, 1, 1], "texture": "#0"},
|
||||
"west": {"uv": [0, 0, 5, 1], "texture": "#0"},
|
||||
"up": {"uv": [0, 0, 5, 1], "rotation": 90, "texture": "#0"},
|
||||
"down": {"uv": [0, 0, 5, 1], "rotation": 270, "texture": "#0"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "prettypipes:block/pipe_center"
|
||||
}
|
BIN
src/main/resources/assets/prettypipes/textures/block/pipe.png
Normal file
BIN
src/main/resources/assets/prettypipes/textures/block/pipe.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 182 B |
7
src/main/resources/pack.mcmeta
Normal file
7
src/main/resources/pack.mcmeta
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"pack": {
|
||||
"description": "Pretty Pipes",
|
||||
"pack_format": 4,
|
||||
"_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods."
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue