Initial Commit
This commit is contained in:
commit
f93eac4a87
|
@ -0,0 +1,26 @@
|
|||
.DS_Store
|
||||
|
||||
/download
|
||||
/eclipseBin
|
||||
|
||||
# gradle
|
||||
/.gradle
|
||||
/build
|
||||
|
||||
# ForgeGradle
|
||||
/run
|
||||
|
||||
# eclipse
|
||||
/eclipse
|
||||
/.settings
|
||||
/.metdata
|
||||
/.classpath
|
||||
/.project
|
||||
/bin
|
||||
|
||||
# intellij
|
||||
/out
|
||||
/.idea
|
||||
/*.iml
|
||||
/*.ipr
|
||||
/*.iws
|
|
@ -0,0 +1,82 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven {
|
||||
name "forge"
|
||||
url "http://files.minecraftforge.net/maven/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath "net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "com.matthewprenger.cursegradle" version "1.0.6"
|
||||
}
|
||||
|
||||
apply plugin: "net.minecraftforge.gradle.forge"
|
||||
|
||||
version = mc_version + "-" + mod_version
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
minecraft {
|
||||
version = mc_version + "-" + forge_version
|
||||
runDir = "run"
|
||||
|
||||
mappings = mcp_mappings
|
||||
|
||||
replaceIn "Funnels.java"
|
||||
replace "@VERSION@", mod_version
|
||||
|
||||
useDepAts = true
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
from (sourceSets.main.resources.srcDirs) {
|
||||
include "mcmod.info"
|
||||
expand "version": project.version, "mcversion": mc_version
|
||||
}
|
||||
from (sourceSets.main.resources.srcDirs) {
|
||||
exclude "mcmod.info"
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name "shadowfacts"
|
||||
url "http://mvn.rx14.co.uk/shadowfacts/"
|
||||
}
|
||||
maven {
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
deobfCompile group: "net.shadowfacts", name: "ShadowMC", version: mc_version + "-" + shadowmc_version
|
||||
deobfCompile group: "mezz.jei", name: "jei_" + mc_version, version: jei_version
|
||||
}
|
||||
|
||||
// curseforge {
|
||||
// apiKey = project.hasProperty("curseForgeApiKey") ? project.curseForgeApiKey : ""
|
||||
|
||||
// project {
|
||||
// id = ""
|
||||
|
||||
// addGameVersion "1.9.4"
|
||||
// addGameVersion "Java 8"
|
||||
|
||||
// mainArtifact(jar) {
|
||||
// releaseType = "beta"
|
||||
|
||||
// relations {
|
||||
// requiredLibrary "shadowmc"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
|
@ -0,0 +1,10 @@
|
|||
mod_version = 1.0.0
|
||||
group = net.shadowfacts
|
||||
archivesBaseName = Funnels
|
||||
|
||||
mc_version = 1.9.4
|
||||
mcp_mappings = snapshot_20160614
|
||||
forge_version = 12.17.0.1963
|
||||
|
||||
shadowmc_version = 3.3.6
|
||||
jei_version = 3.6.3.212
|
Binary file not shown.
|
@ -0,0 +1,6 @@
|
|||
#Tue Jun 14 18:04:44 EDT 2016
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip
|
|
@ -0,0 +1,160 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn ( ) {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die ( ) {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
esac
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||
function splitJvmOpts() {
|
||||
JVM_OPTS=("$@")
|
||||
}
|
||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||
|
||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
|
@ -0,0 +1,90 @@
|
|||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
if "%@eval[2+2]" == "4" goto 4NT_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=%*
|
||||
goto execute
|
||||
|
||||
:4NT_args
|
||||
@rem Get arguments from the 4NT Shell from JP Software
|
||||
set CMD_LINE_ARGS=%$
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -0,0 +1,112 @@
|
|||
package net.shadowfacts.funnels;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.shadowfacts.shadowmc.block.BlockTE;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public class BlockFunnel extends BlockTE<TileEntityFunnel> {
|
||||
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", side -> side != EnumFacing.UP);
|
||||
|
||||
protected static final AxisAlignedBB BASE_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.625D, 1.0D);
|
||||
protected static final AxisAlignedBB SOUTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.125D);
|
||||
protected static final AxisAlignedBB NORTH_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.875D, 1.0D, 1.0D, 1.0D);
|
||||
protected static final AxisAlignedBB WEST_AABB = new AxisAlignedBB(0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
protected static final AxisAlignedBB EAST_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D);
|
||||
|
||||
public BlockFunnel() {
|
||||
super(Material.ROCK, "funnel");
|
||||
|
||||
setCreativeTab(CreativeTabs.MISC);
|
||||
|
||||
setDefaultState(getDefaultState()
|
||||
.withProperty(FACING, EnumFacing.DOWN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return FULL_BLOCK_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn) {
|
||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, BASE_AABB);
|
||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, EAST_AABB);
|
||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, WEST_AABB);
|
||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, SOUTH_AABB);
|
||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, NORTH_AABB);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return state.getValue(FACING).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(FACING, EnumFacing.getFront(meta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
if (side == EnumFacing.UP) side = EnumFacing.DOWN;
|
||||
return getDefaultState().withProperty(FACING, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (!player.isSneaking()) {
|
||||
TileEntityFunnel te = getTileEntity(world, pos);
|
||||
|
||||
if (FluidUtils.fillHandlerWithContainer(world, te.tank, player, hand)) {
|
||||
return true;
|
||||
} else if (FluidUtils.fillContainerFromHandler(world, te.tank, player, hand, te.tank.getFluid())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<TileEntityFunnel> getTileEntityClass() {
|
||||
return TileEntityFunnel.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TileEntityFunnel createTileEntity(World world, IBlockState state) {
|
||||
return new TileEntityFunnel();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package net.shadowfacts.funnels;
|
||||
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public class FluidUtils {
|
||||
|
||||
public static boolean fillHandlerWithContainer(World world, IFluidHandler handler, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack container = player.getHeldItem(hand);
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(container);
|
||||
|
||||
if (fluid != null) {
|
||||
if (handler.fill(fluid, false) == fluid.amount || player.capabilities.isCreativeMode) {
|
||||
ItemStack returnStack = FluidContainerRegistry.drainFluidContainer(container);
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (PlayerUtils.disposePlayerItem(player.getHeldItem(hand), returnStack, player, true)) {
|
||||
player.openContainer.detectAndSendChanges();
|
||||
((EntityPlayerMP)player).sendContainerToPlayer(player.openContainer);
|
||||
}
|
||||
}
|
||||
handler.fill(fluid, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean fillContainerFromHandler(World world, IFluidHandler handler, EntityPlayer player, EnumHand hand, FluidStack tankFluid) {
|
||||
ItemStack container = player.getHeldItem(hand);
|
||||
|
||||
if (FluidContainerRegistry.isEmptyContainer(container)) {
|
||||
ItemStack returnStack = FluidContainerRegistry.fillFluidContainer(tankFluid, container);
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(returnStack);
|
||||
|
||||
if (fluid == null || returnStack == null) {
|
||||
return false;
|
||||
}
|
||||
if (world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (container.stackSize == 1) {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, returnStack);
|
||||
container.stackSize--;
|
||||
if (container.stackSize <= 0) {
|
||||
container = null;
|
||||
}
|
||||
} else {
|
||||
if (PlayerUtils.disposePlayerItem(player.getHeldItem(hand), returnStack, player, true)) {
|
||||
player.openContainer.detectAndSendChanges();
|
||||
((EntityPlayerMP) player).sendContainerToPlayer(player.openContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
handler.drain(fluid.amount, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isFluidBlock(World world, BlockPos pos) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() instanceof BlockLiquid) {
|
||||
return state.getValue(BlockLiquid.LEVEL) == 0;
|
||||
}
|
||||
if (state.getBlock() instanceof IFluidBlock) {
|
||||
return ((IFluidBlock)state.getBlock()).canDrain(world, pos);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static FluidStack drainFluidBlock(World world, BlockPos pos, boolean doDrain) {
|
||||
FluidStack stack = null;
|
||||
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof BlockLiquid && state.getValue(BlockLiquid.LEVEL) == 0) {
|
||||
if (state.getBlock() == Blocks.WATER || state.getBlock() == Blocks.FLOWING_WATER) {
|
||||
stack = new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME);
|
||||
if (doDrain) world.setBlockToAir(pos);
|
||||
} else if (state.getBlock() == Blocks.LAVA|| state.getBlock() == Blocks.FLOWING_LAVA) {
|
||||
stack = new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME);
|
||||
if (doDrain) world.setBlockToAir(pos);
|
||||
}
|
||||
} else if (state.getBlock() instanceof IFluidBlock) {
|
||||
stack = ((IFluidBlock)state.getBlock()).drain(world, pos, doDrain);
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package net.shadowfacts.funnels;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
@Mod(modid = Funnels.modId, name = Funnels.name, version = Funnels.version, dependencies = "required-after:shadowmc@[3.3.6,);", acceptedMinecraftVersions = "[1.9.4]", guiFactory = "net.shadowfacts.funnels.GUIFactory")
|
||||
public class Funnels {
|
||||
|
||||
public static final String modId = "Funnels";
|
||||
public static final String name = "Funnels";
|
||||
public static final String version = "@VERSION@";
|
||||
|
||||
// Content
|
||||
public static BlockFunnel funnel;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
FunnelsConfig.init(event.getModConfigurationDirectory());
|
||||
FunnelsConfig.load();
|
||||
|
||||
funnel = GameRegistry.register(new BlockFunnel());
|
||||
GameRegistry.register(new ItemBlock(funnel).setRegistryName(funnel.getRegistryName()));
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityFunnel.class, "funnel");
|
||||
|
||||
if (event.getSide() == Side.CLIENT) {
|
||||
preInitClient();
|
||||
}
|
||||
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(funnel, "I I", "I I", " B ", 'I', "ingotIron", 'B', Items.BUCKET));
|
||||
}
|
||||
|
||||
private void preInitClient() {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFunnel.class, new TESRFunnel());
|
||||
funnel.initItemModel();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package net.shadowfacts.funnels;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.shadowfacts.config.Config;
|
||||
import net.shadowfacts.config.ConfigManager;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
@Config(name = Funnels.modId)
|
||||
public class FunnelsConfig {
|
||||
|
||||
static Configuration config;
|
||||
|
||||
@Config.Prop
|
||||
public static int size = 4000;
|
||||
|
||||
@Config.Prop
|
||||
public static boolean pickupWorldFluids = true;
|
||||
|
||||
@Config.Prop
|
||||
public static boolean placeFluidsInWorld = true;
|
||||
|
||||
public static void init(File configDir) {
|
||||
config = new Configuration(new File(configDir, "shadowfacts/Funnels.cfg"));
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
ConfigManager.load(FunnelsConfig.class, Configuration.class, config);
|
||||
if (config.hasChanged()) config.save();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package net.shadowfacts.funnels;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.shadowfacts.shadowmc.config.GUIConfig;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public class FunnelsConfigGUI extends GUIConfig {
|
||||
|
||||
public FunnelsConfigGUI(GuiScreen parent) {
|
||||
super(parent, Funnels.modId, FunnelsConfig.config);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package net.shadowfacts.funnels;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public class GUIFactory implements IModGuiFactory {
|
||||
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return FunnelsConfigGUI.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package net.shadowfacts.funnels;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public class PlayerUtils {
|
||||
|
||||
public static boolean disposePlayerItem(ItemStack stack, ItemStack dropStack, EntityPlayer entityplayer, boolean allowDrop, boolean allowReplace) {
|
||||
|
||||
if (entityplayer == null || entityplayer.capabilities.isCreativeMode) {
|
||||
return true;
|
||||
}
|
||||
if (allowReplace && stack.stackSize <= 1) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null);
|
||||
entityplayer.inventory.addItemStackToInventory(dropStack);
|
||||
return true;
|
||||
} else if (allowDrop) {
|
||||
stack.stackSize -= 1;
|
||||
if (dropStack != null && !entityplayer.inventory.addItemStackToInventory(dropStack)) {
|
||||
entityplayer.dropItem(dropStack, false, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean disposePlayerItem(ItemStack stack, ItemStack dropStack, EntityPlayer entityplayer, boolean allowDrop) {
|
||||
return disposePlayerItem(stack, dropStack, entityplayer, allowDrop, true);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package net.shadowfacts.funnels;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.shadowfacts.shadowmc.util.RenderHelper;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public class TESRFunnel extends TileEntitySpecialRenderer<TileEntityFunnel> {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntityFunnel te, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||
if (te.tank.getFluid() != null) {
|
||||
FluidStack fluid = te.tank.getFluid();
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
VertexBuffer renderer = tessellator.getBuffer();
|
||||
renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
int color = fluid.getFluid().getColor(fluid);
|
||||
int brightness = Minecraft.getMinecraft().theWorld.getCombinedLight(te.getPos(), fluid.getFluid().getLuminosity());
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if (Minecraft.isAmbientOcclusionEnabled()) {
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
} else {
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
}
|
||||
|
||||
GlStateManager.translate(x, y, z);
|
||||
|
||||
TextureAtlasSprite still = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(fluid.getFluid().getStill(fluid).toString());
|
||||
|
||||
RenderHelper.putTexturedQuad(renderer, still, 2/16d, 14/16d, 2/16d, 12/16d, 0, 12/16d, EnumFacing.UP, color, brightness);
|
||||
|
||||
tessellator.draw();
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package net.shadowfacts.funnels;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.shadowfacts.shadowmc.ShadowMC;
|
||||
import net.shadowfacts.shadowmc.network.PacketUpdateTE;
|
||||
import net.shadowfacts.shadowmc.tileentity.BaseTileEntity;
|
||||
|
||||
/**
|
||||
* @author shadowfacts
|
||||
*/
|
||||
public class TileEntityFunnel extends BaseTileEntity implements ITickable {
|
||||
|
||||
FluidTank tank = new FluidTank(FunnelsConfig.size);
|
||||
|
||||
private int tick;
|
||||
|
||||
private void save() {
|
||||
markDirty();
|
||||
ShadowMC.network.sendToAllAround(new PacketUpdateTE(this), new NetworkRegistry.TargetPoint(worldObj.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 64));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!worldObj.isRemote) {
|
||||
if (tank.getFluidAmount() > 0) {
|
||||
EnumFacing facing = worldObj.getBlockState(pos).getValue(BlockFunnel.FACING);
|
||||
BlockPos handlerPos = pos.offset(facing);
|
||||
TileEntity te = worldObj.getTileEntity(handlerPos);
|
||||
if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite())) {
|
||||
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite());
|
||||
tank.drain(handler.fill(tank.drain(20, false), true), true);
|
||||
save();
|
||||
}
|
||||
}
|
||||
tick++;
|
||||
if (tick % 40 == 0) {
|
||||
if (FunnelsConfig.pickupWorldFluids) {
|
||||
tick = 0;
|
||||
if (FluidUtils.isFluidBlock(worldObj, pos.up())) {
|
||||
FluidStack toDrain = FluidUtils.drainFluidBlock(worldObj, pos.up(), false);
|
||||
if (toDrain.amount <= tank.getCapacity() - tank.getFluidAmount()) {
|
||||
tank.fill(FluidUtils.drainFluidBlock(worldObj, pos.up(), true), true);
|
||||
save();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (FunnelsConfig.placeFluidsInWorld && tank.getFluidAmount() >= Fluid.BUCKET_VOLUME) {
|
||||
FluidStack fluid = tank.getFluid();
|
||||
if (fluid.getFluid().canBePlacedInWorld()) {
|
||||
Block fluidBlock = fluid.getFluid().getBlock();
|
||||
BlockPos newPos = pos.offset(worldObj.getBlockState(pos).getValue(BlockFunnel.FACING));
|
||||
if (fluidBlock.canPlaceBlockAt(worldObj, newPos)) {
|
||||
tank.drain(Fluid.BUCKET_VOLUME, true);
|
||||
save();
|
||||
worldObj.setBlockState(newPos, fluidBlock.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
tank.readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tank.writeToNBT(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) {
|
||||
return (T)tank;
|
||||
} else {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"variants": {
|
||||
"inventory": {
|
||||
"model": "hopper_down",
|
||||
"transform": "forge:default-item"
|
||||
},
|
||||
"facing": {
|
||||
"down": {
|
||||
"model": "hopper_down"
|
||||
},
|
||||
"north": {
|
||||
"model": "hopper_side"
|
||||
},
|
||||
"south": {
|
||||
"model": "hopper_side",
|
||||
"y": 180
|
||||
},
|
||||
"west": {
|
||||
"model": "hopper_side",
|
||||
"y": 270
|
||||
},
|
||||
"east": {
|
||||
"model": "hopper_side",
|
||||
"y": 90
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
tile.funnel.name=Funnel
|
||||
|
||||
Funnels.config.gui.title=Funnels Config
|
||||
Funnels.config.gui.category.general=General
|
|
@ -0,0 +1,14 @@
|
|||
[
|
||||
{
|
||||
"modid": "Funnels",
|
||||
"name": "Funnels",
|
||||
"version": "$version",
|
||||
"mcversion": "$mcversion",
|
||||
"description": "Fluid funnels",
|
||||
"credits": "",
|
||||
"url": "https://github.com/shadowfacts/Funnels",
|
||||
"updateUrl": "",
|
||||
"authorList": [ "shadowfacts" ],
|
||||
"screenshots": []
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue