reverting to forge mappings from mojmap

adding create and pncr ports
This commit is contained in:
ticticboooom
2021-05-18 11:20:49 +01:00
parent 04849d3aa7
commit 4372b4214d
59 changed files with 702 additions and 335 deletions

View File

@@ -3,9 +3,11 @@ buildscript {
maven { url "https://plugins.gradle.org/m2/" } maven { url "https://plugins.gradle.org/m2/" }
maven { url = 'https://files.minecraftforge.net/maven' } maven { url = 'https://files.minecraftforge.net/maven' }
mavenCentral() mavenCentral()
maven { url "https://repo.spongepowered.org/maven/" }
} }
dependencies { dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
} }
} }
@@ -18,7 +20,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
version = '1.16.5-0.1.28-T' + System.currentTimeMillis() version = '1.16.5-0.1.31-T' + System.currentTimeMillis()
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'MasterfulMachinery' archivesBaseName = 'MasterfulMachinery'
@@ -42,7 +44,7 @@ minecraft {
// //
// Use non-default mappings at your own risk. they may not always work. // 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. // Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.16.5' mappings channel: 'snapshot', version: '20210309-1.16.5'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
@@ -64,7 +66,8 @@ minecraft {
// You can set various levels here. // You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'debug' property 'forge.logging.console.level', 'debug'
properties 'mixin.env.disableRefMap': 'true' property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
mods { mods {
masterfulmachinery { masterfulmachinery {
source sourceSets.main source sourceSets.main
@@ -86,7 +89,8 @@ minecraft {
// You can set various levels here. // You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'debug' property 'forge.logging.console.level', 'debug'
properties 'mixin.env.disableRefMap': 'true' property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
mods { mods {
masterfulmachinery { masterfulmachinery {
source sourceSets.main source sourceSets.main
@@ -103,7 +107,8 @@ minecraft {
// "REGISTRIES": For firing of registry events. // "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries. // "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.markers', 'REGISTRIES'
properties 'mixin.env.disableRefMap': 'true' property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
// Recommended logging level for the console // Recommended logging level for the console
// You can set various levels here. // You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
@@ -137,6 +142,9 @@ repositories {
includeGroup "curse.maven" includeGroup "curse.maven"
} }
} }
maven {
url 'https://repo.spongepowered.org/maven/'
}
} }
dependencies { dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
@@ -145,6 +153,7 @@ dependencies {
compileOnly 'org.projectlombok:lombok:1.18.18' compileOnly 'org.projectlombok:lombok:1.18.18'
annotationProcessor 'org.projectlombok:lombok:1.18.18' annotationProcessor 'org.projectlombok:lombok:1.18.18'
minecraft 'net.minecraftforge:forge:1.16.5-36.1.16' minecraft 'net.minecraftforge:forge:1.16.5-36.1.16'
shade 'com.github.marschall:memoryfilesystem:2.1.0' shade 'com.github.marschall:memoryfilesystem:2.1.0'
implementation fg.deobf("mekanism:Mekanism:${mekanism_version}")// core implementation fg.deobf("mekanism:Mekanism:${mekanism_version}")// core
@@ -156,6 +165,11 @@ dependencies {
// at runtime, use the full JEI jar // at runtime, use the full JEI jar
runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}")
implementation fg.deobf('me.desht.pneumaticcraft:pneumaticcraft-repressurized:1.16.5-2.12.2-186'); implementation fg.deobf('me.desht.pneumaticcraft:pneumaticcraft-repressurized:1.16.5-2.12.2-186');
implementation fg.deobf("curse.maven:create-328085:3278516")
// implementation fg.deobf("curse.maven:astral-sorcery-241721:3156477")
// implementation fg.deobf("curse.maven:curios-309927:3275653")
// You may put jars on which you depend on in ./libs or you may define them like so.. // 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:classifier"
// compile "some.group:artifact:version" // compile "some.group:artifact:version"

Binary file not shown.

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

53
gradlew vendored
View File

@@ -1,5 +1,21 @@
#!/usr/bin/env sh #!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
############################################################################## ##############################################################################
## ##
## Gradle start up script for UN*X ## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` 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. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
@@ -66,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi fi
# For Cygwin, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if $cygwin ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
else else
eval `echo args$i`="\"$arg\"" eval `echo args$i`="\"$arg\""
fi fi
i=$((i+1)) i=`expr $i + 1`
done done
case $i in case $i in
(0) set -- ;; 0) set -- ;;
(1) set -- "$args0" ;; 1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;; 2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;; 3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;; 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac esac
fi fi
@@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " " echo " "
} }
APP_ARGS=$(save "$@") APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules # 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" 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" "$@" exec "$JAVACMD" "$@"

43
gradlew.bat vendored
View File

@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @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 DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,28 +64,14 @@ echo location of your Java installation.
goto fail 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 :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @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% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

View File

@@ -67,7 +67,7 @@ public class MM {
RecipeTypes.RECIPE_SERIALIZERS.register(bus); RecipeTypes.RECIPE_SERIALIZERS.register(bus);
bus.addListener(this::clientEvents); bus.addListener(this::clientEvents);
if (FMLEnvironment.dist == Dist.CLIENT) { if (FMLEnvironment.dist == Dist.CLIENT) {
Minecraft.getInstance().getResourcePackRepository().addPackFinder(new MMPackFinder(PackType.RESOURCE)); Minecraft.getInstance().getResourcePackList().addPackFinder(new MMPackFinder(PackType.RESOURCE));
} }
MinecraftForge.EVENT_BUS.addListener(this::onServerStart); MinecraftForge.EVENT_BUS.addListener(this::onServerStart);
} }
@@ -95,30 +95,30 @@ public class MM {
} }
public void onServerStart(final FMLServerAboutToStartEvent event) { public void onServerStart(final FMLServerAboutToStartEvent event) {
event.getServer().getPackRepository().addPackFinder(new MMPackFinder(PackType.DATA)); event.getServer().getResourcePacks().addPackFinder(new MMPackFinder(PackType.DATA));
} }
private void clientEvents(final FMLClientSetupEvent event) { private void clientEvents(final FMLClientSetupEvent event) {
for (RegistryObject<ContainerType<ControllerBlockContainer>> container : MMLoader.CONTAINERS) { for (RegistryObject<ContainerType<ControllerBlockContainer>> container : MMLoader.CONTAINERS) {
ScreenManager.register(container.get(), ControllerBlockContainerScreen::new); ScreenManager.registerFactory(container.get(), ControllerBlockContainerScreen::new);
} }
for (RegistryObject<ContainerType<?>> container : MMLoader.PORT_CONTAINERS) { for (RegistryObject<ContainerType<?>> container : MMLoader.PORT_CONTAINERS) {
ScreenManager.register((ContainerType<PortBlockContainer>) container.get(), PortBlockContainerScreen::new); ScreenManager.registerFactory((ContainerType<PortBlockContainer>) container.get(), PortBlockContainerScreen::new);
} }
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) { for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.solid() || layer == RenderType.translucent()); RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
} }
for (RegistryObject<MachinePortBlock> block : MMLoader.IPORT_BLOCKS) { for (RegistryObject<MachinePortBlock> block : MMLoader.IPORT_BLOCKS) {
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.solid() || layer == RenderType.translucent()); RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
} }
for (RegistryObject<MachinePortBlock> block : MMLoader.OPORT_BLOCKS) { for (RegistryObject<MachinePortBlock> block : MMLoader.OPORT_BLOCKS) {
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.solid() || layer == RenderType.translucent()); RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
} }
RenderTypeLookup.setRenderLayer(MMSetup.PROJECTOR_BLOCK.get(), RenderType.translucent()); RenderTypeLookup.setRenderLayer(MMSetup.PROJECTOR_BLOCK.get(), RenderType.getTranslucent());
ScreenManager.register(MMSetup.STRUCTURE_CONTAINER.get(), StructureGenBlockContainerScreen::new); ScreenManager.registerFactory(MMSetup.STRUCTURE_CONTAINER.get(), StructureGenBlockContainerScreen::new);
} }
} }

View File

@@ -40,25 +40,25 @@ public class ControllerBlock extends DirectionalBlock {
private String texOverride; private String texOverride;
public ControllerBlock(RegistryObject<TileEntityType<?>> type, String name, String id, String texOverride) { public ControllerBlock(RegistryObject<TileEntityType<?>> type, String name, String id, String texOverride) {
super(AbstractBlock.Properties.of(Material.METAL) super(AbstractBlock.Properties.create(Material.IRON)
.harvestLevel(1) .harvestLevel(1)
.harvestTool(ToolType.PICKAXE)); .harvestTool(ToolType.PICKAXE));
this.type = type; this.type = type;
this.controllerName = name; this.controllerName = name;
this.controllerId = id; this.controllerId = id;
this.texOverride = texOverride; this.texOverride = texOverride;
this.registerDefaultState(this.defaultBlockState().setValue(FACING, Direction.NORTH)); this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
} }
@Override @Override
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) { protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder.add(FACING)); super.fillStateContainer(builder.add(FACING));
} }
@Nullable @Nullable
@Override @Override
public BlockState getStateForPlacement(BlockItemUseContext ctx) { public BlockState getStateForPlacement(BlockItemUseContext ctx) {
return this.defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite()); return this.getDefaultState().with(FACING, ctx.getPlacementHorizontalFacing().getOpposite());
} }
@Override @Override
@@ -73,9 +73,9 @@ public class ControllerBlock extends DirectionalBlock {
} }
@Override @Override
public ActionResultType use(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult traceResult) { public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!level.isClientSide()) { if (!worldIn.isRemote()) {
TileEntity blockEntity = level.getBlockEntity(pos); TileEntity blockEntity = worldIn.getTileEntity(pos);
if (blockEntity instanceof ControllerBlockEntity) { if (blockEntity instanceof ControllerBlockEntity) {
NetworkHooks.openGui(((ServerPlayerEntity) player), (ControllerBlockEntity)blockEntity, pos); NetworkHooks.openGui(((ServerPlayerEntity) player), (ControllerBlockEntity)blockEntity, pos);
} }

View File

@@ -20,6 +20,7 @@ import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader; import net.minecraft.world.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.RegistryObject; import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.ItemStackHandler;
@@ -38,7 +39,7 @@ public class MachinePortBlock extends Block {
private ResourceLocation overlay; private ResourceLocation overlay;
public MachinePortBlock(RegistryObject<TileEntityType<?>> type, String name, String controllerId, String textureOverride, ResourceLocation overlay) { public MachinePortBlock(RegistryObject<TileEntityType<?>> type, String name, String controllerId, String textureOverride, ResourceLocation overlay) {
super(AbstractBlock.Properties.of(Material.METAL)); super(AbstractBlock.Properties.create(Material.IRON));
this.type = type; this.type = type;
this.langName = name; this.langName = name;
this.controllerId = controllerId; this.controllerId = controllerId;
@@ -58,9 +59,9 @@ public class MachinePortBlock extends Block {
} }
@Override @Override
public ActionResultType use(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult traceResult) { public ActionResultType onBlockActivated(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult traceResult) {
if (!level.isClientSide()) { if (!level.isRemote()) {
TileEntity blockEntity = level.getBlockEntity(pos); TileEntity blockEntity = level.getTileEntity(pos);
if (blockEntity instanceof MachinePortBlockEntity) { if (blockEntity instanceof MachinePortBlockEntity) {
NetworkHooks.openGui(((ServerPlayerEntity) player), (MachinePortBlockEntity)blockEntity, pos); NetworkHooks.openGui(((ServerPlayerEntity) player), (MachinePortBlockEntity)blockEntity, pos);
} }
@@ -70,22 +71,26 @@ public class MachinePortBlock extends Block {
@Override @Override
public void onRemove(BlockState state, World world, BlockPos pos, BlockState state1, boolean p_196243_5_) { public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
TileEntity tile = world.getBlockEntity(pos); TileEntity tile = worldIn.getTileEntity(pos);
if (tile instanceof MachinePortBlockEntity){ if (tile instanceof MachinePortBlockEntity){
Object o = ((MachinePortBlockEntity) tile).getStorage().getLO().orElse(null); LazyOptional<Object> lo = ((MachinePortBlockEntity) tile).getStorage().getLO();
if (lo == null){
return;
}
Object o = lo.orElse(null);
if (o instanceof ItemStackHandler) { if (o instanceof ItemStackHandler) {
InventoryHelper.dropContents(world, pos, new ItemStackInventory((ItemStackHandler) o)); InventoryHelper.dropInventoryItems(worldIn, pos, new ItemStackInventory((ItemStackHandler) o));
} }
} }
super.onRemove(state, world, pos, state1, p_196243_5_); super.onReplaced(state, worldIn, pos, newState, isMoving);
} }
@Override @Override
public void neighborChanged(BlockState p_220069_1_, World world, BlockPos pos, Block p_220069_4_, BlockPos changedPos, boolean p_220069_6_) { public void neighborChanged(BlockState p_220069_1_, World world, BlockPos pos, Block p_220069_4_, BlockPos changedPos, boolean p_220069_6_) {
super.neighborChanged(p_220069_1_, world, pos, p_220069_4_, changedPos, p_220069_6_); super.neighborChanged(p_220069_1_, world, pos, p_220069_4_, changedPos, p_220069_6_);
TileEntity tile = world.getBlockEntity(pos); TileEntity tile = world.getTileEntity(pos);
if (tile instanceof MachinePortBlockEntity){ if (tile instanceof MachinePortBlockEntity){
((MachinePortBlockEntity) tile).getStorage().neighborChanged(); ((MachinePortBlockEntity) tile).getStorage().neighborChanged();
} }

View File

@@ -22,58 +22,58 @@ import java.util.stream.Stream;
public class ProjectorBlock extends Block { public class ProjectorBlock extends Block {
public ProjectorBlock() { public ProjectorBlock() {
super(Properties.of(Material.METAL)); super(Properties.create(Material.IRON));
this.registerDefaultState(this.defaultBlockState().setValue(FACING, Direction.NORTH)); this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
} }
private static final DirectionProperty FACING = HorizontalBlock.FACING; private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
private static final VoxelShape SHAPE_N = Stream.of( private static final VoxelShape SHAPE_N = Stream.of(
Block.box(0, 0, 0, 16, 8, 16), Block.makeCuboidShape(0, 0, 0, 16, 8, 16),
Block.box(0, 8, 0, 4, 10, 16), Block.makeCuboidShape(0, 8, 0, 4, 10, 16),
Block.box(4, 8, 8, 16, 12, 16), Block.makeCuboidShape(4, 8, 8, 16, 12, 16),
Block.box(12, 8, 0, 16, 10, 8), Block.makeCuboidShape(12, 8, 0, 16, 10, 8),
Block.box(5, 8, 1, 11, 12, 7), Block.makeCuboidShape(5, 8, 1, 11, 12, 7),
Block.box(5, 12, 9, 11, 16, 15) Block.makeCuboidShape(5, 12, 9, 11, 16, 15)
).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
private static final VoxelShape SHAPE_E = Stream.of( private static final VoxelShape SHAPE_E = Stream.of(
Block.box(0, 0, 0, 16, 8, 16), Block.makeCuboidShape(0, 0, 0, 16, 8, 16),
Block.box(0, 8, 0, 16, 10, 4), Block.makeCuboidShape(0, 8, 0, 16, 10, 4),
Block.box(0, 8, 4, 8, 12, 16), Block.makeCuboidShape(0, 8, 4, 8, 12, 16),
Block.box(8, 8, 12, 16, 10, 16), Block.makeCuboidShape(8, 8, 12, 16, 10, 16),
Block.box(9, 8, 5, 15, 12, 11), Block.makeCuboidShape(9, 8, 5, 15, 12, 11),
Block.box(1, 12, 5, 7, 16, 11) Block.makeCuboidShape(1, 12, 5, 7, 16, 11)
).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
private static final VoxelShape SHAPE_S = Stream.of( private static final VoxelShape SHAPE_S = Stream.of(
Block.box(0, 0, 0, 16, 8, 16), Block.makeCuboidShape(0, 0, 0, 16, 8, 16),
Block.box(12, 8, 0, 16, 10, 16), Block.makeCuboidShape(12, 8, 0, 16, 10, 16),
Block.box(0, 8, 0, 12, 12, 8), Block.makeCuboidShape(0, 8, 0, 12, 12, 8),
Block.box(0, 8, 8, 4, 10, 16), Block.makeCuboidShape(0, 8, 8, 4, 10, 16),
Block.box(5, 8, 9, 11, 12, 15), Block.makeCuboidShape(5, 8, 9, 11, 12, 15),
Block.box(5, 12, 1, 11, 16, 7) Block.makeCuboidShape(5, 12, 1, 11, 16, 7)
).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
private static final VoxelShape SHAPE_W = Stream.of( private static final VoxelShape SHAPE_W = Stream.of(
Block.box(0, 0, 0, 16, 8, 16), Block.makeCuboidShape(0, 0, 0, 16, 8, 16),
Block.box(0, 8, 12, 16, 10, 16), Block.makeCuboidShape(0, 8, 12, 16, 10, 16),
Block.box(8, 8, 0, 16, 12, 12), Block.makeCuboidShape(8, 8, 0, 16, 12, 12),
Block.box(0, 8, 0, 8, 10, 4), Block.makeCuboidShape(0, 8, 0, 8, 10, 4),
Block.box(1, 8, 5, 7, 12, 11), Block.makeCuboidShape(1, 8, 5, 7, 12, 11),
Block.box(9, 12, 5, 15, 16, 11) Block.makeCuboidShape(9, 12, 5, 15, 16, 11)
).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); ).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
@Override @Override
protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> builder) { protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder.add(FACING)); super.fillStateContainer(builder.add(FACING));
} }
@Nullable @Nullable
@Override @Override
public BlockState getStateForPlacement(BlockItemUseContext ctx) { public BlockState getStateForPlacement(BlockItemUseContext ctx) {
return this.defaultBlockState().setValue(FACING, ctx.getHorizontalDirection().getOpposite()); return this.getDefaultState().with(FACING, ctx.getPlacementHorizontalFacing().getOpposite());
} }
@Override @Override
@@ -89,7 +89,7 @@ public class ProjectorBlock extends Block {
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) { public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) {
switch (state.getValue(FACING)) { switch (state.get(FACING)) {
case NORTH: case NORTH:
return SHAPE_N; return SHAPE_N;
case EAST: case EAST:

View File

@@ -21,7 +21,7 @@ import javax.annotation.Nullable;
public class StructureGenBlock extends Block { public class StructureGenBlock extends Block {
public StructureGenBlock() { public StructureGenBlock() {
super(Properties.of(Material.METAL)); super(Properties.create(Material.IRON));
} }
@Override @Override
@@ -36,9 +36,9 @@ public class StructureGenBlock extends Block {
} }
@Override @Override
public ActionResultType use(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult traceResult) { public ActionResultType onBlockActivated(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult traceResult) {
if (!level.isClientSide()) { if (!level.isRemote()) {
TileEntity blockEntity = level.getBlockEntity(pos); TileEntity blockEntity = level.getTileEntity(pos);
if (blockEntity instanceof ControllerBlockEntity) { if (blockEntity instanceof ControllerBlockEntity) {
NetworkHooks.openGui(((ServerPlayerEntity) player), (StructureGenBlockEntity)blockEntity, pos); NetworkHooks.openGui(((ServerPlayerEntity) player), (StructureGenBlockEntity)blockEntity, pos);
} }

View File

@@ -34,17 +34,20 @@ public class ControllerBlockContainer extends Container {
} }
public ControllerBlockContainer(ContainerType<?> container, int windowId, PlayerInventory player, PacketBuffer buf) { public ControllerBlockContainer(ContainerType<?> container, int windowId, PlayerInventory player, PacketBuffer buf) {
this(container, windowId, player, (ControllerBlockEntity) player.player.level.getBlockEntity(buf.readBlockPos())); this(container, windowId, player, (ControllerBlockEntity) player.player.world.getTileEntity(buf.readBlockPos()));
} }
@Override @Override
public boolean stillValid(PlayerEntity p_75145_1_) { public boolean canInteractWith(PlayerEntity p_75145_1_) {
return true; return true;
} }
@Override @Override
public ItemStack quickMoveStack(PlayerEntity p_82846_1_, int p_82846_2_) { public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
} }

View File

@@ -28,11 +28,11 @@ public class PortBlockContainer extends Container {
} }
public PortBlockContainer(ContainerType<?> container, int windowId, PlayerInventory player, PacketBuffer buf) { public PortBlockContainer(ContainerType<?> container, int windowId, PlayerInventory player, PacketBuffer buf) {
this(container, windowId, player, (MachinePortBlockEntity) player.player.level.getBlockEntity(buf.readBlockPos())); this(container, windowId, player, (MachinePortBlockEntity) player.player.world.getTileEntity(buf.readBlockPos()));
} }
@Override @Override
public boolean stillValid(PlayerEntity p_75145_1_) { public boolean canInteractWith(PlayerEntity p_75145_1_) {
return true; return true;
} }
@@ -42,27 +42,27 @@ public class PortBlockContainer extends Container {
} }
@Override @Override
public ItemStack quickMoveStack(PlayerEntity p_82846_1_, int index) { public ItemStack transferStackInSlot(PlayerEntity p_82846_1_, int index) {
ItemStack itemStack = ItemStack.EMPTY; ItemStack itemStack = ItemStack.EMPTY;
Object o = tile.getStorage().getLO().orElse(null); Object o = tile.getStorage().getLO().orElse(null);
if (o instanceof ItemStackHandler) { if (o instanceof ItemStackHandler) {
ItemStackHandler handler = ((ItemStackHandler) o); ItemStackHandler handler = ((ItemStackHandler) o);
Slot slot = this.getSlot(index); Slot slot = this.getSlot(index);
if (slot.hasItem()) { if (slot.getHasStack()) {
ItemStack itemStack1 = slot.getItem(); ItemStack itemStack1 = slot.getStack();
itemStack = itemStack1.copy(); itemStack = itemStack1.copy();
if (index < handler.getSlots()) { if (index < handler.getSlots()) {
if (!this.moveItemStackTo(itemStack1, handler.getSlots(), inv.getContainerSize(), true)) { if (!this.mergeItemStack(itemStack1, handler.getSlots(), this.inventorySlots.size(), true)) {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
} else if (!this.moveItemStackTo(itemStack1, 0, handler.getSlots(), false)) { } else if (!this.mergeItemStack(itemStack1, 0, handler.getSlots(), false)) {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
if (itemStack1.isEmpty()) { if (itemStack1.isEmpty()) {
slot.set(ItemStack.EMPTY); slot.putStack(ItemStack.EMPTY);
} else { } else {
slot.setChanged(); slot.onSlotChanged();
} }
} }
} }

View File

@@ -16,11 +16,11 @@ public class ProjectorBlockContainer extends Container {
} }
@Override @Override
public boolean stillValid(PlayerEntity p_75145_1_) { public boolean canInteractWith(PlayerEntity p_75145_1_) {
return true; return true;
} }
public ProjectorBlockContainer(int w, PlayerInventory inv, PacketBuffer buf) { public ProjectorBlockContainer(int w, PlayerInventory inv, PacketBuffer buf) {
this(w, (ProjectorBlockEntity) inv.player.level.getBlockEntity(buf.readBlockPos())); this(w, (ProjectorBlockEntity) inv.player.world.getTileEntity(buf.readBlockPos()));
} }
} }

View File

@@ -17,11 +17,11 @@ public class StructureGenBlockContainer extends Container {
} }
@Override @Override
public boolean stillValid(PlayerEntity p_75145_1_) { public boolean canInteractWith(PlayerEntity p_75145_1_) {
return true; return true;
} }
public StructureGenBlockContainer(int w, PlayerInventory inv, PacketBuffer buf) { public StructureGenBlockContainer(int w, PlayerInventory inv, PacketBuffer buf) {
this(w, (StructureGenBlockEntity) inv.player.level.getBlockEntity(buf.readBlockPos())); this(w, (StructureGenBlockEntity) inv.player.world.getTileEntity(buf.readBlockPos()));
} }
} }

View File

@@ -43,13 +43,13 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
@Override @Override
public void tick() { public void tick() {
if (level.isClientSide()){ if (world.isRemote()){
return; return;
} }
update.setMsg("Failed to construct \nthe machine"); update.setMsg("Failed to construct \nthe machine");
List<MachineStructureRecipe> recipes = level.getRecipeManager().getAllRecipesFor(RecipeTypes.MACHINE_STRUCTURE); List<MachineStructureRecipe> recipes = world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_STRUCTURE);
for (MachineStructureRecipe recipe : recipes) { for (MachineStructureRecipe recipe : recipes) {
int index = recipe.matches(this.worldPosition, level, controllerId); int index = recipe.matches(this.pos, world, controllerId);
if (index != -1) { if (index != -1) {
if (!update.getSid().equals(recipe.getId().toString())){ if (!update.getSid().equals(recipe.getId().toString())){
update.setTicksTaken(0); update.setTicksTaken(0);
@@ -64,11 +64,11 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
} }
private void onStructureFound(MachineStructureRecipe structure, int index) { private void onStructureFound(MachineStructureRecipe structure, int index) {
ArrayList<BlockPos> ports = structure.getPorts(worldPosition, level, index); ArrayList<BlockPos> ports = structure.getPorts(pos, world, index);
List<PortStorage> inputPorts = new ArrayList<>(); List<PortStorage> inputPorts = new ArrayList<>();
List<PortStorage> outputPorts = new ArrayList<>(); List<PortStorage> outputPorts = new ArrayList<>();
for (BlockPos port : ports) { for (BlockPos port : ports) {
TileEntity blockEntity = level.getBlockEntity(port); TileEntity blockEntity = world.getTileEntity(port);
if (blockEntity instanceof MachinePortBlockEntity) { if (blockEntity instanceof MachinePortBlockEntity) {
MachinePortBlockEntity portBE = (MachinePortBlockEntity) blockEntity; MachinePortBlockEntity portBE = (MachinePortBlockEntity) blockEntity;
@@ -84,7 +84,7 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
} }
private void onPortsEstablished(List<PortStorage> inputPorts, List<PortStorage> outputPorts, MachineStructureRecipe structure) { private void onPortsEstablished(List<PortStorage> inputPorts, List<PortStorage> outputPorts, MachineStructureRecipe structure) {
List<MachineProcessRecipe> processRecipes = level.getRecipeManager().getAllRecipesFor(RecipeTypes.MACHINE_PROCESS); List<MachineProcessRecipe> processRecipes = world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_PROCESS);
boolean processed = false; boolean processed = false;
for (MachineProcessRecipe recipe : processRecipes) { for (MachineProcessRecipe recipe : processRecipes) {
if (recipe.matches(inputPorts, structure.getStructureId())) { if (recipe.matches(inputPorts, structure.getStructureId())) {
@@ -115,15 +115,15 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
} }
@Override @Override
public CompoundNBT save(CompoundNBT nbt) { public CompoundNBT write(CompoundNBT nbt) {
nbt.putInt("ticks", update.getTicksTaken()); nbt.putInt("ticks", update.getTicksTaken());
nbt.putString("msg", update.getMsg()); nbt.putString("msg", update.getMsg());
return super.save(nbt); return super.write(nbt);
} }
@Override @Override
public void load(BlockState p_230337_1_, CompoundNBT nbt) { public void read(BlockState p_230337_1_, CompoundNBT nbt) {
super.load(p_230337_1_, nbt); super.read(p_230337_1_, nbt);
update.setTicksTaken(nbt.getInt("ticks")); update.setTicksTaken(nbt.getInt("ticks"));
update.setMsg(nbt.getString("msg")); update.setMsg(nbt.getString("msg"));
} }

View File

@@ -47,14 +47,14 @@ public class MachinePortBlockEntity extends UpdatableTile implements ITickableTi
} }
@Override @Override
public CompoundNBT save(CompoundNBT nbt) { public CompoundNBT write(CompoundNBT nbt) {
nbt.put("inv", storage.save(new CompoundNBT())); nbt.put("inv", storage.save(new CompoundNBT()));
return super.save(nbt); return super.write(nbt);
} }
@Override @Override
public void load(BlockState state, CompoundNBT nbt) { public void read(BlockState state, CompoundNBT nbt) {
super.load(state, nbt); super.read(state, nbt);
storage.load(nbt.getCompound("inv")); storage.load(nbt.getCompound("inv"));
} }
@@ -71,6 +71,9 @@ public class MachinePortBlockEntity extends UpdatableTile implements ITickableTi
@Override @Override
public void tick() { public void tick() {
if (world.isRemote()){
return;
}
this.getStorage().tick(this); this.getStorage().tick(this);
update(); update();
} }

View File

@@ -27,18 +27,18 @@ public class StructureGenBlockEntity extends UpdatableTile implements ITickableT
private ItemStack device = ItemStack.EMPTY; private ItemStack device = ItemStack.EMPTY;
@Override @Override
public CompoundNBT save(CompoundNBT nbt) { public CompoundNBT write(CompoundNBT nbt) {
NonNullList<ItemStack> list = NonNullList.of(device); NonNullList<ItemStack> list = NonNullList.from(device);
nbt = ItemStackHelper.saveAllItems(nbt, list); nbt = ItemStackHelper.saveAllItems(nbt, list);
return super.save(nbt); return super.write(nbt);
} }
@Override @Override
public void load(BlockState p_230337_1_, CompoundNBT nbt) { public void read(BlockState p_230337_1_, CompoundNBT nbt) {
NonNullList<ItemStack> list = NonNullList.withSize(1, ItemStack.EMPTY); NonNullList<ItemStack> list = NonNullList.withSize(1, ItemStack.EMPTY);
ItemStackHelper.loadAllItems(nbt, list); ItemStackHelper.loadAllItems(nbt, list);
device = list.get(0); device = list.get(0);
super.load(p_230337_1_, nbt); super.read(p_230337_1_, nbt);
} }

View File

@@ -14,8 +14,8 @@ public class UpdatableTile extends TileEntity{
} }
public void update() { public void update() {
if (!level.isClientSide()){ if (!world.isRemote()){
PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new TileClientUpdatePacket.Data(worldPosition, save(new CompoundNBT()))); PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new TileClientUpdatePacket.Data(pos, write(new CompoundNBT())));
} }
} }
} }

View File

@@ -46,12 +46,12 @@ public class MMJeiPlugin implements IModPlugin {
@Override @Override
public void registerRecipes(IRecipeRegistration registration) { public void registerRecipes(IRecipeRegistration registration) {
ENERGY_TYPE_RENDERER.setHelpers(registration.getJeiHelpers()); ENERGY_TYPE_RENDERER.setHelpers(registration.getJeiHelpers());
List<MachineStructureRecipe> structureRecipes = Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(RecipeTypes.MACHINE_STRUCTURE); List<MachineStructureRecipe> structureRecipes = Minecraft.getInstance().world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_STRUCTURE);
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) { for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
registration.addRecipes(structureRecipes.stream().filter(x -> x.getControllerId().contains(block.get().getControllerId())).collect(Collectors.toList()), new ResourceLocation(MM.ID, "machine_structure_" + block.get().getControllerId())); registration.addRecipes(structureRecipes.stream().filter(x -> x.getControllerId().contains(block.get().getControllerId())).collect(Collectors.toList()), new ResourceLocation(MM.ID, "machine_structure_" + block.get().getControllerId()));
} }
List<MachineProcessRecipe> processRecipes = Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(RecipeTypes.MACHINE_PROCESS); List<MachineProcessRecipe> processRecipes = Minecraft.getInstance().world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_PROCESS);
for (MachineStructureRecipe structureRecipe : structureRecipes) { for (MachineStructureRecipe structureRecipe : structureRecipes) {
List<MachineProcessRecipe> recipes = processRecipes.stream().filter(x -> x.getStructureId().equals(structureRecipe.getStructureId())).collect(Collectors.toList()); List<MachineProcessRecipe> recipes = processRecipes.stream().filter(x -> x.getStructureId().equals(structureRecipe.getStructureId())).collect(Collectors.toList());
registration.addRecipes(recipes, new ResourceLocation(MM.ID, "machine_process_" + structureRecipe.getStructureId())); registration.addRecipes(recipes, new ResourceLocation(MM.ID, "machine_process_" + structureRecipe.getStructureId()));
@@ -64,7 +64,7 @@ public class MMJeiPlugin implements IModPlugin {
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) { for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
registration.addRecipeCategories(new MachineStructureRecipeCategory(registration.getJeiHelpers(), block.get())); registration.addRecipeCategories(new MachineStructureRecipeCategory(registration.getJeiHelpers(), block.get()));
} }
List<MachineStructureRecipe> structureRecipes = Minecraft.getInstance().level.getRecipeManager().getAllRecipesFor(RecipeTypes.MACHINE_STRUCTURE); List<MachineStructureRecipe> structureRecipes = Minecraft.getInstance().world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_STRUCTURE);
for (MachineStructureRecipe structureRecipe : structureRecipes) { for (MachineStructureRecipe structureRecipe : structureRecipes) {
registration.addRecipeCategories(new MachineProcessRecipeCategory(registration.getJeiHelpers(), structureRecipe.getStructureId(), structureRecipe.getName())); registration.addRecipeCategories(new MachineProcessRecipeCategory(registration.getJeiHelpers(), structureRecipe.getStructureId(), structureRecipe.getName()));
} }

View File

@@ -83,10 +83,10 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
@Override @Override
public void setIngredients(MachineStructureRecipe machineStructureRecipe, IIngredients iIngredients) { public void setIngredients(MachineStructureRecipe machineStructureRecipe, IIngredients iIngredients) {
Ingredient ingredient = Ingredient.of(new ItemStack(MMSetup.BLUEPRINT.get())); Ingredient ingredient = Ingredient.fromStacks(new ItemStack(MMSetup.BLUEPRINT.get()));
ArrayList<Ingredient> objects = new ArrayList<>(); ArrayList<Ingredient> objects = new ArrayList<>();
objects.add(ingredient); objects.add(ingredient);
objects.add(Ingredient.of(new ItemStack(ForgeRegistries.ITEMS.getValue(controller.getRegistryName())))); objects.add(Ingredient.fromStacks(new ItemStack(ForgeRegistries.ITEMS.getValue(controller.getRegistryName()))));
iIngredients.setInputIngredients(objects); iIngredients.setInputIngredients(objects);
} }
@@ -112,7 +112,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
yLastMousePosition = mouseY; yLastMousePosition = mouseY;
} }
if (GLFW.glfwGetMouseButton(mc.getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_1) != 0) { if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_1) != 0) {
double relMoveX = mouseX - xLastMousePosition; double relMoveX = mouseX - xLastMousePosition;
double relMoveY = mouseY - yLastMousePosition; double relMoveY = mouseY - yLastMousePosition;
xRotation += relMoveX; xRotation += relMoveX;
@@ -156,7 +156,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
if (!part.getBlock().equals("")) { if (!part.getBlock().equals("")) {
ResourceLocation resourceLocation = new ResourceLocation(part.getBlock()); ResourceLocation resourceLocation = new ResourceLocation(part.getBlock());
Block block = ForgeRegistries.BLOCKS.getValue(resourceLocation); Block block = ForgeRegistries.BLOCKS.getValue(resourceLocation);
BlockState defaultState = block.defaultBlockState(); BlockState defaultState = block.getDefaultState();
new GuiBlockRenderBuilder(defaultState).at(bp) new GuiBlockRenderBuilder(defaultState).at(bp)
.withPrePosition(new Vector3f(6.5f, -5, 10)) .withPrePosition(new Vector3f(6.5f, -5, 10))
.withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true)) .withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true))
@@ -173,7 +173,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
} }
} }
if (block != null) { if (block != null) {
BlockState defaultState = block.defaultBlockState().setValue(DirectionalBlock.FACING, Direction.NORTH); BlockState defaultState = block.getDefaultState().with(DirectionalBlock.FACING, Direction.NORTH);
new GuiBlockRenderBuilder(defaultState).at(new BlockPos(0, 0, 0)) new GuiBlockRenderBuilder(defaultState).at(new BlockPos(0, 0, 0))
.withPrePosition(new Vector3f(6.5f, -5, 10)) .withPrePosition(new Vector3f(6.5f, -5, 10))
.withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true)) .withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true))

View File

@@ -20,26 +20,27 @@ public class ControllerBlockContainerScreen extends ContainerScreen<ControllerBl
private static final ResourceLocation GUI = new ResourceLocation(MM.ID, "textures/gui/gui_large.png"); private static final ResourceLocation GUI = new ResourceLocation(MM.ID, "textures/gui/gui_large.png");
@Override @Override
protected void renderBg(MatrixStack stack, float p_230450_2_, int p_230450_3_, int p_230450_4_) { public void render(MatrixStack stack, int mouseX, int mouseY, float p_230430_4_) {
this.renderBackground(stack);
this.minecraft.textureManager.bind(GUI); super.render(stack, mouseX, mouseY, p_230430_4_);
this.blit(stack, this.leftPos, this.topPos - 20, 0, 0, 256, 256);
} }
@Override
public void render(MatrixStack p_230430_1_, int p_230430_2_, int p_230430_3_, float p_230430_4_) {
super.render(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_);
}
@Override @Override
protected void renderLabels(MatrixStack stack, int p_230451_2_, int p_230451_3_) { protected void drawGuiContainerForegroundLayer(MatrixStack stack, int x0, int y0) {
this.minecraft.font.drawWordWrap(container.getTile().getDisplayName(), 10, -10, 176, 0xfefefe); this.minecraft.fontRenderer.func_238418_a_(container.getTile().getDisplayName(), 10, -10, 176, 0xfefefe);
drawString(stack, this.minecraft.font, "Inventory", 7, 110, 0xfefefe); drawString(stack, this.minecraft.fontRenderer, "Inventory", 7, 110, 0xfefefe);
int y = 50; int y = 50;
for (String s : container.getTile().getUpdate().getMsg().split("\n")) { for (String s : container.getTile().getUpdate().getMsg().split("\n")) {
drawString(stack, this.minecraft.font, s, 12, y, 0xfefefe); drawString(stack, this.minecraft.fontRenderer, s, 12, y, 0xfefefe);
y += 12; y += 12;
} }
}
@Override
protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int x, int y) {
this.renderBackground(stack);
this.minecraft.textureManager.bindTexture(GUI);
this.blit(stack, this.guiLeft, this.guiTop - 20, 0, 0, 256, 256);
} }
} }

View File

@@ -18,22 +18,23 @@ public class PortBlockContainerScreen extends ContainerScreen<PortBlockContainer
} }
private static final ResourceLocation GUI = new ResourceLocation(MM.ID, "textures/gui/port_gui.png"); private static final ResourceLocation GUI = new ResourceLocation(MM.ID, "textures/gui/port_gui.png");
@Override
protected void renderBg(MatrixStack stack, float p_230450_2_, int mouseX, int mouseY) {
this.renderBackground(stack);
container.getTile().getStorage().render(stack, mouseX, mouseY, this.leftPos, this.topPos, this);
}
@Override @Override
public void render(MatrixStack p_230430_1_, int p_230430_2_, int p_230430_3_, float p_230430_4_) { public void render(MatrixStack p_230430_1_, int p_230430_2_, int p_230430_3_, float p_230430_4_) {
super.render(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_); super.render(p_230430_1_, p_230430_2_, p_230430_3_, p_230430_4_);
this.renderTooltip(p_230430_1_, p_230430_2_, p_230430_3_); this.renderHoveredTooltip(p_230430_1_, p_230430_2_, p_230430_3_);
} }
@Override @Override
protected void renderLabels(MatrixStack stack, int p_230451_2_, int p_230451_3_) { protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int x, int y) {
drawString(stack, this.minecraft.font, container.getTile().getDisplayName(), 7, 5, 0xfefefe); this.renderBackground(stack);
drawString(stack, this.minecraft.font, "Inventory", 7, 130, 0xfefefe); container.getTile().getStorage().render(stack, x, y, this.guiLeft, this.guiTop, this);
} }
@Override
protected void drawGuiContainerForegroundLayer(MatrixStack stack, int x, int y) {
drawString(stack, this.minecraft.fontRenderer, container.getTile().getDisplayName(), 7, 5, 0xfefefe);
drawString(stack, this.minecraft.fontRenderer, "Inventory", 7, 130, 0xfefefe);
}
} }

View File

@@ -14,11 +14,6 @@ public class StructureGenBlockContainerScreen extends ContainerScreen<StructureG
super(p_i51105_1_, p_i51105_2_, p_i51105_3_); super(p_i51105_1_, p_i51105_2_, p_i51105_3_);
} }
@Override
protected void renderBg(MatrixStack ms, float p_230450_2_, int p_230450_3_, int p_230450_4_) {
Minecraft.getInstance().textureManager.bind(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
blit(ms, leftPos, topPos, 0, 0, 175, 256);
}
@Override @Override
public void render(MatrixStack ms, int p_230430_2_, int p_230430_3_, float p_230430_4_) { public void render(MatrixStack ms, int p_230430_2_, int p_230430_3_, float p_230430_4_) {
@@ -26,4 +21,10 @@ public class StructureGenBlockContainerScreen extends ContainerScreen<StructureG
} }
@Override
protected void drawGuiContainerBackgroundLayer(MatrixStack ms, float partialTicks, int x, int y) {
Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
blit(ms, guiLeft, guiTop, 0, 0, 175, 256);
}
} }

View File

@@ -65,8 +65,8 @@ public class FluidRenderer {
private void drawTiledSprite(MatrixStack matrixStack, int xPosition, int yPosition, int width, int height, int color, int scaledAmount, TextureAtlasSprite sprite) { private void drawTiledSprite(MatrixStack matrixStack, int xPosition, int yPosition, int width, int height, int color, int scaledAmount, TextureAtlasSprite sprite) {
Minecraft minecraft = Minecraft.getInstance(); Minecraft minecraft = Minecraft.getInstance();
minecraft.getTextureManager().bind(PlayerContainer.BLOCK_ATLAS); minecraft.getTextureManager().bindTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE);
Matrix4f matrix = matrixStack.last().pose(); Matrix4f matrix = matrixStack.getLast().getMatrix();
setGLColorFromInt(color); setGLColorFromInt(color);
final int xTileCount = width / TEX_WIDTH; final int xTileCount = width / TEX_WIDTH;
@@ -93,21 +93,21 @@ public class FluidRenderer {
} }
private void drawTextureWithMasking(Matrix4f matrix, int x, int y, TextureAtlasSprite sprite, int maskTop, int maskRight, int z) { private void drawTextureWithMasking(Matrix4f matrix, int x, int y, TextureAtlasSprite sprite, int maskTop, int maskRight, int z) {
float uMin = sprite.getU0(); float uMin = sprite.getMinU();
float uMax = sprite.getU1(); float uMax = sprite.getMaxU();
float vMin = sprite.getV0(); float vMin = sprite.getMinV();
float vMax = sprite.getV1(); float vMax = sprite.getMaxV();
uMax = uMax - (maskRight / 16F * (uMax - uMin)); uMax = uMax - (maskRight / 16F * (uMax - uMin));
vMax = vMax - (maskTop / 16F * (vMax - vMin)); vMax = vMax - (maskTop / 16F * (vMax - vMin));
Tessellator tessellator = Tessellator.getInstance(); Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuilder(); BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX); bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferBuilder.vertex(matrix, x, y + 16, z).uv(uMin, vMax).endVertex(); bufferBuilder.pos(matrix, x, y + 16, z).tex(uMin, vMax).endVertex();
bufferBuilder.vertex(matrix, x + 16 - maskRight, y + 16, z).uv(uMax, vMax).endVertex(); bufferBuilder.pos(matrix, x + 16 - maskRight, y + 16, z).tex(uMax, vMax).endVertex();
bufferBuilder.vertex(matrix, x + 16 - maskRight, y + maskTop, z).uv(uMax, vMin).endVertex(); bufferBuilder.pos(matrix, x + 16 - maskRight, y + maskTop, z).tex(uMax, vMin).endVertex();
bufferBuilder.vertex(matrix, x, y + maskTop, z).uv(uMin, vMin).endVertex(); bufferBuilder.pos(matrix, x, y + maskTop, z).tex(uMin, vMin).endVertex();
tessellator.end(); tessellator.draw();
} }
private static void setGLColorFromInt(int color) { private static void setGLColorFromInt(int color) {
@@ -124,6 +124,6 @@ public class FluidRenderer {
Fluid fluid = stack.getFluid(); Fluid fluid = stack.getFluid();
FluidAttributes attributes = fluid.getAttributes(); FluidAttributes attributes = fluid.getAttributes();
ResourceLocation fluidStill = attributes.getStillTexture(stack); ResourceLocation fluidStill = attributes.getStillTexture(stack);
return minecraft.getTextureAtlas(PlayerContainer.BLOCK_ATLAS).apply(fluidStill); return minecraft.getAtlasSpriteGetter(PlayerContainer.LOCATION_BLOCKS_TEXTURE).apply(fluidStill);
} }
} }

View File

@@ -34,7 +34,7 @@ public class GuiBlockRenderBuilder {
public GuiBlockRenderBuilder(BlockState blockState) { public GuiBlockRenderBuilder(BlockState blockState) {
this.blockState = blockState; this.blockState = blockState;
position = new BlockPos(0, 0, 0); position = new BlockPos(0, 0, 0);
tile = blockState.createTileEntity(Minecraft.getInstance().level); tile = blockState.createTileEntity(Minecraft.getInstance().world);
if (tile != null) { if (tile != null) {
ter = TileEntityRendererDispatcher.instance.getRenderer(tile); ter = TileEntityRendererDispatcher.instance.getRenderer(tile);
} }
@@ -64,7 +64,7 @@ public class GuiBlockRenderBuilder {
RenderSystem.enableBlend(); RenderSystem.enableBlend();
RenderSystem.enableRescaleNormal(); RenderSystem.enableRescaleNormal();
RenderSystem.enableAlphaTest(); RenderSystem.enableAlphaTest();
RenderHelper.setupFor3DItems(); RenderHelper.setupGui3DDiffuseLighting();
RenderSystem.alphaFunc(516, 0.1F); RenderSystem.alphaFunc(516, 0.1F);
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
@@ -77,24 +77,24 @@ public class GuiBlockRenderBuilder {
public void finalize(MatrixStack ms) { public void finalize(MatrixStack ms) {
prepareRender(); prepareRender();
IRenderTypeBuffer.Impl buf = mc.renderBuffers().bufferSource(); IRenderTypeBuffer.Impl buf = mc.getRenderTypeBuffers().getBufferSource();
BlockRendererDispatcher brd = Minecraft.getInstance().getBlockRenderer(); BlockRendererDispatcher brd = Minecraft.getInstance().getBlockRendererDispatcher();
ms.pushPose(); ms.push();
transformMatrix(ms); transformMatrix(ms);
brd.renderBlock(blockState, ms, buf, 0xF000F0, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE); brd.renderBlock(blockState, ms, buf, 0xF000F0, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
if (ter != null) { if (ter != null) {
ter.render(tile, 1.0f, ms, buf, 0, 1); ter.render(tile, 1.0f, ms, buf, 0, 1);
} }
buf.endBatch(); buf.finish();
ms.popPose(); ms.pop();
cleanupRender(); cleanupRender();
} }
private void transformMatrix(MatrixStack ms) { private void transformMatrix(MatrixStack ms) {
ms.scale(scale.x(), scale.y(), scale.z()); ms.scale(scale.getX(), scale.getY(), scale.getZ());
ms.translate(prePosition.x(), prePosition.y(), prePosition.z()); ms.translate(prePosition.getX(), prePosition.getY(), prePosition.getZ());
for (Quaternion quaternion : orderedRotation) { for (Quaternion quaternion : orderedRotation) {
ms.mulPose(quaternion); ms.rotate(quaternion);
} }
ms.translate(position.getX(), position.getY(), position.getZ()); ms.translate(position.getX(), position.getY(), position.getZ());
} }

View File

@@ -175,17 +175,17 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
} }
@Override @Override
public ItemStack assemble(IInventory p_77572_1_) { public ItemStack getCraftingResult(IInventory inv) {
return null; return null;
} }
@Override @Override
public boolean canCraftInDimensions(int p_194133_1_, int p_194133_2_) { public boolean canFit(int p_194133_1_, int p_194133_2_) {
return false; return false;
} }
@Override @Override
public ItemStack getResultItem() { public ItemStack getRecipeOutput() {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
@@ -208,7 +208,7 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
@SneakyThrows @SneakyThrows
@Override @Override
public MachineProcessRecipe fromJson(ResourceLocation rl, JsonObject obj) { public MachineProcessRecipe read(ResourceLocation rl, JsonObject obj) {
int ticks = obj.get("ticks").getAsInt(); int ticks = obj.get("ticks").getAsInt();
String structureId = obj.get("structureId").getAsString(); String structureId = obj.get("structureId").getAsString();
JsonArray inputs = obj.get("inputs").getAsJsonArray(); JsonArray inputs = obj.get("inputs").getAsJsonArray();
@@ -255,11 +255,11 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
@Nullable @Nullable
@Override @Override
public MachineProcessRecipe fromNetwork(ResourceLocation rl, PacketBuffer buf) { public MachineProcessRecipe read(ResourceLocation rl, PacketBuffer buf) {
int inputCount = buf.readInt(); int inputCount = buf.readInt();
int outputCount = buf.readInt(); int outputCount = buf.readInt();
int ticks = buf.readInt(); int ticks = buf.readInt();
String structureId = buf.readUtf(); String structureId = buf.readString();
List<PortState> inputs = getStates(buf, inputCount); List<PortState> inputs = getStates(buf, inputCount);
List<PortState> outputs = getStates(buf, outputCount); List<PortState> outputs = getStates(buf, outputCount);
return new MachineProcessRecipe(inputs, outputs, ticks, structureId, rl); return new MachineProcessRecipe(inputs, outputs, ticks, structureId, rl);
@@ -268,7 +268,7 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
private List<PortState> getStates(PacketBuffer buf, int count) { private List<PortState> getStates(PacketBuffer buf, int count) {
List<PortState> result = new ArrayList<>(); List<PortState> result = new ArrayList<>();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
String inpType = buf.readUtf(); String inpType = buf.readString();
boolean perTick = buf.readBoolean(); boolean perTick = buf.readBoolean();
double chance = buf.readDouble(); double chance = buf.readDouble();
MasterfulPortType value = MMPorts.PORTS.get(RLUtils.toRL(inpType)); MasterfulPortType value = MMPorts.PORTS.get(RLUtils.toRL(inpType));
@@ -281,11 +281,11 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
} }
@Override @Override
public void toNetwork(PacketBuffer buf, MachineProcessRecipe recipe) { public void write(PacketBuffer buf, MachineProcessRecipe recipe) {
buf.writeInt(recipe.inputs.size()); buf.writeInt(recipe.inputs.size());
buf.writeInt(recipe.outputs.size()); buf.writeInt(recipe.outputs.size());
buf.writeInt(recipe.ticks); buf.writeInt(recipe.ticks);
buf.writeUtf(recipe.structureId); buf.writeString(recipe.structureId);
writeStates(buf, recipe.inputs); writeStates(buf, recipe.inputs);
writeStates(buf, recipe.outputs); writeStates(buf, recipe.outputs);
@@ -294,7 +294,7 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
private void writeStates(PacketBuffer buf, List<PortState> states) { private void writeStates(PacketBuffer buf, List<PortState> states) {
for (PortState state : states) { for (PortState state : states) {
MasterfulPortType value = MMPorts.PORTS.get(state.getName()); MasterfulPortType value = MMPorts.PORTS.get(state.getName());
buf.writeUtf(value.getRegistryName().toString()); buf.writeString(value.getRegistryName().toString());
buf.writeBoolean(state.isConsumePerTick()); buf.writeBoolean(state.isConsumePerTick());
buf.writeDouble(state.getChance()); buf.writeDouble(state.getChance());
value.getParser().write(buf, state); value.getParser().write(buf, state);

View File

@@ -87,12 +87,12 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
} }
@Override @Override
public ItemStack assemble(IInventory p_77572_1_) { public ItemStack getCraftingResult(IInventory p_77572_1_) {
return null; return null;
} }
@Override @Override
public boolean canCraftInDimensions(int p_194133_1_, int p_194133_2_) { public boolean canFit(int p_194133_1_, int p_194133_2_) {
return false; return false;
} }
@@ -122,7 +122,7 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
private boolean innerBlockMatch(BlockPos controllerPos, World world, MachineStructureRecipeKeyModel model) { private boolean innerBlockMatch(BlockPos controllerPos, World world, MachineStructureRecipeKeyModel model) {
BlockPos pos = controllerPos.offset(model.getPos().getX(), model.getPos().getY(), model.getPos().getZ()); BlockPos pos = controllerPos.add(model.getPos().getX(), model.getPos().getY(), model.getPos().getZ());
BlockState blockState = world.getBlockState(pos); BlockState blockState = world.getBlockState(pos);
boolean valid = false; boolean valid = false;
if (!model.getTag().equals("")) { if (!model.getTag().equals("")) {
@@ -131,7 +131,7 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
MM.LOG.fatal("too many : (colons) in structure tag: {}", model.getTag()); MM.LOG.fatal("too many : (colons) in structure tag: {}", model.getTag());
return false; return false;
} }
ITag<Block> tag = BlockTags.getAllTags().getTag(new ResourceLocation(split[0], split[1])); ITag<Block> tag = BlockTags.getCollection().get(new ResourceLocation(split[0], split[1]));
if (tag == null) { if (tag == null) {
MM.LOG.fatal("no existing block tag for structure tag: {}", model.getTag()); MM.LOG.fatal("no existing block tag for structure tag: {}", model.getTag());
return false; return false;
@@ -153,8 +153,8 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
return true; return true;
} }
try { try {
CompoundNBT compoundNBT = JsonToNBT.parseTag(model.getNbt()); CompoundNBT compoundNBT = JsonToNBT.getTagFromJson(model.getNbt());
TileEntity blockEntity = world.getBlockEntity(pos); TileEntity blockEntity = world.getTileEntity(pos);
return compoundNBT.equals(blockEntity.getTileData()); return compoundNBT.equals(blockEntity.getTileData());
} catch (CommandSyntaxException e) { } catch (CommandSyntaxException e) {
@@ -166,7 +166,7 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
public ArrayList<BlockPos> getPorts(BlockPos controllerPos, World world, int index) { public ArrayList<BlockPos> getPorts(BlockPos controllerPos, World world, int index) {
ArrayList<BlockPos> result = new ArrayList<>(); ArrayList<BlockPos> result = new ArrayList<>();
for (MachineStructureRecipeKeyModel model : models.get(index)) { for (MachineStructureRecipeKeyModel model : models.get(index)) {
BlockPos pos = controllerPos.offset(model.getPos().toVector()); BlockPos pos = controllerPos.add(model.getPos().toVector());
BlockState state = world.getBlockState(pos); BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof MachinePortBlock) { if (state.getBlock() instanceof MachinePortBlock) {
result.add(pos); result.add(pos);
@@ -180,7 +180,7 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
} }
@Override @Override
public ItemStack getResultItem() { public ItemStack getRecipeOutput() {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
@@ -204,7 +204,7 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
@Override @Override
public MachineStructureRecipe fromJson(ResourceLocation rl, JsonObject obj) { public MachineStructureRecipe read(ResourceLocation rl, JsonObject obj) {
JsonElement controllerIdJson = obj.get("controllerId"); JsonElement controllerIdJson = obj.get("controllerId");
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
if (controllerIdJson.isJsonPrimitive()){ if (controllerIdJson.isJsonPrimitive()){
@@ -287,16 +287,16 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
@SneakyThrows @SneakyThrows
@Nullable @Nullable
@Override @Override
public MachineStructureRecipe fromNetwork(ResourceLocation rl, PacketBuffer buf) { public MachineStructureRecipe read(ResourceLocation rl, PacketBuffer buf) {
List<String> controllerId = new ArrayList<>(); List<String> controllerId = new ArrayList<>();
int idCount = buf.readInt(); int idCount = buf.readInt();
for (int i = 0; i < idCount; i++) { for (int i = 0; i < idCount; i++) {
controllerId.add(buf.readUtf()); controllerId.add(buf.readString());
} }
String id = buf.readUtf(); String id = buf.readString();
String name = buf.readUtf(); String name = buf.readString();
try { try {
MachineStructureObject machineStructureObject = buf.readWithCodec(MachineStructureObject.CODEC); MachineStructureObject machineStructureObject = buf.func_240628_a_(MachineStructureObject.CODEC);
List<MachineStructureRecipeKeyModel> models = machineStructureObject.getInner(); List<MachineStructureRecipeKeyModel> models = machineStructureObject.getInner();
return new MachineStructureRecipe(models, controllerId, id, rl, name); return new MachineStructureRecipe(models, controllerId, id, rl, name);
} catch (Exception e) { } catch (Exception e) {
@@ -306,15 +306,15 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
} }
@Override @Override
public void toNetwork(PacketBuffer buf, MachineStructureRecipe recipe) { public void write(PacketBuffer buf, MachineStructureRecipe recipe) {
buf.writeInt(recipe.controllerId.size()); buf.writeInt(recipe.controllerId.size());
for (String s : recipe.controllerId) { for (String s : recipe.controllerId) {
buf.writeUtf(s); buf.writeString(s);
} }
buf.writeUtf(recipe.id); buf.writeString(recipe.id);
buf.writeUtf(recipe.name); buf.writeString(recipe.name);
try { try {
buf.writeWithCodec(MachineStructureObject.CODEC, new MachineStructureObject(recipe.getModels().get(0))); buf.func_240629_a_(MachineStructureObject.CODEC, new MachineStructureObject(recipe.getModels().get(0)));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -365,6 +365,5 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
} }
} }
} }
} }
} }

View File

@@ -5,6 +5,7 @@ import net.minecraft.util.ResourceLocation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random;
public class MockedNamedTag<T> implements ITag.INamedTag<T> { public class MockedNamedTag<T> implements ITag.INamedTag<T> {
private final ResourceLocation name; private final ResourceLocation name;
@@ -24,7 +25,12 @@ public class MockedNamedTag<T> implements ITag.INamedTag<T> {
} }
@Override @Override
public List<T> getValues() { public List<T> getAllElements() {
return new ArrayList<>(); return new ArrayList<>();
} }
@Override
public T getRandomElement(Random random) {
return INamedTag.super.getRandomElement(random);
}
} }

View File

@@ -9,6 +9,7 @@ import net.minecraft.resources.data.IMetadataSectionSerializer;
import net.minecraft.util.JSONUtils; import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files; import java.nio.file.Files;
@@ -27,17 +28,17 @@ public class InMemoryPack implements IResourcePack {
} }
private static String getFullPath(ResourcePackType type, ResourceLocation location) { private static String getFullPath(ResourcePackType type, ResourceLocation location) {
return String.format("%s/%s/%s", type.getDirectory(), location.getNamespace(), location.getPath()); return String.format("%s/%s/%s", type.getDirectoryName(), location.getNamespace(), location.getPath());
} }
@Override @Override
public InputStream getRootResource(String fileName) throws IOException { public InputStream getRootResourceStream(String fileName) throws IOException {
Path resolved = path.resolve(fileName); Path resolved = path.resolve(fileName);
return Files.newInputStream(resolved); return Files.newInputStream(resolved);
} }
@Override @Override
public InputStream getResource(ResourcePackType type, ResourceLocation location) throws IOException { public InputStream getResourceStream(ResourcePackType type, ResourceLocation location) throws IOException {
Path resolved = path.resolve(getFullPath(type, location)); Path resolved = path.resolve(getFullPath(type, location));
if (!Files.exists(resolved)){ if (!Files.exists(resolved)){
throw new IOException("Resource does not exist"); throw new IOException("Resource does not exist");
@@ -46,9 +47,9 @@ public class InMemoryPack implements IResourcePack {
} }
@Override @Override
public Collection<ResourceLocation> getResources(ResourcePackType type, String namespaceIn, String pathIn, int maxDepthIn, Predicate<String> filterIn) { public Collection<ResourceLocation> getAllResourceLocations(ResourcePackType type, String namespaceIn, String pathIn, int maxDepthIn, Predicate<String> filterIn) {
List<ResourceLocation> result = new ArrayList<>(); List<ResourceLocation> result = new ArrayList<>();
getChildResourceLocations(result, 0, maxDepthIn, filterIn, path.resolve(type.getDirectory() + "/" + namespaceIn + "/" + pathIn), namespaceIn, pathIn); getChildResourceLocations(result, 0, maxDepthIn, filterIn, path.resolve(type.getDirectoryName() + "/" + namespaceIn + "/" + pathIn), namespaceIn, pathIn);
return result; return result;
} }
@@ -75,16 +76,16 @@ public class InMemoryPack implements IResourcePack {
@Override @Override
public boolean hasResource(ResourcePackType type, ResourceLocation location) { public boolean resourceExists(ResourcePackType type, ResourceLocation location) {
Path finalPath = path.resolve(type.getDirectory() + "/" + location.getNamespace() + "/" + location.getPath()); Path finalPath = path.resolve(type.getDirectoryName() + "/" + location.getNamespace() + "/" + location.getPath());
return Files.exists(finalPath); return Files.exists(finalPath);
} }
@Override @Override
public Set<String> getNamespaces(ResourcePackType type) { public Set<String> getResourceNamespaces(ResourcePackType type) {
Set<String> result = new HashSet<>(); Set<String> result = new HashSet<>();
try { try {
Stream<Path> list = Files.list(path.resolve(type.getDirectory())); Stream<Path> list = Files.list(path.resolve(type.getDirectoryName()));
for (Path resultingPath : list.collect(Collectors.toList())) { for (Path resultingPath : list.collect(Collectors.toList())) {
result.add(resultingPath.getFileName().toString()); result.add(resultingPath.getFileName().toString());
} }
@@ -95,26 +96,27 @@ public class InMemoryPack implements IResourcePack {
return result; return result;
} }
public <T> T getMetadataSection(IMetadataSectionSerializer<T> deserializer) throws IOException { public <T> T getMetadata(IMetadataSectionSerializer<T> deserializer) throws IOException {
JsonObject jsonobject = new JsonObject(); JsonObject jsonobject = new JsonObject();
JsonObject packObject = new JsonObject(); JsonObject packObject = new JsonObject();
packObject.addProperty("pack_format", 6); packObject.addProperty("pack_format", 6);
packObject.addProperty("description", "emendatusenigmatica"); packObject.addProperty("description", "masterfulmachinery");
jsonobject.add("pack", packObject); jsonobject.add("pack", packObject);
if (!jsonobject.has(deserializer.getMetadataSectionName())) { if (!jsonobject.has(deserializer.getSectionName())) {
return null; return null;
} else { } else {
try { try {
return deserializer.fromJson(JSONUtils.getAsJsonObject(jsonobject, deserializer.getMetadataSectionName())); return deserializer.deserialize(JSONUtils.getJsonObject(jsonobject, deserializer.getSectionName()));
} catch (JsonParseException jsonparseexception) { } catch (JsonParseException jsonparseexception) {
return null; return null;
} }
} }
} }
@Override @Override
public String getName() { public String getName() {
return "In Memory Pack"; return "MM Memory Pack";
} }
@Override @Override

View File

@@ -43,11 +43,11 @@ public class MMPackFinder implements IPackFinder {
@Override @Override
public void loadPacks(Consumer<ResourcePackInfo> infoConsumer, ResourcePackInfo.IFactory infoFactory) { public void findPacks(Consumer<ResourcePackInfo> infoConsumer, ResourcePackInfo.IFactory infoFactory) {
Path rootPath = MemoryDataGeneratorFactory.ROOT_PATH; Path rootPath = MemoryDataGeneratorFactory.ROOT_PATH;
ResourcePackInfo pack = ResourcePackInfo.create("mm_" + type.getSuffix(), true, ResourcePackInfo pack = ResourcePackInfo.createResourcePack("mm_" + type.getSuffix(), true,
() -> new InMemoryPack(rootPath), infoFactory, ResourcePackInfo.Priority.TOP, IPackNameDecorator.DEFAULT); () -> new InMemoryPack(rootPath), infoFactory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.PLAIN);
if (pack != null) { if (pack != null) {
infoConsumer.accept(pack); infoConsumer.accept(pack);
} }

View File

@@ -24,7 +24,7 @@ public class MockedNamedTag<T> implements ITag.INamedTag<T> {
} }
@Override @Override
public List<T> getValues() { public List<T> getAllElements() {
return new ArrayList<>(); return new ArrayList<>();
} }
} }

View File

@@ -70,7 +70,7 @@ public class MMBlockStateProvider extends BlockStateProvider {
.end() .end()
.end() .end()
.customLoader(MultiLayerModelBuilder::begin) .customLoader(MultiLayerModelBuilder::begin)
.submodel(RenderType.solid(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block"))) .submodel(RenderType.getSolid(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
.texture("base", baseTexture) .texture("base", baseTexture)
.element() .element()
.from(0, 0, 0) .from(0, 0, 0)
@@ -79,7 +79,7 @@ public class MMBlockStateProvider extends BlockStateProvider {
//.allFaces((dir, uv) -> uv.uvs(0F,0.0F, 16F,16F)) //.allFaces((dir, uv) -> uv.uvs(0F,0.0F, 16F,16F))
.end() .end()
) )
.submodel(RenderType.translucent(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block"))) .submodel(RenderType.getTranslucent(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
.texture("overlay", overlayTexture) .texture("overlay", overlayTexture)
.element() .element()
.from(0, 0, 0) .from(0, 0, 0)
@@ -108,7 +108,7 @@ public class MMBlockStateProvider extends BlockStateProvider {
.end() .end()
.end() .end()
.customLoader(MultiLayerModelBuilder::begin) .customLoader(MultiLayerModelBuilder::begin)
.submodel(RenderType.solid(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block"))) .submodel(RenderType.getSolid(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
.texture("base", baseTexture) .texture("base", baseTexture)
.element() .element()
.from(0, 0, 0) .from(0, 0, 0)
@@ -117,7 +117,7 @@ public class MMBlockStateProvider extends BlockStateProvider {
//.allFaces((dir, uv) -> uv.uvs(0F,0.0F, 16F,16F)) //.allFaces((dir, uv) -> uv.uvs(0F,0.0F, 16F,16F))
.end() .end()
) )
.submodel(RenderType.translucent(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block"))) .submodel(RenderType.getTranslucent(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
.texture("overlay", overlayTexture) .texture("overlay", overlayTexture)
.element() .element()
.from(0, 0, 0) .from(0, 0, 0)

View File

@@ -4,10 +4,10 @@ import net.minecraft.util.ResourceLocation;
public class RLUtils { public class RLUtils {
public static ResourceLocation toRL(String str) { public static ResourceLocation toRL(String str) {
return ResourceLocation.tryParse(str); return ResourceLocation.tryCreate(str);
} }
public static boolean isRL(String str) { public static boolean isRL(String str) {
return ResourceLocation.tryParse(str) != null; return ResourceLocation.tryCreate(str) != null;
} }
} }

View File

@@ -15,7 +15,7 @@ public class ItemStackInventory implements IInventory {
} }
@Override @Override
public int getContainerSize() { public int getSizeInventory() {
return handler.getSlots(); return handler.getSlots();
} }
@@ -25,38 +25,39 @@ public class ItemStackInventory implements IInventory {
} }
@Override @Override
public ItemStack getItem(int p_70301_1_) { public ItemStack getStackInSlot(int p_70301_1_) {
return handler.getStackInSlot(p_70301_1_); return handler.getStackInSlot(p_70301_1_);
} }
@Override @Override
public ItemStack removeItem(int p_70298_1_, int p_70298_2_) { public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
ItemStack stackInSlot = handler.getStackInSlot(p_70298_1_); ItemStack stackInSlot = handler.getStackInSlot(p_70298_1_);
handler.setStackInSlot(p_70298_1_, ItemStack.EMPTY); handler.setStackInSlot(p_70298_1_, ItemStack.EMPTY);
return stackInSlot; return stackInSlot;
} }
@Override @Override
public ItemStack removeItemNoUpdate(int p_70304_1_) { public ItemStack removeStackFromSlot(int p_70304_1_) {
return handler.getStackInSlot(p_70304_1_); return handler.getStackInSlot(p_70304_1_);
} }
@Override @Override
public void setItem(int p_70299_1_, ItemStack p_70299_2_) { public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
handler.setStackInSlot(p_70299_1_, p_70299_2_); handler.setStackInSlot(p_70299_1_, p_70299_2_);
} }
@Override @Override
public void setChanged() { public void markDirty() {
} }
@Override @Override
public boolean stillValid(PlayerEntity p_70300_1_) { public boolean isUsableByPlayer(PlayerEntity player) {
return true; return true;
} }
@Override @Override
public void clearContent() { public void clear() {
} }
} }

View File

@@ -46,15 +46,15 @@ public class PortMekGasInventory implements IGasHandler, IGasTank {
@Override @Override
public GasStack insertChemical(int i, GasStack stack, Action action) { public GasStack insertChemical(int i, GasStack stack, Action action) {
if (!isValid(i, stack)) { if (!isValid(i, stack)) {
return GasStack.EMPTY; return GasStack.EMPTY;
} }
if (action.simulate()) { if (action.simulate()) {
if (this.stack.getAmount() + stack.getAmount() > capacity) { if (this.stack.getAmount() + stack.getAmount() > capacity) {
return new GasStack(stack.getType(), stack.getAmount() - (this.stack.getAmount() + stack.getAmount() - capacity)); return new GasStack(stack.getType(), (this.stack.getAmount() + stack.getAmount() - capacity));
} else { } else {
return stack; return GasStack.EMPTY;
} }
} }
@@ -65,14 +65,14 @@ public class PortMekGasInventory implements IGasHandler, IGasTank {
} else { } else {
this.stack.setAmount(capacity); this.stack.setAmount(capacity);
} }
return new GasStack(stack.getType(), preAmount + stack.getAmount() - capacity); return new GasStack(stack.getType(), (preAmount + stack.getAmount() - capacity));
} else { } else {
if (this.stack.isEmpty()) { if (this.stack.isEmpty()) {
this.stack = new GasStack(stack.getType(), this.stack.getAmount() + stack.getAmount()); this.stack = new GasStack(stack.getType(), stack.getAmount());
} else { } else {
this.stack.setAmount(this.stack.getAmount() + stack.getAmount()); this.stack.setAmount(this.stack.getAmount() + stack.getAmount());
} }
return stack; return GasStack.EMPTY;
} }
} }

View File

@@ -56,7 +56,7 @@ public class PortMekSlurryInventory implements ISlurryHandler, ISlurryTank {
if (this.stack.getAmount() + stack.getAmount() > capacity) { if (this.stack.getAmount() + stack.getAmount() > capacity) {
return new SlurryStack(stack.getType(), this.stack.getAmount() + stack.getAmount() - capacity); return new SlurryStack(stack.getType(), this.stack.getAmount() + stack.getAmount() - capacity);
} else { } else {
return stack; return SlurryStack.EMPTY;
} }
} }
@@ -74,7 +74,7 @@ public class PortMekSlurryInventory implements ISlurryHandler, ISlurryTank {
} else { } else {
this.stack.setAmount(this.stack.getAmount() + stack.getAmount()); this.stack.setAmount(this.stack.getAmount() + stack.getAmount());
} }
return stack; return SlurryStack.EMPTY;
} }
} }

View File

@@ -15,13 +15,14 @@ import net.minecraft.world.World;
public class StructureGenSelectionDevice extends Item { public class StructureGenSelectionDevice extends Item {
public StructureGenSelectionDevice() { public StructureGenSelectionDevice() {
super(new Item.Properties().tab(MMLoader.MASTERFUL_ITEM_GROUP)); super(new Item.Properties().group(MMLoader.MASTERFUL_ITEM_GROUP));
} }
@Override @Override
public ActionResultType useOn(ItemUseContext ctx) { public ActionResultType onItemUse(ItemUseContext ctx) {
BlockPos clickedPos = ctx.getClickedPos(); BlockPos clickedPos = ctx.getPos();
ItemStack iih = ctx.getItemInHand(); ItemStack iih = ctx.getItem();
CompoundNBT tag = iih.getTag(); CompoundNBT tag = iih.getTag();
if (tag == null) { if (tag == null) {
tag = new CompoundNBT(); tag = new CompoundNBT();

View File

@@ -23,21 +23,21 @@ public class TileClientUpdatePacket {
public static void encode(Data data, PacketBuffer buffer){ public static void encode(Data data, PacketBuffer buffer){
buffer.writeBlockPos(data.getPos()); buffer.writeBlockPos(data.getPos());
buffer.writeNbt(data.nbt); buffer.writeCompoundTag(data.nbt);
} }
public static Data decode(PacketBuffer buffer){ public static Data decode(PacketBuffer buffer){
return new Data(buffer.readBlockPos(), buffer.readNbt()); return new Data(buffer.readBlockPos(), buffer.readCompoundTag());
} }
} }
public static void handle(Data data, Supplier<NetworkEvent.Context> ctx) { public static void handle(Data data, Supplier<NetworkEvent.Context> ctx) {
ctx.get().enqueueWork(() -> { ctx.get().enqueueWork(() -> {
ClientWorld level = Minecraft.getInstance().level; ClientWorld level = Minecraft.getInstance().world;
TileEntity blockEntity = level.getBlockEntity(data.getPos()); TileEntity blockEntity = level.getTileEntity(data.getPos());
BlockState state = level.getBlockState(data.getPos()); BlockState state = level.getBlockState(data.getPos());
if (blockEntity != null) { if (blockEntity != null) {
blockEntity.load(state, data.nbt); blockEntity.read(state, data.nbt);
} }
}); });
ctx.get().setPacketHandled(true); ctx.get().setPacketHandled(true);

View File

@@ -33,7 +33,7 @@ public class EnergyPortParser implements IPortFactory {
@SneakyThrows @SneakyThrows
@Override @Override
public void write(PacketBuffer buf, PortState state) { public void write(PacketBuffer buf, PortState state) {
buf.writeWithCodec(EnergyPortState.CODEC, ((EnergyPortState) state)); buf.func_240629_a_(EnergyPortState.CODEC, ((EnergyPortState) state));
} }
@Override @Override
@@ -59,6 +59,6 @@ public class EnergyPortParser implements IPortFactory {
@Override @Override
@SneakyThrows @SneakyThrows
public PortState createState(PacketBuffer buf) { public PortState createState(PacketBuffer buf) {
return buf.readWithCodec(EnergyPortState.CODEC); return buf.func_240628_a_(EnergyPortState.CODEC);
} }
} }

View File

@@ -32,7 +32,7 @@ public class FluidPortParser implements IPortFactory {
@SneakyThrows @SneakyThrows
@Override @Override
public void write(PacketBuffer buf, PortState state) { public void write(PacketBuffer buf, PortState state) {
buf.writeWithCodec(FluidPortState.CODEC, ((FluidPortState) state)); buf.func_240629_a_(FluidPortState.CODEC, ((FluidPortState) state));
} }
@Override @Override
@@ -53,7 +53,7 @@ public class FluidPortParser implements IPortFactory {
@Override @Override
@SneakyThrows @SneakyThrows
public PortState createState(PacketBuffer buf) { public PortState createState(PacketBuffer buf) {
return buf.readWithCodec(FluidPortState.CODEC); return buf.func_240628_a_(FluidPortState.CODEC);
} }
@Override @Override

View File

@@ -44,7 +44,7 @@ public class ItemPortParser implements IPortFactory {
@SneakyThrows @SneakyThrows
@Override @Override
public void write(PacketBuffer buf, PortState state) { public void write(PacketBuffer buf, PortState state) {
buf.writeWithCodec(ItemPortState.CODEC, ((ItemPortState) state)); buf.func_240629_a_(ItemPortState.CODEC, ((ItemPortState) state));
} }
@Override @Override
@@ -56,7 +56,7 @@ public class ItemPortParser implements IPortFactory {
@SneakyThrows @SneakyThrows
@Override @Override
public PortState createState(PacketBuffer buf) { public PortState createState(PacketBuffer buf) {
return buf.readWithCodec(ItemPortState.CODEC); return buf.func_240628_a_(ItemPortState.CODEC);
} }
@Override @Override
public ResourceLocation getInputOverlay() { public ResourceLocation getInputOverlay() {

View File

@@ -42,7 +42,7 @@ public class MekGasPortParser implements IPortFactory {
@SneakyThrows @SneakyThrows
@Override @Override
public PortState createState(PacketBuffer buf) { public PortState createState(PacketBuffer buf) {
return buf.readWithCodec(MekGasPortState.CODEC); return buf.func_240628_a_(MekGasPortState.CODEC);
} }
@Override @Override
@@ -56,7 +56,7 @@ public class MekGasPortParser implements IPortFactory {
@SneakyThrows @SneakyThrows
@Override @Override
public void write(PacketBuffer buf, PortState state) { public void write(PacketBuffer buf, PortState state) {
buf.writeWithCodec(MekGasPortState.CODEC, (MekGasPortState)state); buf.func_240629_a_(MekGasPortState.CODEC, (MekGasPortState)state);
} }
@Override @Override

View File

@@ -42,7 +42,7 @@ public class MekSlurryPortParser implements IPortFactory {
@SneakyThrows @SneakyThrows
@Override @Override
public PortState createState(PacketBuffer buf) { public PortState createState(PacketBuffer buf) {
return buf.readWithCodec(MekSlurryPortState.CODEC); return buf.func_240628_a_(MekSlurryPortState.CODEC);
} }
@Override @Override
@@ -56,7 +56,7 @@ public class MekSlurryPortParser implements IPortFactory {
@SneakyThrows @SneakyThrows
@Override @Override
public void write(PacketBuffer buf, PortState state) { public void write(PacketBuffer buf, PortState state) {
buf.writeWithCodec(MekSlurryPortState.CODEC, (MekSlurryPortState)state); buf.func_240629_a_(MekSlurryPortState.CODEC, (MekSlurryPortState)state);
} }
@Override @Override

View File

@@ -36,7 +36,7 @@ public class PneumaticPortParser implements IPortFactory{
@SneakyThrows @SneakyThrows
@Override @Override
public void write(PacketBuffer buf, PortState state) { public void write(PacketBuffer buf, PortState state) {
buf.writeWithCodec(PneumaticPortState.CODEC, ((PneumaticPortState) state)); buf.func_240629_a_(PneumaticPortState.CODEC, ((PneumaticPortState) state));
} }
@Override @Override
@@ -67,6 +67,6 @@ public class PneumaticPortParser implements IPortFactory{
@Override @Override
@SneakyThrows @SneakyThrows
public PortState createState(PacketBuffer buf) { public PortState createState(PacketBuffer buf) {
return buf.readWithCodec(PneumaticPortState.CODEC); return buf.func_240628_a_(PneumaticPortState.CODEC);
} }
} }

View File

@@ -0,0 +1,61 @@
package com.ticticboooom.mods.mm.ports.parser;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.JsonOps;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.category.MMJeiPlugin;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.ports.state.PneumaticPortState;
import com.ticticboooom.mods.mm.ports.state.PortState;
import com.ticticboooom.mods.mm.ports.state.RotationPortState;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import com.ticticboooom.mods.mm.ports.storage.RotationPortStorage;
import lombok.SneakyThrows;
import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ResourceLocation;
import java.util.List;
import java.util.function.Supplier;
public class RotationPortParser implements IPortFactory{
@Override
public Supplier<PortStorage> createStorage(JsonObject obj) {
return RotationPortStorage::new;
}
@SneakyThrows
@Override
public void write(PacketBuffer buf, PortState state) {
buf.func_240629_a_(RotationPortState.CODEC, ((RotationPortState) state));
}
@Override
public void setIngredients(IIngredients ingredients, List<?> stacks, boolean input) {
}
@Override
public ResourceLocation getInputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/create_rotation_cutout");
}
@Override
public ResourceLocation getOutputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/create_rotation_cutout");
}
@Override
public PortState createState(JsonObject obj) {
DataResult<Pair<RotationPortState, JsonElement>> apply = JsonOps.INSTANCE.withDecoder(RotationPortState.CODEC).apply(obj);
return apply.result().get().getFirst();
}
@Override
@SneakyThrows
public PortState createState(PacketBuffer buf) {
return buf.func_240628_a_(RotationPortState.CODEC);
}
}

View File

@@ -70,7 +70,7 @@ public class ItemPortState extends PortState {
current -= amount; current -= amount;
} }
} else if (!tag.equals("")) { } else if (!tag.equals("")) {
if (ItemTags.getAllTags().getTag(RLUtils.toRL(tag)).contains(stackInSlot.getItem())) { if (ItemTags.getCollection().get(RLUtils.toRL(tag)).contains(stackInSlot.getItem())) {
int amount = stackInSlot.getCount(); int amount = stackInSlot.getCount();
stackInSlot.setCount(amount - (amount - current < 0 ? amount : current)); stackInSlot.setCount(amount - (amount - current < 0 ? amount : current));
current -= amount; current -= amount;
@@ -102,7 +102,7 @@ public class ItemPortState extends PortState {
current -= stackInSlot.getCount(); current -= stackInSlot.getCount();
} }
} else if (!tag.equals("")) { } else if (!tag.equals("")) {
ITag<Item> tag = ItemTags.getAllTags().getTag(RLUtils.toRL(this.tag)); ITag<Item> tag = ItemTags.getCollection().get(RLUtils.toRL(this.tag));
if (tag != null && tag.contains(stackInSlot.getItem())) { if (tag != null && tag.contains(stackInSlot.getItem())) {
current -= stackInSlot.getCount(); current -= stackInSlot.getCount();
} }
@@ -216,11 +216,11 @@ public class ItemPortState extends PortState {
if (!item.equals("") && RLUtils.isRL(item)) { if (!item.equals("") && RLUtils.isRL(item)) {
return (List<T>) ImmutableList.of(new ItemStack(ForgeRegistries.ITEMS.getValue(RLUtils.toRL(item)), this.count)); return (List<T>) ImmutableList.of(new ItemStack(ForgeRegistries.ITEMS.getValue(RLUtils.toRL(item)), this.count));
} else if (!tag.equals("") && RLUtils.isRL(tag)) { } else if (!tag.equals("") && RLUtils.isRL(tag)) {
ITag<Item> tag = ItemTags.getAllTags().getTag(RLUtils.toRL(this.tag)); ITag<Item> tag = ItemTags.getCollection().get(RLUtils.toRL(this.tag));
assert tag != null; assert tag != null;
List<ItemStack> stacks = new ArrayList<>(); List<ItemStack> stacks = new ArrayList<>();
tag.getValues().forEach(z -> stacks.add(new ItemStack(z, this.count))); tag.getAllElements().forEach(z -> stacks.add(new ItemStack(z, this.count)));
return (List<T>)stacks; return (List<T>)stacks;
} }
return new ArrayList<>(); return new ArrayList<>();
@@ -232,9 +232,9 @@ public class ItemPortState extends PortState {
if (!item.equals("") && RLUtils.isRL(item)) { if (!item.equals("") && RLUtils.isRL(item)) {
layout.getItemStacks().set(typeIndex, new ItemStack(ForgeRegistries.ITEMS.getValue(RLUtils.toRL(item)), this.count)); layout.getItemStacks().set(typeIndex, new ItemStack(ForgeRegistries.ITEMS.getValue(RLUtils.toRL(item)), this.count));
} else if (!tag.equals("") && RLUtils.isRL(tag)) { } else if (!tag.equals("") && RLUtils.isRL(tag)) {
ITag<Item> tag = ItemTags.getAllTags().getTag(RLUtils.toRL(this.tag)); ITag<Item> tag = ItemTags.getCollection().get(RLUtils.toRL(this.tag));
assert tag != null; assert tag != null;
Stream<ItemStack> itemStackStream = tag.getValues().stream().map(z -> new ItemStack(z.getItem(), this.count)); Stream<ItemStack> itemStackStream = tag.getAllElements().stream().map(z -> new ItemStack(z.getItem(), this.count));
layout.getItemStacks().set(typeIndex, itemStackStream.collect(Collectors.toList())); layout.getItemStacks().set(typeIndex, itemStackStream.collect(Collectors.toList()));
} }
if (this.getChance() < 1){ if (this.getChance() < 1){

View File

@@ -84,8 +84,8 @@ public class MekGasPortState extends PortState {
if (st instanceof MekGasPortStorage) { if (st instanceof MekGasPortStorage) {
MekGasPortStorage gasStorage = (MekGasPortStorage) st; MekGasPortStorage gasStorage = (MekGasPortStorage) st;
GasStack extract = gasStorage.getInv().insertChemical(new GasStack(Objects.requireNonNull(MekanismAPI.gasRegistry().getValue(RLUtils.toRL(gas))), current), Action.EXECUTE); GasStack extract = gasStorage.getInv().insertChemical(new GasStack(Objects.requireNonNull(MekanismAPI.gasRegistry().getValue(RLUtils.toRL(gas))), current), Action.EXECUTE);
current -= extract.getAmount(); current -= current - extract.getAmount();
if (current <= 0){ if (current <= 0) {
return; return;
} }
} }
@@ -99,7 +99,7 @@ public class MekGasPortState extends PortState {
if (st instanceof MekGasPortStorage) { if (st instanceof MekGasPortStorage) {
MekGasPortStorage gasStorage = (MekGasPortStorage) st; MekGasPortStorage gasStorage = (MekGasPortStorage) st;
GasStack extract = gasStorage.getInv().insertChemical(new GasStack(Objects.requireNonNull(MekanismAPI.gasRegistry().getValue(RLUtils.toRL(gas))), current), Action.SIMULATE); GasStack extract = gasStorage.getInv().insertChemical(new GasStack(Objects.requireNonNull(MekanismAPI.gasRegistry().getValue(RLUtils.toRL(gas))), current), Action.SIMULATE);
current -= extract.getAmount(); current -= current - extract.getAmount();
if (current <= 0) { if (current <= 0) {
return true; return true;
} }

View File

@@ -0,0 +1,89 @@
package com.ticticboooom.mods.mm.ports.state;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.category.MMJeiPlugin;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import com.ticticboooom.mods.mm.ports.storage.RotationPortStorage;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredientType;
import net.minecraft.util.ResourceLocation;
import java.util.ArrayList;
import java.util.List;
public class RotationPortState extends PortState {
public static final Codec<RotationPortState> CODEC = RecordCodecBuilder.create(x -> x.group(
Codec.FLOAT.fieldOf("speed").forGetter(z -> z.speed)
).apply(x, RotationPortState::new));
private float speed;
public RotationPortState(float pressure) {
this.speed = pressure;
}
@Override
public void processRequirement(List<PortStorage> storage) {
}
@Override
public boolean validateRequirement(List<PortStorage> storage) {
for (PortStorage portStorage : storage) {
if (portStorage instanceof RotationPortStorage){
RotationPortStorage rot = (RotationPortStorage) portStorage;
if (rot.getSpeed() >= speed) {
return true;
}
}
}
return false;
}
@Override
public void processResult(List<PortStorage> storage) {
for (PortStorage portStorage : storage) {
if (portStorage instanceof RotationPortStorage){
RotationPortStorage rot = (RotationPortStorage) portStorage;
rot.setSpeed(speed);
}
}
}
@Override
public boolean validateResult(List<PortStorage> storage) {
return true;
}
@Override
public ResourceLocation getName() {
return new ResourceLocation(MM.ID, "create_rotation");
}
@Override
public IIngredientType<?> getJeiIngredientType() {
return MMJeiPlugin.PRESSURE_TYPE;
}
@Override
public <T> List<T> getIngredient(boolean input) {
return new ArrayList<>();
}
@Override
public void setupRecipe(IRecipeLayout layout, Integer typeIndex, int x, int y, boolean input) {
}
@Override
public void render(MatrixStack ms, int x, int y, int mouseX, int mouseY, IJeiHelpers helpers) {
IDrawableStatic slot = helpers.getGuiHelper().getSlotDrawable();
slot.draw(ms, x, y);
}
}

View File

@@ -0,0 +1,42 @@
package com.ticticboooom.mods.mm.ports.storage;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.block.tile.MachinePortBlockEntity;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
public class AstralStarlightPortStorage extends PortStorage {
@Override
public <T> LazyOptional<T> getLO() {
return null;
}
@Override
public <T> boolean validate(Capability<T> cap) {
return false;
}
@Override
public CompoundNBT save(CompoundNBT nbt) {
return null;
}
@Override
public void load(CompoundNBT nbt) {
}
@Override
public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) {
}
@Override
public void tick(MachinePortBlockEntity tile) {
}
}

View File

@@ -58,7 +58,7 @@ public class EnergyPortStorage extends PortStorage {
@Override @Override
public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) { public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) {
Minecraft.getInstance().textureManager.bind(new ResourceLocation(MM.ID, "textures/gui/port_gui.png")); Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
screen.blit(stack, left, top, 0, 0, 175, 256); screen.blit(stack, left, top, 0, 0, 175, 256);
int barOffsetX = 175 - 30; int barOffsetX = 175 - 30;
int barOffsetY = 20; int barOffsetY = 20;
@@ -68,7 +68,7 @@ public class EnergyPortStorage extends PortStorage {
amount = (float)inv.getEnergyStored() / inv.getMaxEnergyStored(); amount = (float)inv.getEnergyStored() / inv.getMaxEnergyStored();
} }
screen.blit(stack, left + barOffsetX, top + barOffsetY, 193, 18, 18, (int) (108 * amount)); screen.blit(stack, left + barOffsetX, top + barOffsetY, 193, 18, 18, (int) (108 * amount));
AbstractGui.drawString(stack, Minecraft.getInstance().font,Math.round((float)10000 * amount) / 100.f + "%", left + 30, top + 60, 0xfefefe); AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer,Math.round((float)10000 * amount) / 100.f + "%", left + 30, top + 60, 0xfefefe);
AbstractGui.drawString(stack, Minecraft.getInstance().font,inv.getEnergyStored() + "FE", left + 30, top + 80, 0xfefefe); AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer, inv.getEnergyStored() + "FE", left + 30, top + 80, 0xfefefe);
} }
} }

View File

@@ -59,13 +59,13 @@ public class FluidPortStorage extends PortStorage {
@Override @Override
public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) { public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) {
Minecraft.getInstance().textureManager.bind(new ResourceLocation(MM.ID, "textures/gui/port_gui.png")); Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
screen.blit(stack, left, top, 0, 0, 175, 256); screen.blit(stack, left, top, 0, 0, 175, 256);
int x = 78; int x = 78;
int y = 40; int y = 40;
screen.blit(stack, left + x, top + y, 175, 0, 18, 18); screen.blit(stack, left + x, top + y, 175, 0, 18, 18);
FluidRenderer.INSTANCE.render(stack, left + x + 1, top + y + 1, inv.getFluidInTank(0), 16); FluidRenderer.INSTANCE.render(stack, left + x + 1, top + y + 1, inv.getFluidInTank(0), 16);
AbstractGui.drawCenteredString(stack, Minecraft.getInstance().font, inv.getFluidInTank(0).getAmount() + " " + inv.getFluidInTank(0).getDisplayName().getString(), left + x + 9 + 1, top + y + 30, 0xfefefe); AbstractGui.drawCenteredString(stack, Minecraft.getInstance().fontRenderer, inv.getFluidInTank(0).getAmount() + " " + inv.getFluidInTank(0).getDisplayName().getString(), left + x + 9 + 1, top + y + 30, 0xfefefe);
} }
} }

View File

@@ -67,7 +67,7 @@ public class ItemPortStorage extends PortStorage {
@Override @Override
public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) { public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) {
Minecraft.getInstance().textureManager.bind(new ResourceLocation(MM.ID, "textures/gui/port_gui.png")); Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
screen.blit(stack, left, top, 0, 0, 175, 256); screen.blit(stack, left, top, 0, 0, 175, 256);
int offsetY = ((108 - (rows * 18)) / 2) + 7; int offsetY = ((108 - (rows * 18)) / 2) + 7;
int offsetX = ((162 - (columns * 18)) / 2) + 7; int offsetX = ((162 - (columns * 18)) / 2) + 7;

View File

@@ -66,7 +66,7 @@ public class MekGasPortStorage extends PortStorage {
@Override @Override
public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) { public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) {
Minecraft.getInstance().textureManager.bind(new ResourceLocation(MM.ID, "textures/gui/port_gui.png")); Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
screen.blit(stack, left, top, 0, 0, 175, 256); screen.blit(stack, left, top, 0, 0, 175, 256);
int barOffsetX = 175 - 30; int barOffsetX = 175 - 30;
int barOffsetY = 20; int barOffsetY = 20;
@@ -76,8 +76,8 @@ public class MekGasPortStorage extends PortStorage {
amount = (float)inv.getStack().getAmount() / inv.getTankCapacity(0); amount = (float)inv.getStack().getAmount() / inv.getTankCapacity(0);
} }
screen.blit(stack, left + barOffsetX, top + barOffsetY, 193, 18, 18, (int) (108 * amount)); screen.blit(stack, left + barOffsetX, top + barOffsetY, 193, 18, 18, (int) (108 * amount));
AbstractGui.drawString(stack, Minecraft.getInstance().font,inv.getStack().getType().getTextComponent().getString(), left + 30, top + 60, 0xfefefe); AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer,inv.getStack().getType().getTextComponent().getString(), left + 30, top + 60, 0xfefefe);
AbstractGui.drawString(stack, Minecraft.getInstance().font, inv.getStack().getAmount() + "mB", left + 30, top + 80, 0xfefefe); AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer, inv.getStack().getAmount() + "mB", left + 30, top + 80, 0xfefefe);
} }
} }

View File

@@ -67,7 +67,7 @@ public class MekSlurryPortStorage extends PortStorage {
@Override @Override
public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) { public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) {
Minecraft.getInstance().textureManager.bind(new ResourceLocation(MM.ID, "textures/gui/port_gui.png")); Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
screen.blit(stack, left, top, 0, 0, 175, 256); screen.blit(stack, left, top, 0, 0, 175, 256);
int barOffsetX = 175 - 30; int barOffsetX = 175 - 30;
int barOffsetY = 20; int barOffsetY = 20;
@@ -77,8 +77,8 @@ public class MekSlurryPortStorage extends PortStorage {
amount = (float) inv.getStack().getAmount() / inv.getTankCapacity(0); amount = (float) inv.getStack().getAmount() / inv.getTankCapacity(0);
} }
screen.blit(stack, left + barOffsetX, top + barOffsetY, 193, 18, 18, (int) (108 * amount)); screen.blit(stack, left + barOffsetX, top + barOffsetY, 193, 18, 18, (int) (108 * amount));
AbstractGui.drawString(stack, Minecraft.getInstance().font, inv.getStack().getType().getTextComponent().getString(), left + 30, top + 60, 0xfefefe); AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer, inv.getStack().getType().getTextComponent().getString(), left + 30, top + 60, 0xfefefe);
AbstractGui.drawString(stack, Minecraft.getInstance().font, inv.getStack().getAmount() + "mB", left + 30, top + 80, 0xfefefe); AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer, inv.getStack().getAmount() + "mB", left + 30, top + 80, 0xfefefe);
} }
} }

View File

@@ -74,14 +74,18 @@ public class PneumaticPortStorage extends PortStorage {
@Override @Override
public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) { public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) {
Minecraft.getInstance().textureManager.bind(new ResourceLocation(MM.ID, "textures/gui/port_gui.png")); Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
screen.blit(stack, left, top, 0, 0, 175, 256); screen.blit(stack, left, top, 0, 0, 175, 256);
int barOffsetX = 175 - 30; int barOffsetX = 175 - 30;
int barOffsetY = 20; int barOffsetY = 20;
screen.blit(stack, left + barOffsetX, top + barOffsetY, 175, 18, 18, 108); screen.blit(stack, left + barOffsetX, top + barOffsetY, 175, 18, 18, 108);
AbstractGui.drawString(stack, Minecraft.getInstance().font, NumberFormat.getInstance().format(inv.getPressure()) + "P", left + 30, top + 60, 0xfefefe); float amount = inv.getPressure() / inv.getCriticalPressure();
} screen.blit(stack, left + barOffsetX, top + barOffsetY, 193, 18, 18, (int) (108 * amount));
AbstractGui.drawString(stack, Minecraft.getInstance().fontRenderer, NumberFormat.getInstance().format(inv.getPressure()) + "P", left + 30, top + 60, 0xfefefe);
AbstractGui.drawCenteredString(stack, Minecraft.getInstance().fontRenderer, inv.getAir() + " Air", left + mouseX + 9 + 1, top + mouseY + 30, 0xfefefe);
}
@Override @Override
public void tick(MachinePortBlockEntity tile) { public void tick(MachinePortBlockEntity tile) {
this.inv.tick(tile); this.inv.tick(tile);

View File

@@ -0,0 +1,115 @@
package com.ticticboooom.mods.mm.ports.storage;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.KineticNetwork;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.block.tile.MachinePortBlockEntity;
import lombok.Getter;
import lombok.Setter;
import me.desht.pneumaticcraft.api.PNCCapabilities;
import me.desht.pneumaticcraft.api.tileentity.IAirHandlerMachine;
import me.desht.pneumaticcraft.common.capabilities.MachineAirHandler;
import me.desht.pneumaticcraft.common.util.DirectionUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class RotationPortStorage extends PortStorage {
@Getter
@Setter
private float speed;
private HashMap<Direction, KineticTileEntity> kinetics = new HashMap<>();
public RotationPortStorage() {
neighborChanged();
}
@Override
public <T> LazyOptional<T> getLO() {
return null;
}
@Override
public <T> boolean validate(Capability<T> cap) {
return false;
}
@Override
public CompoundNBT save(CompoundNBT nbt) {
nbt.putFloat("speed", speed);
return nbt;
}
@Override
public void load(CompoundNBT nbt) {
speed = nbt.getFloat("speed");
}
@Override
public void render(MatrixStack stack, int mouseX, int mouseY, int left, int top, Screen screen) {
Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
screen.blit(stack, left, top, 0, 0, 175, 256);
AbstractGui.drawCenteredString(stack, Minecraft.getInstance().fontRenderer, speed + " Speed", left + 60, top + 30, 0xfefefe);
}
@Override
public void tick(MachinePortBlockEntity tile) {
BlockPos blockPos = tile.getPos();
World level = tile.getWorld();
HashMap<Direction, TileEntity> tiles = new HashMap<>();
tiles.put(Direction.EAST, level.getTileEntity(blockPos.add(1, 0, 0)));
tiles.put(Direction.WEST, level.getTileEntity(blockPos.add(-1, 0, 0)));
tiles.put(Direction.UP, level.getTileEntity(blockPos.add(0, 1, 0)));
tiles.put(Direction.DOWN, level.getTileEntity(blockPos.add(0, -1, 0)));
tiles.put(Direction.NORTH, level.getTileEntity(blockPos.add(0, 0, 1)));
tiles.put(Direction.SOUTH, level.getTileEntity(blockPos.add(0, 0, -1)));
speed = 0;
if (tile.isInput()) {
for (Map.Entry<Direction, TileEntity> tileEntity : tiles.entrySet()) {
if (tileEntity.getValue() instanceof KineticTileEntity) {
KineticTileEntity te = (KineticTileEntity) tileEntity.getValue();
if (Math.abs(te.getSpeed()) > speed){
speed = Math.abs(te.getSpeed());
}
}
}
} else {
for (Map.Entry<Direction, TileEntity> tileEntity : tiles.entrySet()) {
if (tileEntity.getValue() instanceof KineticTileEntity) {
KineticTileEntity te = (KineticTileEntity) tileEntity.getValue();
if (speed == 0){
te.detachKinetics();
te.setSpeed(0);
te.setNetwork(null);
} else {
te.setSpeed(speed);
te.setNetwork(te.getPos().toLong());
te.attachKinetics();
}
te.notifyUpdate();
}
}
}
}
}

View File

@@ -35,7 +35,7 @@ public class MMLoader {
public static final ItemGroup MASTERFUL_ITEM_GROUP = new ItemGroup(MM.ID) { public static final ItemGroup MASTERFUL_ITEM_GROUP = new ItemGroup(MM.ID) {
@Override @Override
public ItemStack makeIcon() { public ItemStack createIcon() {
return new ItemStack(MMSetup.BLUEPRINT.get()); return new ItemStack(MMSetup.BLUEPRINT.get());
} }
}; };
@@ -69,8 +69,8 @@ public class MMLoader {
Registerable<RegistryObject<ContainerType<ControllerBlockContainer>>> cont = new Registerable<>(); Registerable<RegistryObject<ContainerType<ControllerBlockContainer>>> cont = new Registerable<>();
cont.set(MMSetup.CONTAINER_REG.register(controllerId + "_controller", () -> IForgeContainerType.create((i, o, u) -> new ControllerBlockContainer(cont.get().get(), i, o, u)))); cont.set(MMSetup.CONTAINER_REG.register(controllerId + "_controller", () -> IForgeContainerType.create((i, o, u) -> new ControllerBlockContainer(cont.get().get(), i, o, u))));
controllerBlock.set(MMSetup.BLOCKS_REG.register(controllerId + "_controller", () -> new ControllerBlock(controllerTile.get(), controllerName, controllerId, textureOverrideFinal))); controllerBlock.set(MMSetup.BLOCKS_REG.register(controllerId + "_controller", () -> new ControllerBlock(controllerTile.get(), controllerName, controllerId, textureOverrideFinal)));
controllerTile.set(MMSetup.TILES_REG.register(controllerId + "_controller", () -> TileEntityType.Builder.of(() -> new ControllerBlockEntity(controllerTile.get(), cont.get(), controllerId), controllerBlock.get().get()).build(null))); controllerTile.set(MMSetup.TILES_REG.register(controllerId + "_controller", () -> TileEntityType.Builder.create(() -> new ControllerBlockEntity(controllerTile.get(), cont.get(), controllerId), controllerBlock.get().get()).build(null)));
MMSetup.ITEMS_REG.register(controllerId + "_controller", () -> new BlockItem(controllerBlock.get().get(), new Item.Properties().tab(MASTERFUL_ITEM_GROUP))); MMSetup.ITEMS_REG.register(controllerId + "_controller", () -> new BlockItem(controllerBlock.get().get(), new Item.Properties().group(MASTERFUL_ITEM_GROUP)));
BLOCKS.add(controllerBlock.get()); BLOCKS.add(controllerBlock.get());
CONTAINERS.add(cont.get()); CONTAINERS.add(cont.get());
} }
@@ -98,8 +98,8 @@ public class MMLoader {
Registerable<RegistryObject<ContainerType<?>>> cont = new Registerable<>(); Registerable<RegistryObject<ContainerType<?>>> cont = new Registerable<>();
cont.set(MMSetup.CONTAINER_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> IForgeContainerType.create((i, o, u) -> new PortBlockContainer(cont.get().get(), i, o, u)))); cont.set(MMSetup.CONTAINER_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> IForgeContainerType.create((i, o, u) -> new PortBlockContainer(cont.get().get(), i, o, u))));
block.set(MMSetup.BLOCKS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> new MachinePortBlock(tile.get(), name, controllerId, portTextureOverrideFinal, value.getParser().getInputOverlay()))); block.set(MMSetup.BLOCKS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> new MachinePortBlock(tile.get(), name, controllerId, portTextureOverrideFinal, value.getParser().getInputOverlay())));
tile.set(MMSetup.TILES_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> TileEntityType.Builder.of(() -> new MachinePortBlockEntity(tile.get().get(),cont.get().get(), data.get(), true), block.get().get()).build(null))); tile.set(MMSetup.TILES_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> TileEntityType.Builder.create(() -> new MachinePortBlockEntity(tile.get().get(),cont.get().get(), data.get(), true), block.get().get()).build(null)));
MMSetup.ITEMS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> new BlockItem(block.get().get(), new Item.Properties().tab(MASTERFUL_ITEM_GROUP))); MMSetup.ITEMS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_input", () -> new BlockItem(block.get().get(), new Item.Properties().group(MASTERFUL_ITEM_GROUP)));
PORT_CONTAINERS.add(cont.get()); PORT_CONTAINERS.add(cont.get());
IPORT_BLOCKS.add(block.get()); IPORT_BLOCKS.add(block.get());
} }
@@ -110,8 +110,8 @@ public class MMLoader {
Registerable<RegistryObject<ContainerType<?>>> cont = new Registerable<>(); Registerable<RegistryObject<ContainerType<?>>> cont = new Registerable<>();
cont.set(MMSetup.CONTAINER_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> IForgeContainerType.create((i, o, u) -> new PortBlockContainer(cont.get().get(), i, o, u)))); cont.set(MMSetup.CONTAINER_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> IForgeContainerType.create((i, o, u) -> new PortBlockContainer(cont.get().get(), i, o, u))));
block.set(MMSetup.BLOCKS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> new MachinePortBlock(tile.get(), name, controllerId, portTextureOverrideFinal, value.getParser().getOutputOverlay()))); block.set(MMSetup.BLOCKS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> new MachinePortBlock(tile.get(), name, controllerId, portTextureOverrideFinal, value.getParser().getOutputOverlay())));
tile.set(MMSetup.TILES_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> TileEntityType.Builder.of(() -> new MachinePortBlockEntity(tile.get().get(), cont.get().get(), data.get(), false), block.get().get()).build(null))); tile.set(MMSetup.TILES_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> TileEntityType.Builder.create(() -> new MachinePortBlockEntity(tile.get().get(), cont.get().get(), data.get(), false), block.get().get()).build(null)));
MMSetup.ITEMS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> new BlockItem(block.get().get(), new Item.Properties().tab(MASTERFUL_ITEM_GROUP))); MMSetup.ITEMS_REG.register(controllerId + "_" + id + "_port_" + resourceLocation.getPath() + "_output", () -> new BlockItem(block.get().get(), new Item.Properties().group(MASTERFUL_ITEM_GROUP)));
PORT_CONTAINERS.add(cont.get()); PORT_CONTAINERS.add(cont.get());
OPORT_BLOCKS.add(block.get()); OPORT_BLOCKS.add(block.get());
} }

View File

@@ -18,5 +18,6 @@ public class MMPorts {
PORTS.put(new ResourceLocation(MM.ID, "mekanism_gas"),new MasterfulPortType(new ResourceLocation(MM.ID, "mekanism_gas"), new MekGasPortParser())); PORTS.put(new ResourceLocation(MM.ID, "mekanism_gas"),new MasterfulPortType(new ResourceLocation(MM.ID, "mekanism_gas"), new MekGasPortParser()));
PORTS.put(new ResourceLocation(MM.ID, "mekanism_slurry"),new MasterfulPortType(new ResourceLocation(MM.ID, "mekanism_slurry"), new MekSlurryPortParser())); PORTS.put(new ResourceLocation(MM.ID, "mekanism_slurry"),new MasterfulPortType(new ResourceLocation(MM.ID, "mekanism_slurry"), new MekSlurryPortParser()));
PORTS.put(new ResourceLocation(MM.ID, "pncr_pressure"),new MasterfulPortType(new ResourceLocation(MM.ID, "pncr_pressure"), new PneumaticPortParser())); PORTS.put(new ResourceLocation(MM.ID, "pncr_pressure"),new MasterfulPortType(new ResourceLocation(MM.ID, "pncr_pressure"), new PneumaticPortParser()));
PORTS.put(new ResourceLocation(MM.ID, "create_rotation"),new MasterfulPortType(new ResourceLocation(MM.ID, "create_rotation"), new RotationPortParser()));
} }
} }

View File

@@ -25,17 +25,17 @@ public class MMSetup {
public static final DeferredRegister<TileEntityType<?>> TILES_REG = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, MM.ID); public static final DeferredRegister<TileEntityType<?>> TILES_REG = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, MM.ID);
public static final DeferredRegister<ContainerType<?>> CONTAINER_REG = DeferredRegister.create(ForgeRegistries.CONTAINERS, MM.ID); public static final DeferredRegister<ContainerType<?>> CONTAINER_REG = DeferredRegister.create(ForgeRegistries.CONTAINERS, MM.ID);
public static final RegistryObject<Item> BLUEPRINT = ITEMS_REG.register("blueprint", () -> new Item(new Item.Properties().tab(MMLoader.MASTERFUL_ITEM_GROUP))); public static final RegistryObject<Item> BLUEPRINT = ITEMS_REG.register("blueprint", () -> new Item(new Item.Properties().group(MMLoader.MASTERFUL_ITEM_GROUP)));
public static final RegistryObject<TileEntityType<?>> PROJECTOR_TILE = TILES_REG.register("projector", () -> TileEntityType.Builder.of(ProjectorBlockEntity::new).build(null)); public static final RegistryObject<TileEntityType<?>> PROJECTOR_TILE = TILES_REG.register("projector", () -> TileEntityType.Builder.create(ProjectorBlockEntity::new).build(null));
public static final RegistryObject<Block> PROJECTOR_BLOCK = BLOCKS_REG.register("projector", ProjectorBlock::new); public static final RegistryObject<Block> PROJECTOR_BLOCK = BLOCKS_REG.register("projector", ProjectorBlock::new);
public static final RegistryObject<ContainerType<ProjectorBlockContainer>> PROJECTOR_CONTAINER = CONTAINER_REG.register("projector", () -> IForgeContainerType.create(ProjectorBlockContainer::new)); public static final RegistryObject<ContainerType<ProjectorBlockContainer>> PROJECTOR_CONTAINER = CONTAINER_REG.register("projector", () -> IForgeContainerType.create(ProjectorBlockContainer::new));
public static final RegistryObject<Item> PROJECTOR_ITEM = ITEMS_REG.register("projector", () -> new BlockItem(PROJECTOR_BLOCK.get(), new Item.Properties().tab(MMLoader.MASTERFUL_ITEM_GROUP))); public static final RegistryObject<Item> PROJECTOR_ITEM = ITEMS_REG.register("projector", () -> new BlockItem(PROJECTOR_BLOCK.get(), new Item.Properties().group(MMLoader.MASTERFUL_ITEM_GROUP)));
public static final RegistryObject<TileEntityType<?>> STRUCTURE_TILE = TILES_REG.register("structure_generator", () -> TileEntityType.Builder.of(StructureGenBlockEntity::new).build(null)); public static final RegistryObject<TileEntityType<?>> STRUCTURE_TILE = TILES_REG.register("structure_generator", () -> TileEntityType.Builder.create(StructureGenBlockEntity::new).build(null));
public static final RegistryObject<Block> STRUCTURE_BLOCK = BLOCKS_REG.register("structure_generator", StructureGenBlock::new); public static final RegistryObject<Block> STRUCTURE_BLOCK = BLOCKS_REG.register("structure_generator", StructureGenBlock::new);
public static final RegistryObject<ContainerType<StructureGenBlockContainer>> STRUCTURE_CONTAINER = CONTAINER_REG.register("structure_generator", () -> IForgeContainerType.create(StructureGenBlockContainer::new)); public static final RegistryObject<ContainerType<StructureGenBlockContainer>> STRUCTURE_CONTAINER = CONTAINER_REG.register("structure_generator", () -> IForgeContainerType.create(StructureGenBlockContainer::new));
public static final RegistryObject<Item> STRUCTURE_ITEM = ITEMS_REG.register("structure_generator", () -> new BlockItem(STRUCTURE_BLOCK.get(), new Item.Properties().tab(MMLoader.MASTERFUL_ITEM_GROUP))); public static final RegistryObject<Item> STRUCTURE_ITEM = ITEMS_REG.register("structure_generator", () -> new BlockItem(STRUCTURE_BLOCK.get(), new Item.Properties().group(MMLoader.MASTERFUL_ITEM_GROUP)));
public static final RegistryObject<Item> STRUCTURE_DEVICE = ITEMS_REG.register("structure_gen_device", StructureGenSelectionDevice::new); public static final RegistryObject<Item> STRUCTURE_DEVICE = ITEMS_REG.register("structure_gen_device", StructureGenSelectionDevice::new);
} }