Browse Source

initial commit

master
Martmists 7 months ago
commit
8fd993bed7
35 changed files with 1390 additions and 0 deletions
  1. +4
    -0
      .gitignore
  2. +7
    -0
      LICENSE
  3. +3
    -0
      README.md
  4. +25
    -0
      build.gradle
  5. +4
    -0
      gradle.properties
  6. BIN
     
  7. +6
    -0
      gradle/wrapper/gradle-wrapper.properties
  8. +172
    -0
      gradlew
  9. +84
    -0
      gradlew.bat
  10. +4
    -0
      settings.gradle
  11. +87
    -0
      src/main/java/com/martmists/ynet/YNetMod.java
  12. +6
    -0
      src/main/java/com/martmists/ynet/api/BaseProvider.java
  13. +35
    -0
      src/main/java/com/martmists/ynet/api/EnergyProvider.java
  14. +38
    -0
      src/main/java/com/martmists/ynet/api/ItemProvider.java
  15. +94
    -0
      src/main/java/com/martmists/ynet/blockentities/ControllerBlockEntity.java
  16. +66
    -0
      src/main/java/com/martmists/ynet/blocks/CableBlock.java
  17. +145
    -0
      src/main/java/com/martmists/ynet/blocks/ConnectorBlock.java
  18. +17
    -0
      src/main/java/com/martmists/ynet/blocks/ControllerBlock.java
  19. +16
    -0
      src/main/java/com/martmists/ynet/event/ProviderTickCallback.java
  20. +14
    -0
      src/main/java/com/martmists/ynet/mixin/accessors/InventoryStacksAccessor.java
  21. +62
    -0
      src/main/java/com/martmists/ynet/mixin/providers/energy/PowerAcceptorMixin.java
  22. +78
    -0
      src/main/java/com/martmists/ynet/mixin/providers/item/AbstractFurnaceBlockMixin.java
  23. +111
    -0
      src/main/java/com/martmists/ynet/mixin/providers/item/GenericMachineBlockMixin.java
  24. +95
    -0
      src/main/java/com/martmists/ynet/mixin/providers/item/LootableContainerBlockMixin.java
  25. +64
    -0
      src/main/resources/assets/ynet/blockstates/cable.json
  26. +24
    -0
      src/main/resources/assets/ynet/models/block/cable.json
  27. +23
    -0
      src/main/resources/assets/ynet/models/block/cable_side.json
  28. BIN
     
  29. +23
    -0
      src/main/resources/fabric.mod.json
  30. +11
    -0
      src/main/resources/mod.mixins.json
  31. +1
    -0
      versions/1.15.2/build.gradle
  32. +5
    -0
      versions/1.15.2/gradle.properties
  33. +1
    -0
      versions/1.16/build.gradle
  34. +5
    -0
      versions/1.16/gradle.properties
  35. +60
    -0
      versions/common.gradle

+ 4
- 0
.gitignore View File

@@ -0,0 +1,4 @@
.idea/
build/
run/
.gradle/

+ 7
- 0
LICENSE View File

@@ -0,0 +1,7 @@
Copyright 2019 Martmists

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+ 3
- 0
README.md View File

@@ -0,0 +1,3 @@
# YNet

A fabric port of XNet, written from scratch

+ 25
- 0
build.gradle View File

@@ -0,0 +1,25 @@
buildscript {
dependencies {
classpath "net.fabricmc:fabric-loom:0.2.7-SNAPSHOT"
}
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}

apply plugin: "idea"

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}

repositories {
mavenCentral()
maven {
url 'https://jitpack.io'
}
}

+ 4
- 0
gradle.properties View File

@@ -0,0 +1,4 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
mod_version=0.0.1
mod_name=ynet

BIN
View File


+ 6
- 0
gradle/wrapper/gradle-wrapper.properties View File

@@ -0,0 +1,6 @@
#Tue Oct 15 13:15:02 CEST 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

+ 172
- 0
gradlew View 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='"-Xmx64m"'

# 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
- 0
gradlew.bat View 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="-Xmx64m"
@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

+ 4
- 0
settings.gradle View File

@@ -0,0 +1,4 @@
include "versions:1.15.2"
include "versions:1.16"

rootProject.name = 'ynet'

+ 87
- 0
src/main/java/com/martmists/ynet/YNetMod.java View File

@@ -0,0 +1,87 @@
package com.martmists.ynet;

import com.martmists.ynet.api.BaseProvider;
import com.martmists.ynet.api.EnergyProvider;
import com.martmists.ynet.api.ItemProvider;
import com.martmists.ynet.blockentities.ControllerBlockEntity;
import com.martmists.ynet.blocks.CableBlock;
import com.martmists.ynet.blocks.ConnectorBlock;
import com.martmists.ynet.blocks.ControllerBlock;
import com.martmists.ynet.event.ProviderTickCallback;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.SimpleRegistry;

import java.util.HashMap;
import java.util.Map;

public class YNetMod implements ModInitializer {
public static ItemGroup YNET_GROUP = FabricItemGroupBuilder.build(
new Identifier("ynet", "items"),
() -> new ItemStack(
Registry.ITEM.get(
new Identifier("ynet", "cable")
)
)
);
public static CableBlock CABLE = register("cable", new CableBlock(Block.Settings.of(Material.METAL)));
public static ConnectorBlock CONNECTOR = register("connector", new ConnectorBlock(Block.Settings.of(Material.METAL)));
public static ControllerBlock CONTROLLER = register("controller", new ControllerBlock(Block.Settings.of(Material.METAL)));
public static BlockEntityType<ControllerBlockEntity> CONTROLLER_BE = Registry.register(
Registry.BLOCK_ENTITY_TYPE,
new Identifier("ynet", "controller"),
BlockEntityType.Builder.create(ControllerBlockEntity::new, CONTROLLER).build(null)
);

public static Map<Class<? extends BaseProvider>, ProviderTickCallback<? extends BaseProvider>> PROVIDERS = new HashMap<>();
public static Map<Class<? extends BaseProvider>, String> PROVIDER_NAMES = new HashMap<>();

@Override
public void onInitialize() {
System.out.println("YNet loaded!");
register("ynet:item", ItemProvider.class, (ItemProvider[] listeners, ControllerBlockEntity be) -> {
// TODO:
// - Get matching channels from ControllerBlockEntity
// - Find a way to route all items (+ filters?
return ActionResult.SUCCESS;
});
register("ynet:energy", EnergyProvider.class, (EnergyProvider[] listeners, ControllerBlockEntity be) -> {
// TODO:
// - Get matching channels from ControllerBlockEntity
// - Find a way to route all energy
return ActionResult.SUCCESS;
});
// TODO:
// - Add support for configuring redstone signals on connectors
}

static <T extends Block> T register(String name, T block) {
return register(name, block, new BlockItem(block, new Item.Settings().group(YNET_GROUP)));
}

static <T extends Block> T register(String name, T block, BlockItem bl) {
T b = Registry.register(Registry.BLOCK, new Identifier("ynet", name), block);
register(name, bl);
return b;
}

static <T extends Item> T register(String name, T item) {
return Registry.register(Registry.ITEM, new Identifier("ynet", name), item);
}

static <T extends BaseProvider> ProviderTickCallback<T> register(String name, Class<T> clazz, ProviderTickCallback<T> callback) {
PROVIDER_NAMES.put(clazz, name);
PROVIDERS.put(clazz, callback);
return callback;
}
}

+ 6
- 0
src/main/java/com/martmists/ynet/api/BaseProvider.java View File

@@ -0,0 +1,6 @@
package com.martmists.ynet.api;

import java.util.Arrays;

// Base interface for implementation checks
public interface BaseProvider { }

+ 35
- 0
src/main/java/com/martmists/ynet/api/EnergyProvider.java View File

@@ -0,0 +1,35 @@
package com.martmists.ynet.api;

import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;

public interface EnergyProvider extends BaseProvider {
/**
* @param world The world the block resides in
* @param pos The BlockPos of the block
* @return The maximum energy this block can receive
*/
double getEnergyInputLimit(BlockView world, BlockPos pos);

/**
* @param world The world the block resides in
* @param pos The BlockPos of the block
* @param energy The amount of energy to be added to the machine
*/
void inputEnergy(BlockView world, BlockPos pos, double energy);

/**
* @param world The world the block resides in
* @param pos The BlockPos of the block
* @return The maximum energy this block can output
*/
double getEnergyOutputLimit(BlockView world, BlockPos pos);

/**
* @param world The world the block resides in
* @param pos The BlockPos of the block
* @param energy The amount of energy to be added to the machine
*/
void outputEnergy(BlockView world, BlockPos pos, double energy);
}

+ 38
- 0
src/main/java/com/martmists/ynet/api/ItemProvider.java View File

@@ -0,0 +1,38 @@
package com.martmists.ynet.api;

import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;

public interface ItemProvider extends BaseProvider {
/**
* @param world The world the block resides in
* @param pos The BlockPos of the block
* @param itemStack The ItemStack to attempt to input
* @return The amount of items from the stack that can be input
*/
int getItemInputCount(BlockView world, BlockPos pos, ItemStack itemStack);

/**
* @param world The world the block resides in
* @param pos The BlockPos of the block
* @param itemStack The ItemStack to add to the block
*/
void inputItem(BlockView world, BlockPos pos, ItemStack itemStack);

/**
* @param world The world the block resides in
* @param pos The BlockPos of the block
* @return The ItemStacks that can be output
*/
ItemStack[] getItemOutputStacks(BlockView world, BlockPos pos);

/**
* @param world The world the block resides in
* @param pos The BlockPos of the block
* @param itemStack the ItemStack to remove from the container
* May not be an existing stack, make sure to check the count
*/
void outputItem(BlockView world, BlockPos pos, ItemStack itemStack);
}

+ 94
- 0
src/main/java/com/martmists/ynet/blockentities/ControllerBlockEntity.java View File

@@ -0,0 +1,94 @@
package com.martmists.ynet.blockentities;

import com.martmists.ynet.YNetMod;
import com.martmists.ynet.api.BaseProvider;
import com.martmists.ynet.blocks.CableBlock;
import com.martmists.ynet.blocks.ConnectorBlock;
import com.martmists.ynet.event.ProviderTickCallback;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Tickable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;

import java.lang.reflect.Array;
import java.util.*;
import java.util.stream.Collectors;

public class ControllerBlockEntity extends BlockEntity implements Tickable {
public ControllerBlockEntity() {
super(YNetMod.CONTROLLER_BE);
}

// TODO:
// - Add configurable channels
// - Add a way to get input/output blocks from said channel

private Block[] getConnectedBlocks() {
List<BlockPos> searched = new ArrayList<>();
List<BlockPos> providers = new ArrayList<>();
searched.add(pos);
findNeighbors(world, pos, searched, providers);
return (Block[]) providers.stream().map(p -> world.getBlockState(p).getBlock()).toArray();
}

private static void findNeighbors(BlockView world, BlockPos p, List<BlockPos> searched, List<BlockPos> providers) {
List<BlockPos> toSearch = Arrays.asList(p.up(), p.down(), p.north(), p.south(), p.east(), p.west());
for (BlockPos bp : toSearch) {
searched.add(bp);
Block block = world.getBlockState(bp).getBlock();
if (block instanceof BaseProvider){
providers.add(bp);
}
if (block instanceof CableBlock || block instanceof ConnectorBlock){
findNeighbors(world, bp, searched, providers);
}
}
}

@Override
public void tick() {
// TODO:
// Collect all connected blocks
Block[] blocks = getConnectedBlocks();

Map<Class<? extends BaseProvider>, List<BaseProvider>> blockMap = new HashMap<>();
for (Block b : blocks) {
Class<?> bClass = b.getClass();
if (!tMap.containsKey(bClass)){
Set<Class<? extends BaseProvider>> set = new HashSet<>();
findProviderTypes(bClass, set);
tMap.put(bClass, set);
}
for (Class<? extends BaseProvider> clazz : tMap.get(bClass)){
blockMap.putIfAbsent(clazz, new ArrayList<>());
blockMap.get(clazz).add((BaseProvider)b);
}
}

for (Class<? extends BaseProvider> clazz : blockMap.keySet()) {
dispatch(clazz, blockMap.get(clazz));
}
}

private <P extends BaseProvider> void dispatch(Class<? extends BaseProvider> clazz, List<P> blockMap) {
ProviderTickCallback<P> provider = (ProviderTickCallback<P>) YNetMod.PROVIDERS.get(clazz);
provider.interact(blockMap.toArray(provider.createArray((Class<P>) clazz)), this);

}

// Ugly hack by Pyrofab
private static Map<Class<?>, Set<Class<? extends BaseProvider>>> tMap = new HashMap<>();
private static void findProviderTypes(Class<?> cls, Set<Class<? extends BaseProvider>> ret) {
tMap.putIfAbsent(cls, ret);
if (cls != Object.class) {
if (BaseProvider.class.isAssignableFrom(cls)) {
ret.add((Class<? extends BaseProvider>) cls);
}
findProviderTypes(cls.getSuperclass(), ret);
for (Class<?> itf : cls.getInterfaces()) {
findProviderTypes(itf, ret);
}
}
}
}

+ 66
- 0
src/main/java/com/martmists/ynet/blocks/CableBlock.java View File

@@ -0,0 +1,66 @@
package com.martmists.ynet.blocks;

import com.martmists.ynet.YNetMod;
import com.martmists.ynet.api.BaseProvider;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.ConnectingBlock;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.Property;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.IWorld;

public class CableBlock extends ConnectingBlock {
public CableBlock(Settings settings) {
super(0.1875F, settings);
setDefaultState(getStateManager().getDefaultState()
.with(NORTH, false)
.with(EAST, false)
.with(SOUTH, false)
.with(WEST, false)
.with(UP, false)
.with(DOWN, false)
);
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(NORTH, EAST, SOUTH, WEST, UP, DOWN);
}

@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.withConnectionProperties(ctx.getWorld(), ctx.getBlockPos());
}

@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, IWorld world, BlockPos pos, BlockPos neighborPos) {
if (!state.canPlaceAt(world, pos)) {
world.getBlockTickScheduler().schedule(pos, this, 1);
return super.getStateForNeighborUpdate(state, facing, neighborState, world, pos, neighborPos);
} else {
Block block = neighborState.getBlock();
return state.with(FACING_PROPERTIES.get(facing), block == this || block == YNetMod.CONNECTOR || block instanceof BaseProvider);
}
}

public BlockState withConnectionProperties(BlockView world, BlockPos pos) {
Block block = world.getBlockState(pos.down()).getBlock();
Block block2 = world.getBlockState(pos.up()).getBlock();
Block block3 = world.getBlockState(pos.north()).getBlock();
Block block4 = world.getBlockState(pos.east()).getBlock();
Block block5 = world.getBlockState(pos.south()).getBlock();
Block block6 = world.getBlockState(pos.west()).getBlock();
return this.getDefaultState()
.with(DOWN, block == this || block == YNetMod.CONNECTOR)
.with(UP, block2 == this || block2 == YNetMod.CONNECTOR)
.with(NORTH, block3 == this || block3 == YNetMod.CONNECTOR)
.with(EAST, block4 == this || block4 == YNetMod.CONNECTOR)
.with(SOUTH, block5 == this || block5 == YNetMod.CONNECTOR)
.with(WEST, block6 == this || block6 == YNetMod.CONNECTOR);
}
}

+ 145
- 0
src/main/java/com/martmists/ynet/blocks/ConnectorBlock.java View File

@@ -0,0 +1,145 @@
package com.martmists.ynet.blocks;

import com.martmists.ynet.YNetMod;
import com.martmists.ynet.api.BaseProvider;
import com.sun.org.apache.xpath.internal.operations.Bool;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ConnectingBlock;
import net.minecraft.block.RedstoneWireBlock;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.IWorld;
import net.minecraft.world.ModifiableWorld;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ConnectorBlock extends ConnectingBlock {
public static final IntProperty NORTH_REDSTONE = IntProperty.of("NORTH_REDSTONE", 0, 15);
public static final IntProperty EAST_REDSTONE = IntProperty.of("EAST_REDSTONE", 0, 15);
public static final IntProperty SOUTH_REDSTONE = IntProperty.of("SOUTH_REDSTONE", 0, 15);
public static final IntProperty WEST_REDSTONE = IntProperty.of("WEST_REDSTONE", 0, 15);
public static final IntProperty UP_REDSTONE = IntProperty.of("UP_REDSTONE", 0, 15);
public static final IntProperty DOWN_REDSTONE = IntProperty.of("DOWN_REDSTONE", 0, 15);

public ConnectorBlock(Settings settings) {
super(0.1875F, settings);
setDefaultState(getStateManager().getDefaultState()
.with(NORTH, false)
.with(EAST, false)
.with(SOUTH, false)
.with(WEST, false)
.with(UP, false)
.with(DOWN, false)
.with(NORTH_REDSTONE, 0)
.with(EAST_REDSTONE, 0)
.with(SOUTH_REDSTONE, 0)
.with(WEST_REDSTONE, 0)
.with(UP_REDSTONE, 0)
.with(DOWN_REDSTONE, 0)
);
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(NORTH, EAST, SOUTH, WEST, UP, DOWN);
}

@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.withConnectionProperties(ctx.getWorld(), ctx.getBlockPos());
}

@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction facing, BlockState neighborState, IWorld world, BlockPos pos, BlockPos neighborPos) {
if (!state.canPlaceAt(world, pos)) {
world.getBlockTickScheduler().schedule(pos, this, 1);
return super.getStateForNeighborUpdate(state, facing, neighborState, world, pos, neighborPos);
} else {
Block block = neighborState.getBlock();
return state.with(FACING_PROPERTIES.get(facing), block == this || block == YNetMod.CABLE || block instanceof BaseProvider);
}
}

public <T extends BaseProvider> T[] getProviders(BlockView world, BlockPos pos) {
List<T> providers = new ArrayList<>();
for (BlockPos position : new BlockPos[]{ pos.up(), pos.down(), pos.north(), pos.east(), pos.south(), pos.west() }){
Block b = world.getBlockState(position).getBlock();
if (b instanceof BaseProvider){
providers.add((T)b);
}
}
return (T[])providers.toArray();
}

public BlockState withConnectionProperties(BlockView world, BlockPos pos) {
Block block = world.getBlockState(pos.down()).getBlock();
Block block2 = world.getBlockState(pos.up()).getBlock();
Block block3 = world.getBlockState(pos.north()).getBlock();
Block block4 = world.getBlockState(pos.east()).getBlock();
Block block5 = world.getBlockState(pos.south()).getBlock();
Block block6 = world.getBlockState(pos.west()).getBlock();
return this.getDefaultState()
.with(DOWN, block == this || block == YNetMod.CABLE || block instanceof BaseProvider)
.with(UP, block2 == this || block2 == YNetMod.CABLE || block2 instanceof BaseProvider)
.with(NORTH, block3 == this || block3 == YNetMod.CABLE || block3 instanceof BaseProvider)
.with(EAST, block4 == this || block4 == YNetMod.CABLE || block4 instanceof BaseProvider)
.with(SOUTH, block5 == this || block5 == YNetMod.CABLE || block5 instanceof BaseProvider)
.with(WEST, block6 == this || block6 == YNetMod.CABLE || block6 instanceof BaseProvider);
}

@Override
public int getStrongRedstonePower(BlockState state, BlockView world, BlockPos pos, Direction facing) {
return state.getWeakRedstonePower(world, pos, facing);
}

@Override
public int getWeakRedstonePower(BlockState state, BlockView world, BlockPos pos, Direction facing) {
return state.get(getProp(facing));
}

public void setRedstoneOutput(Direction facing, BlockView world, BlockPos pos, int strength) {

((ModifiableWorld)world).setBlockState(pos, world.getBlockState(pos).with(getProp(facing), strength), 3);
}

private IntProperty getProp(Direction facing) {
IntProperty p;
switch (facing){
case DOWN:
p = DOWN_REDSTONE;
break;
case UP:
p = UP_REDSTONE;
break;
case NORTH:
p = NORTH_REDSTONE;
break;
case SOUTH:
p = SOUTH_REDSTONE;
break;
case WEST:
p = WEST_REDSTONE;
break;
case EAST:
p = EAST_REDSTONE;
break;
default:
throw new IllegalStateException("Unexpected value: " + facing);
}
return p;
}

public int getRedstoneOutput(Direction facing, BlockView world, BlockPos pos){
BlockState state = world.getBlockState(pos.offset(facing));
return state.getBlock().getWeakRedstonePower(state, world, pos, facing);
}
}

+ 17
- 0
src/main/java/com/martmists/ynet/blocks/ControllerBlock.java View File

@@ -0,0 +1,17 @@
package com.martmists.ynet.blocks;

import com.martmists.ynet.blockentities.ControllerBlockEntity;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.BlockView;

public class ControllerBlock extends BlockWithEntity {
public ControllerBlock(Settings settings) {
super(settings);
}

@Override
public BlockEntity createBlockEntity(BlockView view) {
return new ControllerBlockEntity();
}
}

+ 16
- 0
src/main/java/com/martmists/ynet/event/ProviderTickCallback.java View File

@@ -0,0 +1,16 @@
package com.martmists.ynet.event;

import com.martmists.ynet.api.BaseProvider;
import com.martmists.ynet.blockentities.ControllerBlockEntity;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.util.ActionResult;

import java.lang.reflect.Array;
import java.util.Arrays;

public interface ProviderTickCallback<T extends BaseProvider> {
// DO NOT OVERRIDE
default T[] createArray(Class<T> clazz) { return (T[])Array.newInstance(clazz, 0); }
ActionResult interact(T[] listeners, ControllerBlockEntity be);
}

+ 14
- 0
src/main/java/com/martmists/ynet/mixin/accessors/InventoryStacksAccessor.java View File

@@ -0,0 +1,14 @@
package com.martmists.ynet.mixin.accessors;

import net.minecraft.block.entity.LootableContainerBlockEntity;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import java.util.List;

@Mixin(LootableContainerBlockEntity.class)
public interface InventoryStacksAccessor {
@Invoker
List<ItemStack> callGetInvStacks();
}

+ 62
- 0
src/main/java/com/martmists/ynet/mixin/providers/energy/PowerAcceptorMixin.java View File

@@ -0,0 +1,62 @@
package com.martmists.ynet.mixin.providers.energy;

import com.martmists.ynet.api.EnergyProvider;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import org.spongepowered.asm.mixin.Mixin;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import team.reborn.energy.EnergySide;
import techreborn.blocks.GenericMachineBlock;
import techreborn.blocks.generator.GenericGeneratorBlock;
import techreborn.blocks.storage.energy.EnergyStorageBlock;


@Mixin({GenericMachineBlock.class, GenericGeneratorBlock.class, EnergyStorageBlock.class})
public class PowerAcceptorMixin implements EnergyProvider {
@Override
public double getEnergyInputLimit(BlockView world, BlockPos pos) {
PowerAcceptorBlockEntity be = getBlockEntity(world, pos);
if (be == null) {
return 0;
}
return be.canAcceptEnergy(null) ?
Math.min(
be.getMaxStoredPower()-be.getStored(EnergySide.UNKNOWN),
be.getMaxInput(EnergySide.UNKNOWN)) :
0;
}

@Override
public void inputEnergy(BlockView world, BlockPos pos, double energy) {
PowerAcceptorBlockEntity be = getBlockEntity(world, pos);
be.setEnergy(be.getEnergy()+energy);
}

@Override
public double getEnergyOutputLimit(BlockView world, BlockPos pos) {
PowerAcceptorBlockEntity be = getBlockEntity(world, pos);
if (be == null) {
return 0;
}
return be.canProvideEnergy(null) ?
Math.min(
be.getStored(EnergySide.UNKNOWN),
be.getMaxOutput(EnergySide.UNKNOWN)) :
0;
}

@Override
public void outputEnergy(BlockView world, BlockPos pos, double energy) {
PowerAcceptorBlockEntity be = getBlockEntity(world, pos);
be.setEnergy(be.getEnergy()-energy);
}

private PowerAcceptorBlockEntity getBlockEntity(BlockView world, BlockPos pos){
BlockEntity be = world.getBlockEntity(pos);
if (be instanceof PowerAcceptorBlockEntity){
return (PowerAcceptorBlockEntity) be;
}
return null;
}
}

+ 78
- 0
src/main/java/com/martmists/ynet/mixin/providers/item/AbstractFurnaceBlockMixin.java View File

@@ -0,0 +1,78 @@
package com.martmists.ynet.mixin.providers.item;

import com.martmists.ynet.api.ItemProvider;
import net.minecraft.block.AbstractFurnaceBlock;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(AbstractFurnaceBlock.class)
public abstract class AbstractFurnaceBlockMixin implements ItemProvider {
@Override
public int getItemInputCount(BlockView world, BlockPos pos, ItemStack itemStack) {
AbstractFurnaceBlockEntity be = getBlockEntity(world, pos);
if (AbstractFurnaceBlockEntity.canUseAsFuel(itemStack)){
// put in fuel slot
ItemStack stack = be.getInvStack(1);
if (stack.isEmpty()){
return itemStack.getCount();
}
return stack.getMaxCount() - stack.getCount();
} else {
ItemStack stack = be.getInvStack(0);
if (stack.isEmpty()){
return itemStack.getCount();
} else {
if (stack.getItem() == itemStack.getItem()){
return stack.getMaxCount() - stack.getCount();
} else {
return 0;
}
}
}
}

@Override
public void inputItem(BlockView world, BlockPos pos, ItemStack itemStack) {
AbstractFurnaceBlockEntity be = getBlockEntity(world, pos);
if (AbstractFurnaceBlockEntity.canUseAsFuel(itemStack)){
ItemStack stack = be.getInvStack(1);
if (stack.isEmpty()){
be.setInvStack(1, itemStack);
} else {
stack.setCount(itemStack.getCount() + stack.getCount());
}
} else {
ItemStack stack = be.getInvStack(0);
if (stack.isEmpty()){
be.setInvStack(0, itemStack);
} else {
stack.setCount(itemStack.getCount() + stack.getCount());
}
}
}

@Override
public ItemStack[] getItemOutputStacks(BlockView world, BlockPos pos) {
return new ItemStack[] { getBlockEntity(world, pos).getInvStack(2) };
}

@Override
public void outputItem(BlockView world, BlockPos pos, ItemStack itemStack) {
AbstractFurnaceBlockEntity be = getBlockEntity(world, pos);
ItemStack stack = be.getInvStack(2);
if (itemStack.getCount() == stack.getCount()){
be.setInvStack(2, ItemStack.EMPTY);
} else {
stack.setCount(stack.getCount() - itemStack.getCount());
}
}

private AbstractFurnaceBlockEntity getBlockEntity(BlockView world, BlockPos pos){
return (AbstractFurnaceBlockEntity) world.getBlockEntity(pos);
}
}

+ 111
- 0
src/main/java/com/martmists/ynet/mixin/providers/item/GenericMachineBlockMixin.java View File

@@ -0,0 +1,111 @@
package com.martmists.ynet.mixin.providers.item;

import com.martmists.ynet.api.ItemProvider;
import com.martmists.ynet.mixin.accessors.InventoryStacksAccessor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import org.spongepowered.asm.mixin.Mixin;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.util.DefaultedListCollector;
import techreborn.blockentity.machine.GenericMachineBlockEntity;
import techreborn.blocks.GenericMachineBlock;

import java.util.Arrays;
import java.util.List;

@Mixin(GenericMachineBlock.class)
public class GenericMachineBlockMixin implements ItemProvider {

@Override
public int getItemInputCount(BlockView world, BlockPos pos, ItemStack itemStack) {
GenericMachineBlockEntity be = getBlockEntity(world, pos);
if (hasInventory(be)){
List<ItemStack> stacks = getInputStacks(be);
if (stacks.stream().anyMatch(ItemStack::isEmpty)) {
return itemStack.getMaxCount();
}
int available = 0;
for (ItemStack stack : stacks) {
if (stack.getItem() == itemStack.getItem()){
available += stack.getMaxCount() - stack.getCount();
}
}
return Math.min(available, itemStack.getMaxCount());
}
return 0;
}

@Override
public void inputItem(BlockView world, BlockPos pos, ItemStack itemStack) {
List<ItemStack> stacks = getInputStacks(getBlockEntity(world, pos));
int inputCount = itemStack.getCount();
for (ItemStack stack : stacks) {
if (stack.getItem() == itemStack.getItem()){
int available = stack.getMaxCount() - stack.getCount();
int inputting = Math.min(available, inputCount);
inputCount -= inputting;
stack.setCount(stack.getCount() + inputting);
}
if (inputCount <= 0) {
return;
}
}
if (inputCount > 0){
int i = 0;
for (ItemStack stack : stacks) {
if (stack.isEmpty()){
stacks.set(i, new ItemStack(itemStack.getItem(), inputCount));
return;
}
i++;
}
}
}

@Override
public ItemStack[] getItemOutputStacks(BlockView world, BlockPos pos) {
return getOutputStacks(getBlockEntity(world, pos)).stream().filter(stack -> !stack.isEmpty()).toArray(ItemStack[]::new);
}

@Override
public void outputItem(BlockView world, BlockPos pos, ItemStack itemStack) {
List<ItemStack> stacks = getOutputStacks(getBlockEntity(world, pos));
int outputCount = itemStack.getCount();
int i = 0;
for (ItemStack stack : stacks){
if (stack.getItem() == itemStack.getItem()){
int outputting = Math.min(outputCount, stack.getCount());
stack.setCount(outputting);
outputCount -= outputting;
if (stack.getCount() == 0){
stacks.set(i, ItemStack.EMPTY);
}
if (outputCount <= 0) {
return;
}
}
if (stack.isEmpty()) {
stacks.set(i, new ItemStack(itemStack.getItem(), outputCount));
return;
}
i++;
}
}

private GenericMachineBlockEntity getBlockEntity(BlockView world, BlockPos pos){
return (GenericMachineBlockEntity)world.getBlockEntity(pos);
}

private List<ItemStack> getInputStacks(GenericMachineBlockEntity be) {
return Arrays.stream(be.crafter.inputSlots).mapToObj(be::getInvStack).collect(DefaultedListCollector.toList());
}

private List<ItemStack> getOutputStacks(GenericMachineBlockEntity be) {
return Arrays.stream(be.crafter.outputSlots).mapToObj(be::getInvStack).collect(DefaultedListCollector.toList());
}

private boolean hasInventory(GenericMachineBlockEntity be) {
return be.getOptionalInventory().isPresent();
}
}

+ 95
- 0
src/main/java/com/martmists/ynet/mixin/providers/item/LootableContainerBlockMixin.java View File

@@ -0,0 +1,95 @@
package com.martmists.ynet.mixin.providers.item;

import com.martmists.ynet.api.ItemProvider;
import com.martmists.ynet.mixin.accessors.InventoryStacksAccessor;
import net.minecraft.block.*;
import net.minecraft.block.entity.LootableContainerBlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import org.spongepowered.asm.mixin.Mixin;

import java.util.List;

@Mixin(value={
ChestBlock.class, TrappedChestBlock.class,
ShulkerBoxBlock.class, DispenserBlock.class,
HopperBlock.class, BarrelBlock.class})
public abstract class LootableContainerBlockMixin implements ItemProvider {

@Override
public int getItemInputCount(BlockView world, BlockPos pos, ItemStack itemStack) {
List<ItemStack> stacks = ((InventoryStacksAccessor)getBlockEntity(world, pos)).callGetInvStacks();
if (stacks.stream().anyMatch(ItemStack::isEmpty)) {
return itemStack.getMaxCount();
}
int available = 0;
for (ItemStack stack : stacks) {
if (stack.getItem() == itemStack.getItem()){
available += stack.getMaxCount() - stack.getCount();
}
}
return Math.min(available, itemStack.getMaxCount());
}

@Override
public void inputItem(BlockView world, BlockPos pos, ItemStack itemStack) {
List<ItemStack> stacks = ((InventoryStacksAccessor)getBlockEntity(world, pos)).callGetInvStacks();
int inputCount = itemStack.getCount();
for (ItemStack stack : stacks) {
if (stack.getItem() == itemStack.getItem()){
int available = stack.getMaxCount() - stack.getCount();
int inputting = Math.min(available, inputCount);
inputCount -= inputting;
stack.setCount(stack.getCount() + inputting);
}
if (inputCount <= 0) {
return;
}
}
if (inputCount > 0){
int i = 0;
for (ItemStack stack : stacks) {
if (stack.isEmpty()){
stacks.set(i, new ItemStack(itemStack.getItem(), inputCount));
return;
}
i++;
}
}
}

@Override
public ItemStack[] getItemOutputStacks(BlockView world, BlockPos pos) {
return ((InventoryStacksAccessor)getBlockEntity(world, pos)).callGetInvStacks().stream().filter(stack -> !stack.isEmpty()).toArray(ItemStack[]::new);
}

@Override
public void outputItem(BlockView world, BlockPos pos, ItemStack itemStack) {
List<ItemStack> stacks = ((InventoryStacksAccessor)getBlockEntity(world, pos)).callGetInvStacks();
int outputCount = itemStack.getCount();
int i = 0;
for (ItemStack stack : stacks){
if (stack.getItem() == itemStack.getItem()){
int outputting = Math.min(outputCount, stack.getCount());
stack.setCount(outputting);
outputCount -= outputting;
if (stack.getCount() == 0){
stacks.set(i, ItemStack.EMPTY);
}
if (outputCount <= 0) {
return;
}
}
if (stack.isEmpty()) {
stacks.set(i, new ItemStack(itemStack.getItem(), outputCount));
return;
}
i++;
}
}

private LootableContainerBlockEntity getBlockEntity(BlockView world, BlockPos pos) {
return (LootableContainerBlockEntity) world.getBlockEntity(pos);
}
}

+ 64
- 0
src/main/resources/assets/ynet/blockstates/cable.json View File

@@ -0,0 +1,64 @@
{
"multipart": [
{
"apply": {
"model": "ynet:block/cable"
}
},
{
"when": {
"north": true
},
"apply": {
"model": "ynet:block/cable_side",
"x": 270
}
},
{
"when": {
"east": true
},
"apply": {
"model": "ynet:block/cable_side",
"x": 90,
"y": 270
}
},
{
"when": {
"south": true
},
"apply": {
"model": "ynet:block/cable_side",
"x": 90
}
},
{
"when": {
"west": true
},
"apply": {
"model": "ynet:block/cable_side",
"x": 90,
"y": 90
}
},
{
"when": {
"up": true
},
"apply": {
"model": "ynet:block/cable_side",
"x": 180
}
},
{
"when": {
"down": true
},
"apply": {
"model": "ynet:block/cable_side"
}
}
]
}

+ 24
- 0
src/main/resources/assets/ynet/models/block/cable.json View File

@@ -0,0 +1,24 @@
{
"credit": "Made with Blockbench",
"ambientocclusion": false,
"textures": {
"0": "ynet:block/pipe",
"particle": "ynet:block/pipe"
},
"elements": [
{
"name": "pipe_center",
"from": [5, 5, 5],
"to": [11, 11, 11],
"faces": {
"north": {"uv": [0, 0, 6, 6], "texture": "#0"},
"east": {"uv": [0, 0, 6, 6], "texture": "#0"},
"south": {"uv": [0, 0, 6, 6], "texture": "#0"},
"west": {"uv": [0, 0, 6, 6], "texture": "#0"},
"up": {"uv": [0, 0, 6, 6], "texture": "#0"},
"down": {"uv": [0, 0, 6, 6], "texture": "#0"}
}
}
],
"display": {}
}

+ 23
- 0
src/main/resources/assets/ynet/models/block/cable_side.json View File

@@ -0,0 +1,23 @@
{
"credit": "Made with Blockbench",
"ambientocclusion": false,
"textures": {
"1": "ynet:block/pipe"
},
"elements": [
{
"name": "pipe_side",
"from": [5, 0, 5],
"to": [11, 5, 11],
"faces": {
"north": {"uv": [0, 0, 6, 5], "texture": "#1"},
"east": {"uv": [0, 0, 6, 5], "texture": "#1"},
"south": {"uv": [0, 0, 6, 5], "texture": "#1"},
"west": {"uv": [0, 0, 6, 5], "texture": "#1"},
"up": {"uv": [0, 0, 6, 6], "texture": "#1"},
"down": {"uv": [0, 0, 6, 6], "texture": "#1"}
}
}
],
"display": {}
}

BIN
View File


+ 23
- 0
src/main/resources/fabric.mod.json View File

@@ -0,0 +1,23 @@
{
"schemaVersion": 1,
"id": "ynet",
"version": "${version}",
"name": "YNet",
"description": "Fabric port of XNet",
"authors": [
"Martmists"
],
"license": "MIT",
"icon": "assets/lgr/icon.png",
"entrypoints": {
"main": [
"com.martmists.ynet.YNetMod"
]
},
"mixins": [
"mod.mixins.json"
],
"depends": {
"fabricloader": ">=0.4.0"
}
}

+ 11
- 0
src/main/resources/mod.mixins.json View File

@@ -0,0 +1,11 @@
{
"required": true,
"package": "com.martmists.ynet.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"ChestBlockEntityMixin"
],
"injectors": {
"defaultRequire": 1
}
}

+ 1
- 0
versions/1.15.2/build.gradle View File

@@ -0,0 +1 @@
apply from: '../common.gradle'

+ 5
- 0
versions/1.15.2/gradle.properties View File

@@ -0,0 +1,5 @@
minecraft_version=1.15.2
yarn_mappings=1.15.2+build.14
loader_version=0.7.8+build.184
fabric_version=0.4.32+build.292-1.15
tr_slug=TechReborn-1.15:3.3.4+build.193

+ 1
- 0
versions/1.16/build.gradle View File

@@ -0,0 +1 @@
apply from: '../common.gradle'

+ 5
- 0
versions/1.16/gradle.properties View File

@@ -0,0 +1,5 @@
minecraft_version=20w10a
yarn_mappings=20w10a+build.2
loader_version=0.7.8+build.186
fabric_version=0.4.34+build.303-1.16
tr_slug=TechReborn-1.16:3.3.3+build.3

+ 60
- 0
versions/common.gradle View File

@@ -0,0 +1,60 @@
apply plugin: 'fabric-loom'
apply plugin: 'java'
apply plugin: 'idea'

sourceCompatibility = 1.8
targetCompatibility = 1.8
archivesBaseName = "${project.mod_name}-${project.mod_version}-${project.minecraft_version}"

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modCompile "TechReborn:${project.tr_slug}"
}

repositories {
maven {
name = "TechReborn"
url = "https://maven.fabricmc.net/"
}
}

processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
expand "version": project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}

setBuildDir("../../build")

sourceSets {
main {
java {
srcDirs = ["../../src/main/java"]
}
resources {
srcDirs = ["../../src/main/resources"]
}
}
}

jar {
from "LICENSE"
}

task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}

jar.dependsOn sourcesJar
build.dependsOn jar

Loading…
Cancel
Save