Restructured repository.
commit
9e06605dad
|
@ -0,0 +1,70 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "MC1.8.0-b0.9.1"
|
||||
group= "net.einsteinsci.betterbeginnings" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = "betterbeginnings"
|
||||
|
||||
minecraft {
|
||||
version = "1.8-11.14.1.1334"
|
||||
runDir = "eclipse"
|
||||
|
||||
// the mappings can be changed at any time, and must be in the following format.
|
||||
// snapshot_YYYYMMDD snapshot are built nightly.
|
||||
// stable_# stables are built at the discretion of the MCP team.
|
||||
// Use non-default mappings at your own risk. they may not allways work.
|
||||
// simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings = "snapshot_20141130"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// you may put jars on which you depend on in ./libs
|
||||
// or you may define them like so..
|
||||
//compile "some.group:artifact:version:classifier"
|
||||
//compile "some.group:artifact:version"
|
||||
|
||||
// real examples
|
||||
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
|
||||
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
|
||||
|
||||
// for more info...
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
|
||||
}
|
||||
|
||||
processResources
|
||||
{
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
inputs.property "mcversion", project.minecraft.version
|
||||
|
||||
// replace stuff in mcmod.info, nothing else
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'mcmod.info'
|
||||
|
||||
// replace version and mcversion
|
||||
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||
}
|
||||
|
||||
// copy everything else, thats not the mcmod.info
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,6 @@
|
|||
#Wed Jul 02 15:54:47 CDT 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip
|
|
@ -0,0 +1,164 @@
|
|||
#!/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
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched.
|
||||
if $cygwin ; then
|
||||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
fi
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# 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\"`/" >&-
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >&-
|
||||
|
||||
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"`
|
||||
|
||||
# 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 Windowz 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,133 @@
|
|||
package net.einsteinsci.betterbeginnings;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.config.BBConfig;
|
||||
import net.einsteinsci.betterbeginnings.event.BBEventHandler;
|
||||
import net.einsteinsci.betterbeginnings.event.Worldgen;
|
||||
import net.einsteinsci.betterbeginnings.network.PacketNetherBrickOvenFuelLevel;
|
||||
import net.einsteinsci.betterbeginnings.network.ServerProxy;
|
||||
import net.einsteinsci.betterbeginnings.register.*;
|
||||
import net.einsteinsci.betterbeginnings.register.achievement.RegisterAchievements;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.AchievementPage;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.common.*;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.Mod.Instance;
|
||||
import net.minecraftforge.fml.common.event.*;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
/*
|
||||
* Forge Version: 11.14.1.1334 for MC 1.8.0
|
||||
*/
|
||||
|
||||
@Mod(modid = ModMain.MODID, version = ModMain.VERSION, name = ModMain.NAME,
|
||||
guiFactory = "net.einsteinsci.betterbeginnings.config.BBConfigGuiFactory")
|
||||
public class ModMain
|
||||
{
|
||||
public static final String MODID = "betterbeginnings";
|
||||
public static final String VERSION = "0.0.6.0";
|
||||
public static final String NAME = "Better Beginnings";
|
||||
public static final CreativeTabs tabBetterBeginnings = new CreativeTabs("tabBetterBeginnings")
|
||||
{
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getTabIconItem()
|
||||
{
|
||||
return RegisterItems.flintKnife;
|
||||
}
|
||||
};
|
||||
|
||||
@Instance(ModMain.MODID)
|
||||
public static ModMain modInstance;
|
||||
public static Configuration configFile;
|
||||
public static SimpleNetworkWrapper network;
|
||||
@SidedProxy(clientSide = "net.einsteinsci.betterbeginnings.network.ClientProxy",
|
||||
serverSide = "net.einsteinsci.betterbeginnings.network.ServerProxy")
|
||||
public static ServerProxy proxy;
|
||||
public BBEventHandler eventHandler = new BBEventHandler();
|
||||
|
||||
public static void LogDebug(String text)
|
||||
{
|
||||
if (BBConfig.debugLogging)
|
||||
{
|
||||
Log(Level.DEBUG, text);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Log(Level level, String text)
|
||||
{
|
||||
FMLLog.log(NAME, level, text);
|
||||
}
|
||||
|
||||
public static void LogDebug(Level level, String text)
|
||||
{
|
||||
if (BBConfig.debugLogging)
|
||||
{
|
||||
Log(level, text);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent e)
|
||||
{
|
||||
Log("Starting pre-initialization...");
|
||||
|
||||
configFile = new Configuration(e.getSuggestedConfigurationFile());
|
||||
configFile.load();
|
||||
BBConfig.initialize();
|
||||
BBConfig.syncConfig(configFile);
|
||||
|
||||
proxy.registerNetworkStuff();
|
||||
proxy.registerRenderThings();
|
||||
|
||||
|
||||
FMLCommonHandler.instance().bus().register(eventHandler);
|
||||
MinecraftForge.EVENT_BUS.register(eventHandler);
|
||||
|
||||
network = NetworkRegistry.INSTANCE.newSimpleChannel("bbchannel");
|
||||
network.registerMessage(PacketNetherBrickOvenFuelLevel.PacketHandler.class,
|
||||
PacketNetherBrickOvenFuelLevel.class, 0, Side.CLIENT);
|
||||
|
||||
RegisterItems.register();
|
||||
RegisterBlocks.register();
|
||||
RegisterTileEntities.register();
|
||||
}
|
||||
|
||||
public static void Log(String text)
|
||||
{
|
||||
Log(Level.INFO, text);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent e)
|
||||
{
|
||||
RemoveRecipes.remove();
|
||||
RegisterRecipes.addShapelessRecipes();
|
||||
RegisterRecipes.addShapedRecipes();
|
||||
RegisterRecipes.addAdvancedRecipes();
|
||||
RegisterRecipes.addFurnaceRecipes();
|
||||
|
||||
RemoveRecipes.removeFurnaceRecipes();
|
||||
|
||||
if (e.getSide() == Side.CLIENT)
|
||||
{
|
||||
RegisterModels.register();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent e)
|
||||
{
|
||||
|
||||
RegisterItems.tweakVanilla();
|
||||
Worldgen.addWorldgen();
|
||||
AchievementPage.registerAchievementPage(new AchievementPage(NAME, RegisterAchievements.getAchievements()));
|
||||
Log("Finished post-initialization.");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
package net.einsteinsci.betterbeginnings.blocks;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockBrickOven extends BlockContainer implements IBBName
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
private static boolean isLit;
|
||||
private final boolean isLit2; // strange why...
|
||||
|
||||
public BlockBrickOven(boolean lit)
|
||||
{
|
||||
super(Material.rock);
|
||||
|
||||
if (lit)
|
||||
{
|
||||
setLightLevel(0.875F);
|
||||
}
|
||||
else
|
||||
{
|
||||
setLightLevel(0.0F);
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
setUnlocalizedName(getName());
|
||||
|
||||
setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||
isLit2 = lit;
|
||||
setHardness(2.0f);
|
||||
setResistance(10.0f);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return isLit2 ? "brickOvenLit" : "brickOven";
|
||||
}
|
||||
|
||||
public static void updateBlockState(boolean lit, World world, BlockPos pos)
|
||||
{
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
isLit = true;
|
||||
|
||||
if (lit)
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.brickOvenLit.getDefaultState()
|
||||
.withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.brickOven.getDefaultState()
|
||||
.withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||
}
|
||||
|
||||
isLit = false;
|
||||
|
||||
if (tileentity != null)
|
||||
{
|
||||
tileentity.validate();
|
||||
world.setTileEntity(pos, tileentity);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand)
|
||||
{
|
||||
if (isLit2)
|
||||
{
|
||||
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||
double d0 = (double)pos.getX() + 0.5D;
|
||||
double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D;
|
||||
double d2 = (double)pos.getZ() + 0.5D;
|
||||
double d3 = 0.52D;
|
||||
double d4 = rand.nextDouble() * 0.6D - 0.3D;
|
||||
|
||||
switch (BlockKiln.SwitchEnumFacing.facings[enumfacing.ordinal()])
|
||||
{
|
||||
case 1:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case 2:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case 3:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case 4:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Block block = world.getBlockState(pos.offset(EnumFacing.NORTH)).getBlock();
|
||||
Block block1 = world.getBlockState(pos.offset(EnumFacing.SOUTH)).getBlock();
|
||||
Block block2 = world.getBlockState(pos.offset(EnumFacing.WEST)).getBlock();
|
||||
Block block3 = world.getBlockState(pos.offset(EnumFacing.EAST)).getBlock();
|
||||
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||
|
||||
if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.EAST;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
world.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int par3)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.brickOven);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side,
|
||||
float clickX, float clickY, float clickZ)
|
||||
{
|
||||
player.openGui(ModMain.modInstance, BBGuiHandler.BRICKOVEN_ID, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
|
||||
int meta, EntityLivingBase placer)
|
||||
{
|
||||
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer,
|
||||
ItemStack stack)
|
||||
{
|
||||
world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
|
||||
|
||||
if (stack.hasDisplayName())
|
||||
{
|
||||
TileEntity teBase = world.getTileEntity(pos);
|
||||
if (teBase instanceof TileEntityBrickOven)
|
||||
{
|
||||
TileEntityBrickOven tileEntity = (TileEntityBrickOven)teBase;
|
||||
tileEntity.setBlockName(stack.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World world, BlockPos pos)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.brickOven);
|
||||
}
|
||||
|
||||
protected BlockState createBlockState()
|
||||
{
|
||||
return new BlockState(this, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Drop stuff everywhere
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!isLit)
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof TileEntityBrickOven)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityBrickOven)tileentity);
|
||||
worldIn.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2)
|
||||
{
|
||||
return new TileEntityBrickOven();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Buffer
|
|
@ -0,0 +1,200 @@
|
|||
package net.einsteinsci.betterbeginnings.blocks;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.*;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityCampfire;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockCampfire extends BlockContainer implements IBBName
|
||||
{
|
||||
private static boolean isAlteringLit;
|
||||
private final boolean isLit; // strange why...
|
||||
|
||||
public BlockCampfire(boolean lit)
|
||||
{
|
||||
super(Material.rock);
|
||||
setResistance(3.0F);
|
||||
setHardness(1.5F);
|
||||
|
||||
if (!lit)
|
||||
{
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
setUnlocalizedName(getName());
|
||||
|
||||
isLit = lit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return isLit ? "campfireLit" : "campfire";
|
||||
}
|
||||
|
||||
public static void updateBlockState(boolean lit, World world, BlockPos pos)
|
||||
{
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
isAlteringLit = true;
|
||||
|
||||
if (lit)
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.campfireLit.getDefaultState(), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.campfire.getDefaultState(), 3);
|
||||
}
|
||||
|
||||
isAlteringLit = false;
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
tileEntity.validate();
|
||||
world.setTileEntity(pos, tileEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFullCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand)
|
||||
{
|
||||
TileEntityCampfire tile = (TileEntityCampfire)world.getTileEntity(pos);
|
||||
|
||||
if (tile.isBurning())
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
double ry = rand.nextDouble() * 0.5 + 0.15;
|
||||
double rx = rand.nextDouble() * 0.4 + 0.3;
|
||||
double rz = rand.nextDouble() * 0.4 + 0.3;
|
||||
|
||||
double vx = rand.nextDouble() * 0.02 - 0.01;
|
||||
double vy = rand.nextDouble() * 0.05 + 0.03;
|
||||
double vz = rand.nextDouble() * 0.02 - 0.01;
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, pos.getX() + rx, pos.getY() + ry, pos.getZ() + rz,
|
||||
vx, vy, vz);
|
||||
}
|
||||
}
|
||||
else if (tile.isDecaying())
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
double ry = rand.nextDouble() * 0.5 + 0.15;
|
||||
double rx = rand.nextDouble() * 0.4 + 0.3;
|
||||
double rz = rand.nextDouble() * 0.4 + 0.3;
|
||||
|
||||
double vx = rand.nextDouble() * 0.02 - 0.01;
|
||||
double vy = rand.nextDouble() * 0.05 + 0.03;
|
||||
double vz = rand.nextDouble() * 0.02 - 0.01;
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, pos.getX() + rx, pos.getY() + ry, pos.getZ() + rz,
|
||||
vx, vy, vz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int par3)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.campfire);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World world, BlockPos pos)
|
||||
{
|
||||
return world.getBlockState(pos).getBlock()
|
||||
.isReplaceable(world, pos) && World
|
||||
.doesBlockHaveSolidTopSurface(world, pos.offset(EnumFacing.DOWN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side,
|
||||
float clickX, float clickY, float clickZ)
|
||||
{
|
||||
if (player.getHeldItem() != null)
|
||||
{
|
||||
Item item = player.getHeldItem().getItem();
|
||||
|
||||
if (item == Items.flint_and_steel || item == RegisterItems.fireBow)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
player.openGui(ModMain.modInstance, BBGuiHandler.CAMPFIRE_ID, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
|
||||
{
|
||||
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Drop stuff everywhere
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!isLit)
|
||||
{
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof TileEntityCampfire)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(world, pos, (TileEntityCampfire)tileentity);
|
||||
world.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
|
||||
{
|
||||
return new TileEntityCampfire();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package net.einsteinsci.betterbeginnings.blocks;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.register.achievement.RegisterAchievements;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockDoubleWorkbench extends Block implements IBBName
|
||||
{
|
||||
public static final PropertyDirection CONNECTION = PropertyDirection.create("connection");
|
||||
|
||||
public BlockDoubleWorkbench()
|
||||
{
|
||||
super(Material.wood);
|
||||
setStepSound(soundTypeWood);
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
setDefaultState(blockState.getBaseState().withProperty(CONNECTION, EnumFacing.UP));
|
||||
|
||||
// Not sure how this works...
|
||||
setHardness(2.0f);
|
||||
setResistance(5.0f);
|
||||
|
||||
setUnlocalizedName(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "doubleWorkbench";
|
||||
}
|
||||
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((EnumFacing)state.getValue(CONNECTION)).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
IBlockState north = world.getBlockState(pos.north());
|
||||
if (north.getBlock().equals(RegisterBlocks.doubleWorkbench))
|
||||
{
|
||||
world.setBlockState(pos, state.withProperty(CONNECTION, EnumFacing.NORTH), 3);
|
||||
world.setBlockState(pos.north(), north.withProperty(CONNECTION, EnumFacing.SOUTH), 3);
|
||||
}
|
||||
|
||||
IBlockState south = world.getBlockState(pos.south());
|
||||
if (south.getBlock().equals(RegisterBlocks.doubleWorkbench))
|
||||
{
|
||||
world.setBlockState(pos, state.withProperty(CONNECTION, EnumFacing.SOUTH), 3);
|
||||
world.setBlockState(pos.south(), south.withProperty(CONNECTION, EnumFacing.NORTH), 3);
|
||||
}
|
||||
|
||||
IBlockState east = world.getBlockState(pos.east());
|
||||
if (east.getBlock().equals(RegisterBlocks.doubleWorkbench))
|
||||
{
|
||||
world.setBlockState(pos, state.withProperty(CONNECTION, EnumFacing.EAST), 3);
|
||||
world.setBlockState(pos.east(), east.withProperty(CONNECTION, EnumFacing.WEST), 3);
|
||||
}
|
||||
|
||||
IBlockState west = world.getBlockState(pos.west());
|
||||
if (west.getBlock().equals(RegisterBlocks.doubleWorkbench))
|
||||
{
|
||||
world.setBlockState(pos, state.withProperty(CONNECTION, EnumFacing.WEST), 3);
|
||||
world.setBlockState(pos.west(), west.withProperty(CONNECTION, EnumFacing.EAST), 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
IBlockState north = world.getBlockState(pos.north());
|
||||
if (north.getBlock().equals(RegisterBlocks.doubleWorkbench))
|
||||
{
|
||||
world.setBlockState(pos.north(), north.withProperty(CONNECTION, EnumFacing.UP), 3);
|
||||
}
|
||||
IBlockState south = world.getBlockState(pos.south());
|
||||
if (south.getBlock().equals(RegisterBlocks.doubleWorkbench))
|
||||
{
|
||||
world.setBlockState(pos.south(), south.withProperty(CONNECTION, EnumFacing.UP), 3);
|
||||
}
|
||||
IBlockState east = world.getBlockState(pos.east());
|
||||
if (east.getBlock().equals(RegisterBlocks.doubleWorkbench))
|
||||
{
|
||||
world.setBlockState(pos.east(), east.withProperty(CONNECTION, EnumFacing.UP), 3);
|
||||
}
|
||||
IBlockState west = world.getBlockState(pos.west());
|
||||
if (west.getBlock().equals(RegisterBlocks.doubleWorkbench))
|
||||
{
|
||||
world.setBlockState(pos.west(), west.withProperty(CONNECTION, EnumFacing.UP), 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World world, BlockPos pos)
|
||||
{
|
||||
if (world.getBlockState(pos.north()).getBlock().equals(this) &&
|
||||
world.getBlockState(pos.north()).getValue(CONNECTION) != EnumFacing.UP)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (world.getBlockState(pos.south()).getBlock().equals(this) &&
|
||||
world.getBlockState(pos.south()).getValue(CONNECTION) != EnumFacing.UP)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (world.getBlockState(pos.east()).getBlock().equals(this) &&
|
||||
world.getBlockState(pos.east()).getValue(CONNECTION) != EnumFacing.UP)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (world.getBlockState(pos.west()).getBlock().equals(this) &&
|
||||
world.getBlockState(pos.west()).getValue(CONNECTION) != EnumFacing.UP)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing face,
|
||||
float posX, float posY, float posZ)
|
||||
{
|
||||
if (state.getValue(CONNECTION).equals(EnumFacing.UP))
|
||||
{
|
||||
player.openGui(ModMain.modInstance, BBGuiHandler.SIMPLEWORKBENCH_ID, world,
|
||||
pos.getX(), pos.getY(), pos.getZ());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.openGui(ModMain.modInstance, BBGuiHandler.DOUBLEWORKBENCH_ID, world,
|
||||
pos.getX(), pos.getY(), pos.getZ());
|
||||
return true;
|
||||
}
|
||||
|
||||
// if (world.isRemote)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // player.displayGUIWorkbench(x, y, z);
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||
{
|
||||
if (placer instanceof EntityPlayer)
|
||||
{
|
||||
RegisterAchievements.achievementGet((EntityPlayer)placer, "doubleWorkbench");
|
||||
}
|
||||
|
||||
return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer);
|
||||
}
|
||||
|
||||
protected BlockState createBlockState()
|
||||
{
|
||||
return new BlockState(this, CONNECTION);
|
||||
}
|
||||
|
||||
/*
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconregister)
|
||||
{
|
||||
blockIcon = iconregister.registerIcon(ModMain.MODID + ":workbenchSide");
|
||||
top = iconregister.registerIcon(ModMain.MODID + ":workbenchTop");
|
||||
westNorthIfSolo = iconregister.registerIcon(ModMain.MODID + ":workbenchFront");
|
||||
|
||||
westIfNorth = iconregister.registerIcon(ModMain.MODID + ":workbenchWestIfNorth");
|
||||
northIfWest = iconregister.registerIcon(ModMain.MODID + ":workbenchNorthIfWest");
|
||||
eastIfSouth = iconregister.registerIcon(ModMain.MODID + ":workbenchEastIfSouth");
|
||||
southIfEast = iconregister.registerIcon(ModMain.MODID + ":workbenchSouthIfEast");
|
||||
|
||||
topIfNorth = iconregister.registerIcon(ModMain.MODID + ":workbenchTopIfNorth");
|
||||
topIfWest = iconregister.registerIcon(ModMain.MODID + ":workbenchTopIfWest");
|
||||
topIfEast = iconregister.registerIcon(ModMain.MODID + ":workbenchTopIfEast");
|
||||
topIfSouth = iconregister.registerIcon(ModMain.MODID + ":workbenchTopIfSouth");
|
||||
} */
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
package net.einsteinsci.betterbeginnings.blocks;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityEnderSmelter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockEnderSmelter extends BlockContainer implements IBBName
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
private static boolean isLit;
|
||||
private final boolean isLit2; // strange why...
|
||||
|
||||
public BlockEnderSmelter(boolean lit)
|
||||
{
|
||||
super(Material.rock);
|
||||
|
||||
if (lit)
|
||||
{
|
||||
setLightLevel(0.875F);
|
||||
}
|
||||
else
|
||||
{
|
||||
setLightLevel(0.0F);
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
setUnlocalizedName(getName());
|
||||
|
||||
setHardness(1.5f);
|
||||
setResistance(10.0f);
|
||||
setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||
|
||||
isLit2 = lit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return isLit2 ? "enderSmelterLit" : "enderSmelter";
|
||||
}
|
||||
|
||||
public static void updateBlockState(boolean lit, World world, BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
isLit = true;
|
||||
|
||||
if (lit)
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.enderSmelterLit.getDefaultState()
|
||||
.withProperty(FACING, state.getValue(FACING)), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.enderSmelter.getDefaultState()
|
||||
.withProperty(FACING, state.getValue(FACING)), 3);
|
||||
}
|
||||
|
||||
isLit = false;
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
tileEntity.validate();
|
||||
world.setTileEntity(pos, tileEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random random)
|
||||
{
|
||||
if (isLit2)
|
||||
{
|
||||
float f = pos.getX() + 0.5f;
|
||||
float f1 = pos.getY() + random.nextFloat() * 6.0f / 16.0f;
|
||||
float f2 = pos.getZ() + 0.5f;
|
||||
|
||||
float f3 = 0.5f;
|
||||
float f4 = random.nextFloat() * 0.6f - 0.2f;
|
||||
|
||||
// Weird implementation because of particle rendering bug (#59).
|
||||
if (state.getValue(FACING) == EnumFacing.WEST)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f - f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.PORTAL, f - f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.EAST)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.PORTAL, f + f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.NORTH)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f4, f1, f2 - f3, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.PORTAL, f + f4, f1, f2 - f3, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.SOUTH)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f4, f1, f2 + f3, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.PORTAL, f + f4, f1, f2 + f3, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Block block = world.getBlockState(pos.offset(EnumFacing.NORTH)).getBlock();
|
||||
Block block1 = world.getBlockState(pos.offset(EnumFacing.SOUTH)).getBlock();
|
||||
Block block2 = world.getBlockState(pos.offset(EnumFacing.WEST)).getBlock();
|
||||
Block block3 = world.getBlockState(pos.offset(EnumFacing.EAST)).getBlock();
|
||||
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||
|
||||
if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.EAST;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
world.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int par3)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.enderSmelter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side,
|
||||
float clickX, float clickY, float clickZ)
|
||||
{
|
||||
player.openGui(ModMain.modInstance, BBGuiHandler.ENDERSMELTER_ID, world,
|
||||
pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
|
||||
int meta, EntityLivingBase placer)
|
||||
{
|
||||
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer,
|
||||
ItemStack stack)
|
||||
{
|
||||
world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
|
||||
|
||||
if (stack.hasDisplayName())
|
||||
{
|
||||
TileEntity teBase = world.getTileEntity(pos);
|
||||
if (teBase instanceof TileEntityEnderSmelter)
|
||||
{
|
||||
TileEntityEnderSmelter tileEntity = (TileEntityEnderSmelter)teBase;
|
||||
tileEntity.setBlockName(stack.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World world, BlockPos pos)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.enderSmelter);
|
||||
}
|
||||
|
||||
protected BlockState createBlockState()
|
||||
{
|
||||
return new BlockState(this, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Drop stuff everywhere
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!isLit)
|
||||
{
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof TileEntityEnderSmelter)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(world, pos, (TileEntityEnderSmelter)tileentity);
|
||||
world.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2)
|
||||
{
|
||||
return new TileEntityEnderSmelter();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package net.einsteinsci.betterbeginnings.blocks;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockInfusionRepairStation extends Block implements IBBName
|
||||
{
|
||||
public BlockInfusionRepairStation()
|
||||
{
|
||||
super(Material.rock);
|
||||
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
setHardness(2.0f);
|
||||
setResistance(6000);
|
||||
|
||||
setUnlocalizedName(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "infusionRepairStation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side,
|
||||
float clickX, float clickY, float clickZ)
|
||||
{
|
||||
player.openGui(ModMain.modInstance, BBGuiHandler.INFUSIONREPAIR_ID, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,274 @@
|
|||
package net.einsteinsci.betterbeginnings.blocks;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityKiln;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockKiln extends BlockContainer implements IBBName
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
private static boolean isLit;
|
||||
private final boolean isLit2; // strange why...
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
static final class SwitchEnumFacing
|
||||
{
|
||||
static final int[] facings = new int[EnumFacing.values().length];
|
||||
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
facings[EnumFacing.WEST.ordinal()] = 1;
|
||||
}
|
||||
catch (NoSuchFieldError var4)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
facings[EnumFacing.EAST.ordinal()] = 2;
|
||||
}
|
||||
catch (NoSuchFieldError var3)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
facings[EnumFacing.NORTH.ordinal()] = 3;
|
||||
}
|
||||
catch (NoSuchFieldError var2)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
facings[EnumFacing.SOUTH.ordinal()] = 4;
|
||||
}
|
||||
catch (NoSuchFieldError var1)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public BlockKiln(boolean lit)
|
||||
{
|
||||
super(Material.rock);
|
||||
setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||
isLit2 = lit;
|
||||
|
||||
if (!lit)
|
||||
{
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
setUnlocalizedName(getName());
|
||||
|
||||
setHardness(2.0f);
|
||||
setResistance(10.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return isLit2 ? "kilnLit" : "kiln";
|
||||
}
|
||||
|
||||
public static void updateBlockState(boolean flag, World world, BlockPos pos)
|
||||
{
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
isLit = true;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.kilnLit.getDefaultState()
|
||||
.withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.kiln.getDefaultState()
|
||||
.withProperty(FACING, iblockstate.getValue(FACING)), 3);
|
||||
}
|
||||
|
||||
isLit = false;
|
||||
|
||||
if (tileentity != null)
|
||||
{
|
||||
tileentity.validate();
|
||||
world.setTileEntity(pos, tileentity);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random rand)
|
||||
{
|
||||
if (isLit2)
|
||||
{
|
||||
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||
double d0 = (double)pos.getX() + 0.5D;
|
||||
double d1 = (double)pos.getY() + rand.nextDouble() * 6.0D / 16.0D;
|
||||
double d2 = (double)pos.getZ() + 0.5D;
|
||||
double d3 = 0.52D;
|
||||
double d4 = rand.nextDouble() * 0.6D - 0.3D;
|
||||
|
||||
switch (SwitchEnumFacing.facings[enumfacing.ordinal()])
|
||||
{
|
||||
case 1:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 - d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case 2:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 + d3, d1, d2 + d4, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case 3:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 - d3, 0.0D, 0.0D, 0.0D);
|
||||
break;
|
||||
case 4:
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, d1, d2 + d3, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Block block = world.getBlockState(pos.offset(EnumFacing.NORTH)).getBlock();
|
||||
Block block1 = world.getBlockState(pos.offset(EnumFacing.SOUTH)).getBlock();
|
||||
Block block2 = world.getBlockState(pos.offset(EnumFacing.WEST)).getBlock();
|
||||
Block block3 = world.getBlockState(pos.offset(EnumFacing.EAST)).getBlock();
|
||||
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||
|
||||
if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.EAST;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
world.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int fortune)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.kiln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side,
|
||||
float clickX, float clickY, float clickZ)
|
||||
{
|
||||
player.openGui(ModMain.modInstance, BBGuiHandler.KILN_ID, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
|
||||
int meta, EntityLivingBase placer)
|
||||
{
|
||||
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer,
|
||||
ItemStack stack)
|
||||
{
|
||||
world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
|
||||
|
||||
if (stack.hasDisplayName())
|
||||
{
|
||||
TileEntity teBase = world.getTileEntity(pos);
|
||||
if (teBase instanceof TileEntityKiln)
|
||||
{
|
||||
TileEntityKiln tileEntity = (TileEntityKiln)teBase;
|
||||
tileEntity.setBlockName(stack.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World world, BlockPos pos)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.kiln);
|
||||
}
|
||||
|
||||
protected BlockState createBlockState()
|
||||
{
|
||||
return new BlockState(this, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Drop stuff everywhere
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!isLit)
|
||||
{
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof TileEntityKiln)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(world, pos, (TileEntityKiln)tileentity);
|
||||
world.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2)
|
||||
{
|
||||
return new TileEntityKiln();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,248 @@
|
|||
package net.einsteinsci.betterbeginnings.blocks;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/21/2014.
|
||||
*/
|
||||
public class BlockNetherBrickOven extends BlockContainer implements IBBName
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
private static boolean isLit;
|
||||
private final boolean isLit2; // strange why...
|
||||
|
||||
public BlockNetherBrickOven(boolean lit)
|
||||
{
|
||||
super(Material.rock);
|
||||
|
||||
if (lit)
|
||||
{
|
||||
setLightLevel(0.875F);
|
||||
}
|
||||
else
|
||||
{
|
||||
setLightLevel(0F);
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
setUnlocalizedName(getName());
|
||||
|
||||
setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||
|
||||
setHardness(4.0f);
|
||||
setResistance(10.0f);
|
||||
|
||||
isLit2 = lit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return isLit2 ? "netherBrickOvenLit" : "netherBrickOven";
|
||||
}
|
||||
|
||||
public static void updateBlockState(boolean lit, World world, BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
isLit = true;
|
||||
|
||||
if (lit)
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.netherBrickOvenLit.getDefaultState()
|
||||
.withProperty(FACING, state.getValue(FACING)), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.netherBrickOven.getDefaultState()
|
||||
.withProperty(FACING, state.getValue(FACING)), 3);
|
||||
}
|
||||
|
||||
isLit = false;
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
tileEntity.validate();
|
||||
world.setTileEntity(pos, tileEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random random)
|
||||
{
|
||||
if (isLit2)
|
||||
{
|
||||
float f = pos.getX() + 0.5f;
|
||||
float f1 = pos.getY() + random.nextFloat() * 6.0f / 16.0f;
|
||||
float f2 = pos.getZ() + 0.5f;
|
||||
|
||||
float f3 = 0.5f;
|
||||
float f4 = random.nextFloat() * 0.6f - 0.2f;
|
||||
|
||||
if (state.getValue(FACING) == EnumFacing.WEST)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f - f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f - f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.EAST)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f + f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.NORTH)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f4, f1, f2 - f3, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f + f4, f1, f2 - f3, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.SOUTH)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f4, f1, f2 + f3, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f + f4, f1, f2 + f3, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Block block = world.getBlockState(pos.offset(EnumFacing.NORTH)).getBlock();
|
||||
Block block1 = world.getBlockState(pos.offset(EnumFacing.SOUTH)).getBlock();
|
||||
Block block2 = world.getBlockState(pos.offset(EnumFacing.WEST)).getBlock();
|
||||
Block block3 = world.getBlockState(pos.offset(EnumFacing.EAST)).getBlock();
|
||||
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||
|
||||
if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.EAST;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
world.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||
}
|
||||
|
||||
super.onBlockAdded(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int par3)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.netherBrickOven);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side,
|
||||
float clickX, float clickY, float clickZ)
|
||||
{
|
||||
player.openGui(ModMain.modInstance, BBGuiHandler.NETHERBRICKOVEN_ID, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
|
||||
int meta, EntityLivingBase placer)
|
||||
{
|
||||
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer,
|
||||
ItemStack stack)
|
||||
{
|
||||
world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
|
||||
|
||||
if (stack.hasDisplayName())
|
||||
{
|
||||
TileEntity teBase = world.getTileEntity(pos);
|
||||
if (teBase instanceof TileEntityNetherBrickOven)
|
||||
{
|
||||
TileEntityNetherBrickOven tileEntity = (TileEntityNetherBrickOven)teBase;
|
||||
tileEntity.setBlockName(stack.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World world, BlockPos pos)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.netherBrickOven);
|
||||
}
|
||||
|
||||
protected BlockState createBlockState()
|
||||
{
|
||||
return new BlockState(this, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Drop stuff everywhere
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!isLit)
|
||||
{
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof TileEntityNetherBrickOven)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(world, pos, (TileEntityNetherBrickOven)tileentity);
|
||||
world.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2)
|
||||
{
|
||||
return new TileEntityNetherBrickOven();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
package net.einsteinsci.betterbeginnings.blocks;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityObsidianKiln;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockObsidianKiln extends BlockContainer implements IBBName
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
private static boolean isLit;
|
||||
private final boolean isLit2; // strange why...
|
||||
|
||||
public BlockObsidianKiln(boolean lit)
|
||||
{
|
||||
super(Material.rock);
|
||||
|
||||
if (lit)
|
||||
{
|
||||
setLightLevel(0.875F);
|
||||
}
|
||||
else
|
||||
{
|
||||
setLightLevel(0F);
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
setUnlocalizedName(getName());
|
||||
|
||||
setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||
setHardness(2.0f);
|
||||
setResistance(10.0f);
|
||||
|
||||
isLit2 = lit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return isLit2 ? "obsidianKilnLit" : "obsidianKiln";
|
||||
}
|
||||
|
||||
public static void updateBlockState(boolean lit, World world, BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
isLit = true;
|
||||
|
||||
if (lit)
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.obsidianKilnLit.getDefaultState()
|
||||
.withProperty(FACING, state.getValue(FACING)), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.obsidianKiln.getDefaultState()
|
||||
.withProperty(FACING, state.getValue(FACING)), 3);
|
||||
}
|
||||
|
||||
isLit = false;
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
tileEntity.validate();
|
||||
world.setTileEntity(pos, tileEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random random)
|
||||
{
|
||||
if (isLit2)
|
||||
{
|
||||
float f = pos.getX() + 0.5f;
|
||||
float f1 = pos.getY() + random.nextFloat() * 6.0f / 16.0f;
|
||||
float f2 = pos.getZ() + 0.5f;
|
||||
|
||||
float f3 = 0.5f;
|
||||
float f4 = random.nextFloat() * 0.6f - 0.2f;
|
||||
|
||||
if (state.getValue(FACING) == EnumFacing.WEST)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f - f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f - f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.EAST)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f + f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.NORTH)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f4, f1, f2 - f3, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f + f4, f1, f2 - f3, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.SOUTH)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f4, f1, f2 + f3, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f + f4, f1, f2 + f3, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Block block = world.getBlockState(pos.offset(EnumFacing.NORTH)).getBlock();
|
||||
Block block1 = world.getBlockState(pos.offset(EnumFacing.SOUTH)).getBlock();
|
||||
Block block2 = world.getBlockState(pos.offset(EnumFacing.WEST)).getBlock();
|
||||
Block block3 = world.getBlockState(pos.offset(EnumFacing.EAST)).getBlock();
|
||||
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||
|
||||
if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.EAST;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
world.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||
}
|
||||
|
||||
super.onBlockAdded(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int par3)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.obsidianKiln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side,
|
||||
float clickX, float clickY, float clickZ)
|
||||
{
|
||||
player.openGui(ModMain.modInstance, BBGuiHandler.OBSIDIANKILN_ID, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
|
||||
int meta, EntityLivingBase placer)
|
||||
{
|
||||
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer,
|
||||
ItemStack stack)
|
||||
{
|
||||
world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
|
||||
|
||||
if (stack.hasDisplayName())
|
||||
{
|
||||
TileEntity teBase = world.getTileEntity(pos);
|
||||
if (teBase instanceof TileEntityObsidianKiln)
|
||||
{
|
||||
TileEntityObsidianKiln tileEntity = (TileEntityObsidianKiln)teBase;
|
||||
tileEntity.setBlockName(stack.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World world, BlockPos pos)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.obsidianKiln);
|
||||
}
|
||||
|
||||
protected BlockState createBlockState()
|
||||
{
|
||||
return new BlockState(this, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Drop stuff everywhere
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!isLit)
|
||||
{
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof TileEntityObsidianKiln)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(world, pos, (TileEntityObsidianKiln)tileentity);
|
||||
world.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2)
|
||||
{
|
||||
return new TileEntityObsidianKiln();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,244 @@
|
|||
package net.einsteinsci.betterbeginnings.blocks;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntitySmelter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockSmelter extends BlockContainer implements IBBName
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
|
||||
private static boolean isLit;
|
||||
private final boolean isLit2; // strange why...
|
||||
|
||||
public BlockSmelter(boolean lit)
|
||||
{
|
||||
super(Material.rock);
|
||||
|
||||
if (lit)
|
||||
{
|
||||
setLightLevel(0.875F);
|
||||
}
|
||||
else
|
||||
{
|
||||
setLightLevel(0F);
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
setUnlocalizedName(getName());
|
||||
|
||||
setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
|
||||
setHardness(1.5f);
|
||||
setResistance(10.0f);
|
||||
|
||||
isLit2 = lit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return isLit2 ? "smelterLit" : "smelter";
|
||||
}
|
||||
|
||||
public static void updateBlockState(boolean lit, World world, BlockPos pos)
|
||||
{
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
isLit = true;
|
||||
|
||||
if (lit)
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.smelterLit.getDefaultState()
|
||||
.withProperty(FACING, state.getValue(FACING)), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockState(pos, RegisterBlocks.smelter.getDefaultState()
|
||||
.withProperty(FACING, state.getValue(FACING)), 3);
|
||||
}
|
||||
|
||||
isLit = false;
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
tileEntity.validate();
|
||||
world.setTileEntity(pos, tileEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Drop stuff everywhere
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!isLit)
|
||||
{
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof TileEntitySmelter)
|
||||
{
|
||||
InventoryHelper.dropInventoryItems(world, pos, (TileEntitySmelter)tileentity);
|
||||
world.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
return ((EnumFacing)state.getValue(FACING)).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random random)
|
||||
{
|
||||
if (isLit2)
|
||||
{
|
||||
float f = pos.getX() + 0.5f;
|
||||
float f1 = pos.getY() + random.nextFloat() * 6.0f / 16.0f;
|
||||
float f2 = pos.getZ() + 0.5f;
|
||||
|
||||
float f3 = 0.5f;
|
||||
float f4 = random.nextFloat() * 0.6f - 0.2f;
|
||||
|
||||
if (state.getValue(FACING) == EnumFacing.WEST)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f - f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f - f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.EAST)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f + f3, f1, f2 + f4, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.NORTH)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f4, f1, f2 - f3, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f + f4, f1, f2 - f3, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
else if (state.getValue(FACING) == EnumFacing.SOUTH)
|
||||
{
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, f + f4, f1, f2 + f3, 0.0F, 0.0F, 0.0F);
|
||||
world.spawnParticle(EnumParticleTypes.FLAME, f + f4, f1, f2 + f3, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void onBlockAdded(World world, BlockPos pos, IBlockState state)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Block block = world.getBlockState(pos.offset(EnumFacing.NORTH)).getBlock();
|
||||
Block block1 = world.getBlockState(pos.offset(EnumFacing.SOUTH)).getBlock();
|
||||
Block block2 = world.getBlockState(pos.offset(EnumFacing.WEST)).getBlock();
|
||||
Block block3 = world.getBlockState(pos.offset(EnumFacing.EAST)).getBlock();
|
||||
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
|
||||
|
||||
if (enumfacing == EnumFacing.NORTH && block.isFullBlock() && !block1.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.SOUTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.SOUTH && block1.isFullBlock() && !block.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.NORTH;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.WEST && block2.isFullBlock() && !block3.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.EAST;
|
||||
}
|
||||
else if (enumfacing == EnumFacing.EAST && block3.isFullBlock() && !block2.isFullBlock())
|
||||
{
|
||||
enumfacing = EnumFacing.WEST;
|
||||
}
|
||||
|
||||
world.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
|
||||
}
|
||||
|
||||
super.onBlockAdded(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(IBlockState state, Random rand, int par3)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.smelter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side,
|
||||
float clickX, float clickY, float clickZ)
|
||||
{
|
||||
player.openGui(ModMain.modInstance, BBGuiHandler.SMELTER_ID, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ,
|
||||
int meta, EntityLivingBase placer)
|
||||
{
|
||||
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer,
|
||||
ItemStack stack)
|
||||
{
|
||||
world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
|
||||
|
||||
if (stack.hasDisplayName())
|
||||
{
|
||||
TileEntity teBase = world.getTileEntity(pos);
|
||||
if (teBase instanceof TileEntitySmelter)
|
||||
{
|
||||
TileEntitySmelter tileEntity = (TileEntitySmelter)teBase;
|
||||
tileEntity.setBlockName(stack.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World world, BlockPos pos)
|
||||
{
|
||||
return Item.getItemFromBlock(RegisterBlocks.smelter);
|
||||
}
|
||||
|
||||
protected BlockState createBlockState()
|
||||
{
|
||||
return new BlockState(this, FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int par2)
|
||||
{
|
||||
return new TileEntitySmelter();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
package net.einsteinsci.betterbeginnings.config;
|
||||
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class BBConfig
|
||||
{
|
||||
public static final String GENERAL = Configuration.CATEGORY_GENERAL;
|
||||
public static final String CRAFTING = "crafting";
|
||||
public static final String SMELTING = "smelting";
|
||||
|
||||
public static boolean greetUser;
|
||||
public static boolean debugLogging;
|
||||
public static boolean advancedCraftingForLotsOfThings;
|
||||
public static boolean requireAdvancedCrafting;
|
||||
public static boolean removeCraftedFoodRecipes;
|
||||
public static boolean canMakeVanillaWorkbench;
|
||||
public static boolean canMakeVanillaFurnace;
|
||||
public static boolean canMakeChainArmor;
|
||||
public static boolean removeWoodToolRecipes;
|
||||
public static boolean flamingAnimalsDropCharredMeat;
|
||||
public static boolean spidersDropString;
|
||||
public static boolean moreBones;
|
||||
public static boolean moreBonesPeacefulOnly;
|
||||
public static boolean spawnMarshmallows;
|
||||
public static boolean canSmelterDoKilnStuff;
|
||||
public static boolean removeSmeltingRecipes;
|
||||
public static boolean removeOnlyVanillaSmeltingRecipes;
|
||||
public static boolean makeStuffStackable;
|
||||
public static boolean canCampfireDoAllKilnStuff;
|
||||
|
||||
public static List<String> alwaysBreakable;
|
||||
public static List<String> alsoAxes;
|
||||
public static List<String> alsoPickaxes;
|
||||
public static List<String> alsoKnives;
|
||||
|
||||
public static void initialize()
|
||||
{
|
||||
greetUser = true;
|
||||
debugLogging = false;
|
||||
advancedCraftingForLotsOfThings = true;
|
||||
requireAdvancedCrafting = true;
|
||||
removeCraftedFoodRecipes = true;
|
||||
canMakeVanillaWorkbench = false;
|
||||
canMakeVanillaFurnace = false;
|
||||
canMakeChainArmor = true;
|
||||
removeWoodToolRecipes = true;
|
||||
flamingAnimalsDropCharredMeat = true;
|
||||
spidersDropString = false;
|
||||
moreBones = true;
|
||||
moreBonesPeacefulOnly = true;
|
||||
spawnMarshmallows = true;
|
||||
canSmelterDoKilnStuff = false;
|
||||
removeSmeltingRecipes = true;
|
||||
removeOnlyVanillaSmeltingRecipes = true;
|
||||
makeStuffStackable = true;
|
||||
canCampfireDoAllKilnStuff = false;
|
||||
|
||||
alwaysBreakable = new ArrayList<String>();
|
||||
alsoAxes = new ArrayList<String>();
|
||||
alsoPickaxes = new ArrayList<String>();
|
||||
alsoKnives = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public static void syncConfig(Configuration config)
|
||||
{
|
||||
//////////////
|
||||
// Booleans //
|
||||
//////////////
|
||||
|
||||
// General
|
||||
greetUser = config.getBoolean("Greet user", GENERAL, true, "Greet user upon login");
|
||||
debugLogging = config.getBoolean("Debug logging", GENERAL, false, "Log all kinds of stuff, for debug purposes");
|
||||
flamingAnimalsDropCharredMeat = config.getBoolean("Burn, Baby, Burn", GENERAL, true,
|
||||
"Animals that die by flame drop charred meat instead of vanilla cooked meat");
|
||||
spidersDropString = config.getBoolean("Spiders drop string", GENERAL, false,
|
||||
"Spiders drop vanilla string as well as silk.");
|
||||
moreBones = config.getBoolean("All bones", GENERAL, true,
|
||||
"Almost all mobs drop bones, not just skeletons");
|
||||
moreBonesPeacefulOnly = config.getBoolean("More bones only works on peaceful", GENERAL, true,
|
||||
"Non-skeleton mobs only drop bones on peaceful. Requires" +
|
||||
" 'All bones' to be true in order to do anything.");
|
||||
spawnMarshmallows = config.getBoolean("Generate marshmallows", GENERAL, true,
|
||||
"Marshmallows spawn in dungeons, mineshafts, desert temples, " +
|
||||
"and jungle temples.");
|
||||
makeStuffStackable = config.getBoolean("Make stuff stackable", GENERAL, true,
|
||||
"Makes items that should be stackable (doors, " +
|
||||
"minecarts, potions) stackable.");
|
||||
|
||||
// Crafting
|
||||
advancedCraftingForLotsOfThings = config.getBoolean("Advanced crafting for lots of things", CRAFTING, true,
|
||||
"Require Advanced Crafting for things like doors, " +
|
||||
"pistons, chests, etc.");
|
||||
requireAdvancedCrafting = config.getBoolean("Require Advanced Crafting", CRAFTING, true,
|
||||
"Disable vanilla crafting for recipes that require advanced " +
|
||||
"crafting table. Setting this to false sort of makes " +
|
||||
"this part of the mod pointless.");
|
||||
removeCraftedFoodRecipes = config.getBoolean("Remove Crafted Food Recipes", CRAFTING, true,
|
||||
"Remove crafting recipes of vanilla food items, enforcing the " +
|
||||
"use of the ovens.");
|
||||
canMakeVanillaWorkbench = config.getBoolean("Enable vanilla workbench recipe", CRAFTING, true,
|
||||
"Provide alternative recipe for vanilla crafting table");
|
||||
canMakeVanillaFurnace = config.getBoolean("Enable vanilla furnace recipe", CRAFTING, true,
|
||||
"Provide alternative recipe for vanilla furnace");
|
||||
canMakeChainArmor = config.getBoolean("Enable chain armor", CRAFTING, true,
|
||||
"Allow vanilla chain armor to be craftable from iron nuggets");
|
||||
removeWoodToolRecipes = config.getBoolean("Remove wooden tool recipes", CRAFTING, true,
|
||||
"Remove recipes for wooden pickaxe, axe, shovel, and hoe.");
|
||||
|
||||
// Smelting
|
||||
canSmelterDoKilnStuff = config.getBoolean("Smelter can make kiln products", SMELTING, false,
|
||||
"Allow smelter to make glass, bricks, smooth stone, etc.");
|
||||
|
||||
removeSmeltingRecipes = config.getBoolean("Disable vanilla smelting", SMELTING, true,
|
||||
"Remove recipes that normally use the vanilla furnace");
|
||||
removeOnlyVanillaSmeltingRecipes = config.getBoolean("Only remove smelting recipes for vanilla items",
|
||||
SMELTING, true,
|
||||
"Only remove furnace recipes for vanilla items/blocks. " +
|
||||
"Requires 'Disable vanilla smelting'.");
|
||||
canCampfireDoAllKilnStuff = config.getBoolean("Can campfire handle all kiln smelting", SMELTING, true,
|
||||
"Allow campfire to process all recipes kiln can, instead of " +
|
||||
"just a few.");
|
||||
|
||||
////////////
|
||||
// Arrays //
|
||||
////////////
|
||||
|
||||
String[] _alwaysBreakable = config.getStringList("Always breakable", GENERAL, new String[] {},
|
||||
"List of blocks always breakable. Use this format: " +
|
||||
"'modid:blockName'.");
|
||||
alwaysBreakable.clear();
|
||||
Collections.addAll(alwaysBreakable, _alwaysBreakable);
|
||||
|
||||
String[] _alsoAxes = config.getStringList("Also axes", GENERAL, new String[] {},
|
||||
"List of items that qualify as axes for breakable checks. " +
|
||||
"Use this format: 'modid:itemName'.");
|
||||
alsoAxes.clear();
|
||||
Collections.addAll(alsoAxes, _alsoAxes);
|
||||
|
||||
String[] _alsoPickaxes = config.getStringList("Also pickaxes", GENERAL, new String[] {},
|
||||
"List of items that qualify as pickaxes for breakable checks. " +
|
||||
"Use this format: 'modid:itemName'.");
|
||||
alsoPickaxes.clear();
|
||||
Collections.addAll(alsoPickaxes, _alsoPickaxes);
|
||||
|
||||
String[] _alsoKnives = config.getStringList("Also knives", GENERAL, new String[] {},
|
||||
"List of items that qualify as knives for breakable checks. " +
|
||||
"Use this format: 'modid:itemName'.");
|
||||
alsoKnives.clear();
|
||||
Collections.addAll(alsoKnives, _alsoKnives);
|
||||
|
||||
//////////
|
||||
// Save //
|
||||
//////////
|
||||
|
||||
if (config.hasChanged())
|
||||
{
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package net.einsteinsci.betterbeginnings.config;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BBConfigGui extends GuiConfig
|
||||
{
|
||||
public BBConfigGui(GuiScreen parent)
|
||||
{
|
||||
super(parent, getAllCategories(), ModMain.MODID, false, false,
|
||||
GuiConfig.getAbridgedConfigPath(ModMain.configFile.toString()));
|
||||
}
|
||||
|
||||
public static List<IConfigElement> getAllCategories()
|
||||
{
|
||||
List<IConfigElement> all = new ConfigElement(ModMain.configFile.getCategory(BBConfig.GENERAL))
|
||||
.getChildElements();
|
||||
all.addAll(new ConfigElement(ModMain.configFile.getCategory(BBConfig.CRAFTING)).getChildElements());
|
||||
all.addAll(new ConfigElement(ModMain.configFile.getCategory(BBConfig.SMELTING)).getChildElements());
|
||||
|
||||
return all;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package net.einsteinsci.betterbeginnings.config;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class BBConfigGuiFactory implements IModGuiFactory
|
||||
{
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance)
|
||||
{
|
||||
// Nothin here
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass()
|
||||
{
|
||||
return BBConfigGui.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,479 @@
|
|||
package net.einsteinsci.betterbeginnings.event;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.config.BBConfig;
|
||||
import net.einsteinsci.betterbeginnings.items.ItemHammer;
|
||||
import net.einsteinsci.betterbeginnings.items.ItemKnife;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterItems;
|
||||
import net.einsteinsci.betterbeginnings.register.achievement.RegisterAchievements;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityCampfire;
|
||||
import net.einsteinsci.betterbeginnings.util.ChatUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.*;
|
||||
import net.minecraft.entity.passive.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class BBEventHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent e)
|
||||
{
|
||||
if (BBConfig.greetUser)
|
||||
{
|
||||
ChatUtil.sendModChatToPlayer(e.player, ChatUtil.LIME + "Better Beginnings loaded successfully.");
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent e)
|
||||
{
|
||||
if (e.modID.equals(ModMain.MODID))
|
||||
{
|
||||
BBConfig.syncConfig(ModMain.configFile);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onItemTooltip(ItemTooltipEvent e)
|
||||
{
|
||||
Item item = e.itemStack.getItem();
|
||||
|
||||
if (item == RegisterItems.charredMeat)
|
||||
{
|
||||
e.toolTip.add("Not to be confused with charcoal");
|
||||
}
|
||||
|
||||
if (item == RegisterItems.ironNugget)
|
||||
{
|
||||
e.toolTip.add("Good for hinges and rivets");
|
||||
}
|
||||
|
||||
if (item == RegisterItems.flintKnife)
|
||||
{
|
||||
e.toolTip.add("Don't bring it to a gunfight");
|
||||
}
|
||||
|
||||
if (item == RegisterItems.noobWoodSword && EnchantmentHelper.getEnchantments(e.itemStack).isEmpty())
|
||||
{
|
||||
e.toolTip.add(ChatUtil.BLUE + "+0 Attack Damage");
|
||||
}
|
||||
|
||||
if (item == RegisterItems.testItem)
|
||||
{
|
||||
e.toolTip.add(ChatUtil.PINK + "For dev testing only. What it does changes from one version to the next.");
|
||||
}
|
||||
|
||||
if (item == RegisterItems.pan)
|
||||
{
|
||||
e.toolTip.add(ChatUtil.BLUE + "Fry stuff over a campfire!");
|
||||
}
|
||||
|
||||
if (isWIP(e.itemStack))
|
||||
{
|
||||
e.toolTip.add(ChatUtil.RED + "WIP. May not be fully functional.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWIP(ItemStack stack)
|
||||
{
|
||||
List<ItemStack> wip = new ArrayList<>();
|
||||
|
||||
wip.add(new ItemStack(RegisterItems.clothBoots));
|
||||
wip.add(new ItemStack(RegisterItems.clothPants));
|
||||
wip.add(new ItemStack(RegisterItems.clothShirt));
|
||||
wip.add(new ItemStack(RegisterItems.clothHat));
|
||||
wip.add(new ItemStack(RegisterItems.roastingStick));
|
||||
wip.add(new ItemStack(RegisterItems.roastingStickRawMallow));
|
||||
wip.add(new ItemStack(RegisterItems.roastingStickCookedMallow));
|
||||
|
||||
for (ItemStack test : wip)
|
||||
{
|
||||
if (stack.getItem() == test.getItem())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockBreak(BlockEvent.BreakEvent e)
|
||||
{
|
||||
// Let's leave this to the professionals
|
||||
BlockBreakHelper.handleBlockBreaking(e);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRightClick(PlayerInteractEvent e)
|
||||
{
|
||||
if (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
if (e.entityPlayer.getHeldItem() != null)
|
||||
{
|
||||
ItemStack stack = e.entityPlayer.getHeldItem();
|
||||
Item item = stack.getItem();
|
||||
|
||||
if (item == Items.flint_and_steel || item == RegisterItems.fireBow)
|
||||
{
|
||||
Block b = e.world.getBlockState(e.pos).getBlock();
|
||||
|
||||
if (b == RegisterBlocks.campfire || b == RegisterBlocks.campfireLit)
|
||||
{
|
||||
TileEntityCampfire campfire = (TileEntityCampfire)e.world.getTileEntity(e.pos);
|
||||
|
||||
campfire.lightFuel(); // Light it.
|
||||
e.entityPlayer.getHeldItem().damageItem(1, e.entityPlayer);
|
||||
if (item == Items.flint_and_steel)
|
||||
{
|
||||
e.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockDrops(BlockEvent.HarvestDropsEvent e)
|
||||
{
|
||||
Block block = e.state.getBlock();
|
||||
EntityPlayer player = e.harvester;
|
||||
|
||||
// All onBlockDrops activity that does not have to do with players must
|
||||
// occur before here.
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack held = player.getHeldItem();
|
||||
Random rand = player.worldObj.rand;
|
||||
|
||||
// Knife silk-touching for vines
|
||||
if (block == Blocks.vine && !e.isSilkTouching)
|
||||
{
|
||||
if (held != null)
|
||||
{
|
||||
if (held.getItem() instanceof ItemKnife)
|
||||
{
|
||||
if (rand.nextInt(8) == 0)
|
||||
{
|
||||
e.drops.add(new ItemStack(Blocks.vine));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Knife silk-touching for grass/bushes
|
||||
if ((block == Blocks.tallgrass || block == Blocks.deadbush) && !e.isSilkTouching)
|
||||
{
|
||||
if (held != null)
|
||||
{
|
||||
if (held.getItem() instanceof ItemKnife)
|
||||
{
|
||||
if (rand.nextInt(8) == 0)
|
||||
{
|
||||
int meta = block.getMetaFromState(e.state);
|
||||
e.drops.add(new ItemStack(block, 1, meta));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hammer
|
||||
if (held != null)
|
||||
{
|
||||
if (held.getItem() instanceof ItemHammer)
|
||||
{
|
||||
ItemStack crushResult = ItemHammer.getCrushResult(block);
|
||||
if (crushResult != null)
|
||||
{
|
||||
e.drops.clear();
|
||||
e.drops.add(crushResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Makes sure emergency escape mechanic does not let blocks fall out (like logs)
|
||||
ItemStack heldItemStack = player.getHeldItem();
|
||||
|
||||
int neededHarvestLevel = block.getHarvestLevel(e.state);
|
||||
String neededToolClass = block.getHarvestTool(e.state);
|
||||
int usedHarvestLevel = 0;
|
||||
String usedToolClass = null;
|
||||
if (heldItemStack != null)
|
||||
{
|
||||
for (String toolClass : heldItemStack.getItem().getToolClasses(heldItemStack))
|
||||
{
|
||||
int hl = heldItemStack.getItem().getHarvestLevel(heldItemStack, toolClass);
|
||||
if (hl >= usedHarvestLevel)
|
||||
{
|
||||
usedHarvestLevel = hl;
|
||||
usedToolClass = toolClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (neededToolClass == null || neededToolClass.equalsIgnoreCase("shovel") ||
|
||||
neededToolClass.equalsIgnoreCase("null"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (usedToolClass == null || !usedToolClass.equalsIgnoreCase(neededToolClass) ||
|
||||
usedHarvestLevel < neededHarvestLevel)
|
||||
{
|
||||
e.drops.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onItemSmelted(PlayerEvent.ItemSmeltedEvent e)
|
||||
{
|
||||
if (e.smelting.getItem() == Items.golden_apple && e.smelting.getItemDamage() == 1)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "notchApple");
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onItemCrafted(PlayerEvent.ItemCraftedEvent e)
|
||||
{
|
||||
// To fix duplication glitch (#27)
|
||||
if (e.crafting.getItem() instanceof ItemKnife)
|
||||
{
|
||||
for (int i = 0; i < e.craftMatrix.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack stack = e.craftMatrix.getStackInSlot(i);
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack.getItem() instanceof ItemKnife)
|
||||
{
|
||||
--stack.stackSize;
|
||||
|
||||
if (stack.stackSize <= 0)
|
||||
{
|
||||
e.craftMatrix.setInventorySlotContents(i, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.craftMatrix.setInventorySlotContents(i, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == RegisterItems.flintKnife)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "flintKnife");
|
||||
}
|
||||
else if (e.crafting.getItem() instanceof ItemKnife)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "upgradeKnife");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == Items.string)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "makeString");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == RegisterItems.twine)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "makeTwine");
|
||||
}
|
||||
|
||||
for (int i = 0; i < e.craftMatrix.getSizeInventory(); ++i)
|
||||
{
|
||||
if (e.craftMatrix.getStackInSlot(i) != null)
|
||||
{
|
||||
ItemStack current = e.craftMatrix.getStackInSlot(i);
|
||||
if (current.getItem() instanceof ItemKnife && e.crafting.getItem() == Items.stick)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "makeSticks");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == RegisterItems.flintHatchet)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "makeHatchet");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() instanceof ItemSword)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "makeSword");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == Item.getItemFromBlock(RegisterBlocks.infusionRepairStation))
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "infusionRepair");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == RegisterItems.boneShard)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "boneShards");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == RegisterItems.bonePickaxe)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "bonePick");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == Item.getItemFromBlock(RegisterBlocks.kiln))
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "makeKiln");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == Item.getItemFromBlock(RegisterBlocks.obsidianKiln))
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "obsidianKiln");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == Item.getItemFromBlock(RegisterBlocks.smelter))
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "makeSmelter");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == Item.getItemFromBlock(RegisterBlocks.enderSmelter))
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "enderSmelter");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == Item.getItemFromBlock(RegisterBlocks.brickOven))
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "makeBrickOven");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == Items.cake)
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "cake");
|
||||
}
|
||||
|
||||
if (e.crafting.getItem() == Item.getItemFromBlock(RegisterBlocks.netherBrickOven))
|
||||
{
|
||||
RegisterAchievements.achievementGet(e.player, "netherBrickOven");
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityLivingDrops(LivingDropsEvent e)
|
||||
{
|
||||
Random rand = e.entity.worldObj.rand;
|
||||
|
||||
if (e.entityLiving instanceof EntitySpider) // Includes cave spiders
|
||||
{
|
||||
if (!BBConfig.spidersDropString)
|
||||
{
|
||||
Iterator iterator = e.drops.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
EntityItem entityItem = (EntityItem)iterator.next();
|
||||
Item item = entityItem.getEntityItem().getItem();
|
||||
if (item == Items.string)
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int dropCount = rand.nextInt(3 + e.lootingLevel) + 2;
|
||||
for (int i = 0; i < dropCount; ++i)
|
||||
{
|
||||
e.entityLiving.dropItem(RegisterItems.silk, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (BBConfig.moreBones)
|
||||
{
|
||||
if (!BBConfig.moreBonesPeacefulOnly || e.entity.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL)
|
||||
{
|
||||
int maxBones = 0;
|
||||
int maxShards = 0;
|
||||
|
||||
if (e.entityLiving instanceof EntityCow)
|
||||
{
|
||||
maxBones = 4;
|
||||
}
|
||||
if (e.entityLiving instanceof EntitySheep || e.entityLiving instanceof EntityPig)
|
||||
{
|
||||
maxBones = 3;
|
||||
}
|
||||
if (e.entityLiving instanceof EntityChicken || e.entityLiving instanceof EntityOcelot)
|
||||
{
|
||||
maxShards = 3;
|
||||
}
|
||||
if (e.entityLiving instanceof EntityZombie)
|
||||
{
|
||||
maxBones = 2;
|
||||
maxShards = 3;
|
||||
}
|
||||
|
||||
if (maxBones > 0 && e.recentlyHit && !e.entityLiving.isChild())
|
||||
{
|
||||
int dropCount = rand.nextInt(maxBones + e.lootingLevel);
|
||||
for (int i = 0; i < dropCount; ++i)
|
||||
{
|
||||
e.entityLiving.dropItem(Items.bone, 1);
|
||||
}
|
||||
}
|
||||
if (maxShards > 0 && e.recentlyHit && !e.entityLiving.isChild())
|
||||
{
|
||||
int dropCount = rand.nextInt(maxShards + e.lootingLevel);
|
||||
for (int i = 0; i < dropCount; ++i)
|
||||
{
|
||||
e.entityLiving.dropItem(RegisterItems.boneShard, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (e.entityLiving instanceof EntitySkeleton)
|
||||
{
|
||||
int dropCount = rand.nextInt(3 + e.lootingLevel);
|
||||
e.entityLiving.dropItem(Items.bone, 1);
|
||||
e.entityLiving.dropItem(RegisterItems.boneShard, dropCount);
|
||||
}
|
||||
}
|
||||
|
||||
if (BBConfig.flamingAnimalsDropCharredMeat)
|
||||
{
|
||||
// Flaming mobs drop charred meat instead of cooked meats
|
||||
if (e.entityLiving instanceof EntityCow || e.entityLiving instanceof EntityPig ||
|
||||
e.entityLiving instanceof EntityChicken)
|
||||
{
|
||||
int charredDrops = 0;
|
||||
|
||||
Iterator iterator = e.drops.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
EntityItem entityItem = (EntityItem)iterator.next();
|
||||
Item item = entityItem.getEntityItem().getItem();
|
||||
if (item == Items.cooked_beef || item == Items.cooked_porkchop || item == Items.cooked_chicken)
|
||||
{
|
||||
iterator.remove();
|
||||
charredDrops += entityItem.getEntityItem().stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
e.entityLiving.dropItem(RegisterItems.charredMeat, charredDrops);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
package net.einsteinsci.betterbeginnings.event;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.items.ItemKnife;
|
||||
import net.einsteinsci.betterbeginnings.util.ChatUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BlockBreakHelper
|
||||
{
|
||||
public static final Map<EntityPlayer, BlockPos> brokenOnce = new HashMap<>();
|
||||
|
||||
// returns whether to cancel drops or not
|
||||
public static void handleBlockBreaking(BlockEvent.BreakEvent e)
|
||||
{
|
||||
Block block = e.state.getBlock();
|
||||
EntityPlayer player = e.getPlayer();
|
||||
ItemStack heldItemStack = player.getHeldItem();
|
||||
|
||||
if (player.capabilities.isCreativeMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int neededHarvestLevel = block.getHarvestLevel(e.state);
|
||||
String neededToolClass = block.getHarvestTool(e.state);
|
||||
int usedHarvestLevel = 0;
|
||||
String usedToolClass = null;
|
||||
String stackName = heldItemStack != null ? heldItemStack.getDisplayName() : "NULL";
|
||||
|
||||
if (heldItemStack != null)
|
||||
{
|
||||
for (String toolClass : heldItemStack.getItem().getToolClasses(heldItemStack))
|
||||
{
|
||||
int hl = heldItemStack.getItem().getHarvestLevel(heldItemStack, toolClass);
|
||||
if (hl >= usedHarvestLevel)
|
||||
{
|
||||
usedHarvestLevel = hl;
|
||||
usedToolClass = toolClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean cancel = false;
|
||||
|
||||
if (heldItemStack != null)
|
||||
{
|
||||
if (heldItemStack.getItem() instanceof ItemKnife &&
|
||||
ItemKnife.getBreakable().contains(block))
|
||||
{
|
||||
return; // allows knife to do stuff.
|
||||
}
|
||||
}
|
||||
|
||||
if (neededToolClass == null ||
|
||||
neededToolClass.equalsIgnoreCase("shovel") ||
|
||||
neededToolClass.equalsIgnoreCase("null"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (neededToolClass.equalsIgnoreCase(usedToolClass))
|
||||
{
|
||||
if (usedHarvestLevel < neededHarvestLevel)
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (usedToolClass == null || usedToolClass.equalsIgnoreCase("null"))
|
||||
{
|
||||
if (e.world.getDifficulty() != EnumDifficulty.PEACEFUL)
|
||||
{
|
||||
player.attackEntityFrom(new DamageSourceFace(block), 6.0f);
|
||||
}
|
||||
|
||||
if (!brokenOnce.containsKey(player) || brokenOnce.get(player) == null ||
|
||||
!brokenOnce.get(player).equals(e.pos))
|
||||
{
|
||||
ChatUtil.sendModChatToPlayer(player, "Almost. Once more should do it.");
|
||||
brokenOnce.put(player, e.pos);
|
||||
|
||||
// skip other notification
|
||||
e.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChatUtil.sendModChatToPlayer(player, "Ouch! But at least it worked.");
|
||||
brokenOnce.put(player, null);
|
||||
}
|
||||
|
||||
ModMain.Log(Level.INFO, "Block break failed for " + stackName + " on " + block.getUnlocalizedName());
|
||||
ModMain.Log(Level.INFO, " Required tool class: " + neededToolClass + ", supplied: " + usedToolClass);
|
||||
ModMain.Log(Level.INFO, " Minimum harvest level: " + neededHarvestLevel + ", supplied: " +
|
||||
usedHarvestLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (cancel)
|
||||
{
|
||||
ModMain.Log(Level.INFO, "Block break failed for " + stackName + " on " + block.getUnlocalizedName());
|
||||
ModMain.Log(Level.INFO, " Required tool class: " + neededToolClass + ", supplied: " + usedToolClass);
|
||||
ModMain.Log(Level.INFO, " Minimum harvest level: " + neededHarvestLevel + ", supplied: " +
|
||||
usedHarvestLevel);
|
||||
|
||||
ChatUtil.sendModChatToPlayer(player, "Wrong tool!");
|
||||
ChatUtil.sendModChatToPlayer(player,
|
||||
"Requires " + getToolLevelName(neededHarvestLevel) + " " + neededToolClass);
|
||||
|
||||
e.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getToolLevelName(int level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case 0:
|
||||
return "WOOD";
|
||||
case 1:
|
||||
return "STONE";
|
||||
case 2:
|
||||
return "IRON";
|
||||
case 3:
|
||||
return "DIAMOND";
|
||||
default:
|
||||
return "Level " + level;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package net.einsteinsci.betterbeginnings.event;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
public class DamageSourceFace extends DamageSource
|
||||
{
|
||||
public Block faceHurt;
|
||||
|
||||
public DamageSourceFace(Block block)
|
||||
{
|
||||
super("face");
|
||||
faceHurt = block;
|
||||
setDamageBypassesArmor();
|
||||
setDifficultyScaled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDeathMessage(EntityLivingBase mob)
|
||||
{
|
||||
return new ChatComponentTranslation("death.face", mob.getName(), faceHurt.getLocalizedName());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package net.einsteinsci.betterbeginnings.event;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.config.BBConfig;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
import net.minecraftforge.common.ChestGenHooks;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/11/2014.
|
||||
*/
|
||||
public class Worldgen
|
||||
{
|
||||
public static void addWorldgen()
|
||||
{
|
||||
if(BBConfig.spawnMarshmallows){
|
||||
ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(
|
||||
RegisterItems.marshmallow), 1, 5, 100));
|
||||
ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_DESERT_CHEST)
|
||||
.addItem(new WeightedRandomChestContent(new ItemStack(RegisterItems.marshmallow), 1, 10, 200));
|
||||
ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(
|
||||
RegisterItems.marshmallow), 1, 10, 200));
|
||||
ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CROSSING)
|
||||
.addItem(new WeightedRandomChestContent(new ItemStack(RegisterItems.marshmallow), 1, 12, 150));
|
||||
ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CORRIDOR)
|
||||
.addItem(new WeightedRandomChestContent(new ItemStack(RegisterItems.marshmallow), 1, 12, 150));
|
||||
ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR)
|
||||
.addItem(new WeightedRandomChestContent(new ItemStack(RegisterItems.marshmallow), 1, 12, 150));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.inventory.*;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.*;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
|
||||
/**
|
||||
* Some issues with this. Please note the server doesn't register items or blocks. At all.
|
||||
*/
|
||||
public class BBGuiHandler implements IGuiHandler
|
||||
{
|
||||
public static final int KILN_ID = 0;
|
||||
public static final int SIMPLEWORKBENCH_ID = 1;
|
||||
public static final int DOUBLEWORKBENCH_ID = 2;
|
||||
public static final int BRICKOVEN_ID = 3;
|
||||
public static final int SMELTER_ID = 4;
|
||||
public static final int INFUSIONREPAIR_ID = 5;
|
||||
public static final int OBSIDIANKILN_ID = 6;
|
||||
public static final int NETHERBRICKOVEN_ID = 7;
|
||||
public static final int ENDERSMELTER_ID = 8;
|
||||
public static final int CAMPFIRE_ID = 9;
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
if (ID == KILN_ID)
|
||||
{
|
||||
TileEntityKiln tileEntityKiln = (TileEntityKiln)world.getTileEntity(pos);
|
||||
return new ContainerKiln(player.inventory, tileEntityKiln);
|
||||
}
|
||||
|
||||
if (ID == SIMPLEWORKBENCH_ID)
|
||||
{
|
||||
return new ContainerSimpleWorkbench(player.inventory, world, pos);
|
||||
}
|
||||
|
||||
if (ID == DOUBLEWORKBENCH_ID)
|
||||
{
|
||||
return new ContainerDoubleWorkbench(player.inventory, world, pos);
|
||||
}
|
||||
|
||||
if (ID == BRICKOVEN_ID)
|
||||
{
|
||||
TileEntityBrickOven brickOven = (TileEntityBrickOven)world.getTileEntity(pos);
|
||||
return new ContainerBrickOven(player.inventory, brickOven);
|
||||
}
|
||||
|
||||
if (ID == SMELTER_ID)
|
||||
{
|
||||
TileEntitySmelter smelter = (TileEntitySmelter)world.getTileEntity(pos);
|
||||
return new ContainerSmelter(player.inventory, smelter);
|
||||
}
|
||||
|
||||
if (ID == INFUSIONREPAIR_ID)
|
||||
{
|
||||
return new ContainerInfusionRepair(player.inventory, world, pos);
|
||||
}
|
||||
|
||||
if (ID == OBSIDIANKILN_ID)
|
||||
{
|
||||
TileEntityObsidianKiln obsKiln = (TileEntityObsidianKiln)world.getTileEntity(pos);
|
||||
return new ContainerObsidianKiln(player.inventory, obsKiln);
|
||||
}
|
||||
|
||||
if (ID == NETHERBRICKOVEN_ID)
|
||||
{
|
||||
TileEntityNetherBrickOven nbOven = (TileEntityNetherBrickOven)world.getTileEntity(pos);
|
||||
return new ContainerNetherBrickOven(player.inventory, nbOven);
|
||||
}
|
||||
|
||||
if (ID == ENDERSMELTER_ID)
|
||||
{
|
||||
TileEntityEnderSmelter enderSmelter = (TileEntityEnderSmelter)world.getTileEntity(pos);
|
||||
return new ContainerEnderSmelter(player.inventory, enderSmelter);
|
||||
}
|
||||
|
||||
if (ID == CAMPFIRE_ID)
|
||||
{
|
||||
TileEntityCampfire campfire = (TileEntityCampfire)world.getTileEntity(pos);
|
||||
return new ContainerCampfire(player.inventory, campfire);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
if (ID == KILN_ID)
|
||||
{
|
||||
TileEntityKiln tileEntityKiln = (TileEntityKiln)world.getTileEntity(pos);
|
||||
return new GuiKiln(player.inventory, tileEntityKiln);
|
||||
}
|
||||
|
||||
if (ID == SIMPLEWORKBENCH_ID)
|
||||
{
|
||||
return new GuiSimpleWorkbench(player.inventory, world, pos);
|
||||
}
|
||||
|
||||
if (ID == DOUBLEWORKBENCH_ID)
|
||||
{
|
||||
return new GuiDoubleWorkbench(player.inventory, world, pos);
|
||||
}
|
||||
|
||||
if (ID == BRICKOVEN_ID)
|
||||
{
|
||||
TileEntityBrickOven brickOven = (TileEntityBrickOven)world.getTileEntity(pos);
|
||||
return new GuiBrickOven(player.inventory, brickOven);
|
||||
}
|
||||
|
||||
if (ID == SMELTER_ID)
|
||||
{
|
||||
TileEntitySmelter smelter = (TileEntitySmelter)world.getTileEntity(pos);
|
||||
return new GuiSmelter(player.inventory, smelter);
|
||||
}
|
||||
|
||||
if (ID == INFUSIONREPAIR_ID)
|
||||
{
|
||||
return new GuiInfusionRepair(player.inventory, world, pos);
|
||||
}
|
||||
|
||||
if (ID == OBSIDIANKILN_ID)
|
||||
{
|
||||
TileEntityObsidianKiln obsKiln = (TileEntityObsidianKiln)world.getTileEntity(pos);
|
||||
return new GuiObsidianKiln(player.inventory, obsKiln);
|
||||
}
|
||||
|
||||
if (ID == NETHERBRICKOVEN_ID)
|
||||
{
|
||||
TileEntityNetherBrickOven nbOven = (TileEntityNetherBrickOven)world.getTileEntity(pos);
|
||||
return new GuiNetherBrickOven(player.inventory, nbOven);
|
||||
}
|
||||
|
||||
if (ID == ENDERSMELTER_ID)
|
||||
{
|
||||
TileEntityEnderSmelter enderSmelter = (TileEntityEnderSmelter)world.getTileEntity(pos);
|
||||
return new GuiEnderSmelter(player.inventory, enderSmelter);
|
||||
}
|
||||
|
||||
if (ID == CAMPFIRE_ID)
|
||||
{
|
||||
TileEntityCampfire campfire = (TileEntityCampfire)world.getTileEntity(pos);
|
||||
return new GuiCampfire(player.inventory, campfire);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.inventory.ContainerBrickOven;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiBrickOven extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation ovenGuiTextures = new ResourceLocation(ModMain.MODID +
|
||||
":textures/gui/container/brickOven.png");
|
||||
private TileEntityBrickOven tileBrickOven;
|
||||
|
||||
public GuiBrickOven(InventoryPlayer inventory, TileEntityBrickOven tile)
|
||||
{
|
||||
super(new ContainerBrickOven(inventory, tile));
|
||||
tileBrickOven = tile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
String string = tileBrickOven.hasCustomName() ? tileBrickOven.getName() : I18n.format(tileBrickOven.getName());
|
||||
fontRendererObj.drawString(string, xSize / 2 - fontRendererObj.getStringWidth(string), 6, 4210752);
|
||||
fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 94, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
mc.getTextureManager().bindTexture(ovenGuiTextures);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
int i1;
|
||||
|
||||
if (tileBrickOven.isBurning())
|
||||
{
|
||||
i1 = tileBrickOven.getBurnTimeRemainingScaled(12);
|
||||
drawTexturedModalRect(k + 92, l + 41 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
|
||||
}
|
||||
|
||||
i1 = tileBrickOven.getCookProgressScaled(24);
|
||||
drawTexturedModalRect(k + 89, l + 20, 176, 14, i1 + 1, 16);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.inventory.ContainerCampfire;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityCampfire;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiCampfire extends GuiContainer
|
||||
{
|
||||
|
||||
private static final ResourceLocation campfireGuiTextures =
|
||||
new ResourceLocation(ModMain.MODID + ":textures/gui/container/campfire.png");
|
||||
|
||||
private TileEntityCampfire tileCampfire;
|
||||
|
||||
public GuiCampfire(InventoryPlayer invPlayer, TileEntityCampfire tile)
|
||||
{
|
||||
super(new ContainerCampfire(invPlayer, tile));
|
||||
tileCampfire = tile;
|
||||
xSize = 176;
|
||||
ySize = 166;
|
||||
}
|
||||
|
||||
public void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 96 + 4, 4210752);
|
||||
}
|
||||
|
||||
public void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
mc.getTextureManager().bindTexture(campfireGuiTextures);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
int i;
|
||||
|
||||
if (tileCampfire.isBurning())
|
||||
{
|
||||
i = tileCampfire.getBurnTimeRemainingScaled(22);
|
||||
drawTexturedModalRect(k + 58, l + 32 + 22 - i, 176, 22 - i, 14, i);
|
||||
}
|
||||
if (tileCampfire.isDecaying())
|
||||
{
|
||||
i = tileCampfire.getDecayTimeRemainingScaled(16);
|
||||
// x y u v w h
|
||||
int x = k + 77;
|
||||
int y = l + 57 + 16 - i;
|
||||
int u = 176;
|
||||
int v = 55 - i;
|
||||
int w = 3;
|
||||
int h = i;
|
||||
drawTexturedModalRect(x, y, u, v, w, h);
|
||||
}
|
||||
|
||||
i = tileCampfire.getCookProgressScaled(23);
|
||||
drawTexturedModalRect(k + 82, l + 34, 177, 22, i, 16);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.inventory.ContainerDoubleWorkbench;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.*;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiDoubleWorkbench extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation workbenchGuiTextures = new ResourceLocation(ModMain.MODID +
|
||||
":textures/gui/container/doubleWorkbench.png");
|
||||
|
||||
private final ContainerDoubleWorkbench container;
|
||||
|
||||
//private final RenderItemPartialTransparency partialTransItemRenderer = new RenderItemPartialTransparency();
|
||||
|
||||
public GuiDoubleWorkbench(InventoryPlayer invPlayer, World world, BlockPos pos)
|
||||
{
|
||||
super(new ContainerDoubleWorkbench(invPlayer, world, pos));
|
||||
|
||||
container = (ContainerDoubleWorkbench)inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int xMouse, int yMouse, float par3)
|
||||
{
|
||||
super.drawScreen(xMouse, yMouse, par3);
|
||||
|
||||
renderTransparentItems();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
// I'm guessing the really big number at the end is the z layer.
|
||||
fontRendererObj.drawString(I18n.format("container.craftingdouble"), 33, 6, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(workbenchGuiTextures);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
|
||||
// renderTransparentItems();
|
||||
}
|
||||
|
||||
public void renderTransparentItems()
|
||||
{
|
||||
if (AdvancedCraftingHandler.crafting().hasRecipe(container.craftMatrix, container.worldObj))
|
||||
{
|
||||
for (AdvancedRecipe recipe : AdvancedCraftingHandler.crafting().recipes)
|
||||
{
|
||||
if (recipe.matchesMostly(container.craftMatrix, container.worldObj))
|
||||
{
|
||||
for (int i = 0; i < recipe.getNeededMaterials().length; ++i)
|
||||
{
|
||||
OreRecipeElement neededElement = recipe.getNeededMaterials()[i];
|
||||
ItemStack needed = neededElement.getFirst().copy();
|
||||
|
||||
if (needed.getItemDamage() == OreDictionary.WILDCARD_VALUE)
|
||||
{
|
||||
needed.setItemDamage(0);
|
||||
}
|
||||
|
||||
Slot slot = container.matSlots[i];
|
||||
if (container.addedMats.getStackInSlot(i) == null)
|
||||
{
|
||||
drawItemStack(needed, (width - xSize) / 2 + slot.xDisplayPosition, (height - ySize) / 2 +
|
||||
slot.yDisplayPosition, "" + needed.stackSize);
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack result = recipe.getRecipeOutput();
|
||||
Slot slot = container.resultSlot;
|
||||
if (container.craftResult.getStackInSlot(0) == null)
|
||||
{
|
||||
drawItemStack(result, (width - xSize) / 2 + slot.xDisplayPosition, (height - ySize) / 2 +
|
||||
slot.yDisplayPosition, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawItemStack(ItemStack stack, int xPos, int yPos, String note)
|
||||
{
|
||||
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
|
||||
zLevel = 200.0F;
|
||||
//partialTransItemRenderer.zLevel = 200.0F;
|
||||
FontRenderer font = null;
|
||||
if (stack != null)
|
||||
{
|
||||
font = stack.getItem().getFontRenderer(stack);
|
||||
}
|
||||
if (font == null)
|
||||
{
|
||||
font = fontRendererObj;
|
||||
}
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
//partialTransItemRenderer.renderItemAndEffectIntoGUI(font, mc.getTextureManager(), stack, xPos, yPos);
|
||||
//partialTransItemRenderer.renderItemOverlayIntoGUI(font, mc.getTextureManager(), stack, xPos, yPos, note);
|
||||
zLevel = 0.0F;
|
||||
//partialTransItemRenderer.zLevel = 0.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Buffer ;)
|
|
@ -0,0 +1,98 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.inventory.ContainerEnderSmelter;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityEnderSmelter;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/21/2014.
|
||||
*/
|
||||
public class GuiEnderSmelter extends GuiContainer
|
||||
{
|
||||
// Same gui texture.
|
||||
private static final ResourceLocation kilnGuiTextures = new ResourceLocation(ModMain.MODID +
|
||||
":textures/gui/container/smelter.png");
|
||||
//RenderItemPartialTransparency partialTransItemRenderer = new RenderItemPartialTransparency();
|
||||
private TileEntityEnderSmelter tileSmelter;
|
||||
|
||||
public GuiEnderSmelter(InventoryPlayer invPlayer, TileEntityEnderSmelter tile)
|
||||
{
|
||||
super(new ContainerEnderSmelter(invPlayer, tile));
|
||||
tileSmelter = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
String string =
|
||||
tileSmelter.hasCustomName() ? tileSmelter.getName() : I18n.format(
|
||||
tileSmelter.getName());
|
||||
fontRendererObj.drawString(string, xSize / 2 - fontRendererObj.getStringWidth(string), 6, 4210752);
|
||||
fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 94, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
mc.getTextureManager().bindTexture(kilnGuiTextures);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
int i1;
|
||||
|
||||
if (tileSmelter.isBurning())
|
||||
{
|
||||
i1 = tileSmelter.getBurnTimeRemainingScaled(12);
|
||||
drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
|
||||
}
|
||||
|
||||
i1 = tileSmelter.getCookProgressScaled(24);
|
||||
drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
|
||||
|
||||
if (tileSmelter.getStackInSlot(TileEntityEnderSmelter.GRAVEL) == null)
|
||||
{
|
||||
drawItemStack(new ItemStack(Blocks.gravel), k + 66, l + 17, "");
|
||||
}
|
||||
}
|
||||
|
||||
private void drawItemStack(ItemStack stack, int xPos, int yPos, String note)
|
||||
{
|
||||
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
|
||||
zLevel = 200.0F;
|
||||
//partialTransItemRenderer.zLevel = 200.0F;
|
||||
FontRenderer font = null;
|
||||
if (stack != null)
|
||||
{
|
||||
font = stack.getItem().getFontRenderer(stack);
|
||||
}
|
||||
if (font == null)
|
||||
{
|
||||
font = fontRendererObj;
|
||||
}
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
//partialTransItemRenderer.renderItemAndEffectIntoGUI(font, mc.getTextureManager(), stack, xPos, yPos);
|
||||
//partialTransItemRenderer.renderItemOverlayIntoGUI(font, mc.getTextureManager(), stack, xPos, yPos, note);
|
||||
zLevel = 0.0F;
|
||||
//partialTransItemRenderer.zLevel = 0.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.inventory.ContainerInfusionRepair;
|
||||
import net.einsteinsci.betterbeginnings.register.InfusionRepairUtil;
|
||||
import net.einsteinsci.betterbeginnings.util.ChatUtil;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiInfusionRepair extends GuiContainer
|
||||
{
|
||||
|
||||
private static final ResourceLocation craftingTableGuiTextures = new ResourceLocation(ModMain.MODID
|
||||
+ ":textures/gui/container/infusionRepairStation.png");
|
||||
//private RenderItemPartialTransparency partialTransItemRenderer = new RenderItemPartialTransparency();
|
||||
private ContainerInfusionRepair container;
|
||||
private EntityPlayer player;
|
||||
|
||||
public GuiInfusionRepair(InventoryPlayer invPlayer, World world, BlockPos pos)
|
||||
{
|
||||
super(new ContainerInfusionRepair(invPlayer, world, pos));
|
||||
|
||||
container = (ContainerInfusionRepair)inventorySlots;
|
||||
player = invPlayer.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
int takenLevels = InfusionRepairUtil.getTakenLevels(container.inputs);
|
||||
String takenLevelsStr = "";
|
||||
|
||||
int neededLevels = InfusionRepairUtil.getNeededLevels(container.inputs);
|
||||
String neededLevelsStr = "";
|
||||
|
||||
ItemStack repaired = container.inputs.getStackInSlot(0);
|
||||
if (repaired != null)
|
||||
{
|
||||
if (repaired.isItemStackDamageable() &&
|
||||
(player.experienceLevel >= InfusionRepairUtil.getNeededLevels(container.inputs)
|
||||
|| player.capabilities.isCreativeMode))
|
||||
{
|
||||
takenLevelsStr = "Taken: " + takenLevels + " L";
|
||||
neededLevelsStr = "Needed: " + neededLevels + " L";
|
||||
}
|
||||
else if (repaired.isItemStackDamageable())
|
||||
{
|
||||
takenLevelsStr = ChatUtil.RED + "Taken: " + takenLevels + " L";
|
||||
neededLevelsStr = ChatUtil.RED + "Needed: " + neededLevels + " L";
|
||||
}
|
||||
else
|
||||
{
|
||||
takenLevelsStr = "Taken: ";
|
||||
neededLevelsStr = "Needed: ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
takenLevelsStr = "Taken: ";
|
||||
neededLevelsStr = "Needed: ";
|
||||
}
|
||||
|
||||
fontRendererObj.drawString(neededLevelsStr, 90, 5, 4210752);
|
||||
fontRendererObj.drawString(takenLevelsStr, 90, 67, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
ArrayList<ItemStack> requiredItems = InfusionRepairUtil.getRequiredStacks(container.inputs);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(craftingTableGuiTextures);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
|
||||
for (int i = 0; i < requiredItems.size(); ++i)
|
||||
{
|
||||
if (requiredItems.get(i) == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Slot slot = container.circleSlots[i + 1];
|
||||
ItemStack needed = requiredItems.get(i);
|
||||
|
||||
if (needed != null && !slot.getHasStack())
|
||||
{
|
||||
drawItemStack(needed, (width - xSize) / 2 + slot.xDisplayPosition, (height - ySize) / 2 +
|
||||
slot.yDisplayPosition, "" + needed.stackSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawItemStack(ItemStack stack, int xPos, int yPos, String note)
|
||||
{
|
||||
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
|
||||
zLevel = 200.0F;
|
||||
//partialTransItemRenderer.zLevel = 200.0F;
|
||||
FontRenderer font = null;
|
||||
if (stack != null)
|
||||
{
|
||||
font = stack.getItem().getFontRenderer(stack);
|
||||
}
|
||||
if (font == null)
|
||||
{
|
||||
font = fontRendererObj;
|
||||
}
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
//partialTransItemRenderer.renderItemAndEffectIntoGUI(font, mc.getTextureManager(), stack, xPos, yPos);
|
||||
//partialTransItemRenderer.renderItemOverlayIntoGUI(font, mc.getTextureManager(), stack, xPos, yPos, note);
|
||||
zLevel = 0.0F;
|
||||
//partialTransItemRenderer.zLevel = 0.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.inventory.ContainerKiln;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityKiln;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiKiln extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation kilnGuiTextures = new ResourceLocation(
|
||||
"minecraft:textures/gui/container/furnace.png");
|
||||
private TileEntityKiln tileKiln;
|
||||
|
||||
public GuiKiln(InventoryPlayer invPlayer, TileEntityKiln tile)
|
||||
{
|
||||
super(new ContainerKiln(invPlayer, tile));
|
||||
tileKiln = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
String string = tileKiln.hasCustomName() ? tileKiln.getName() : I18n.format(tileKiln.getName());
|
||||
fontRendererObj.drawString(string, xSize / 2 - fontRendererObj.getStringWidth(string), 6, 4210752);
|
||||
fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 94, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
mc.getTextureManager().bindTexture(kilnGuiTextures);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
int i1;
|
||||
|
||||
if (tileKiln.isBurning())
|
||||
{
|
||||
i1 = tileKiln.getBurnTimeRemainingScaled(12);
|
||||
drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
|
||||
}
|
||||
|
||||
i1 = tileKiln.getCookProgressScaled(24);
|
||||
drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.inventory.ContainerNetherBrickOven;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/22/2014.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiNetherBrickOven extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation ovenGuiTextures =
|
||||
new ResourceLocation(ModMain.MODID + ":textures/gui/container/netherBrickOven.png");
|
||||
|
||||
private TileEntityNetherBrickOven tileBrickOven;
|
||||
|
||||
public GuiNetherBrickOven(InventoryPlayer inventory, TileEntityNetherBrickOven tile)
|
||||
{
|
||||
super(new ContainerNetherBrickOven(inventory, tile));
|
||||
tileBrickOven = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{
|
||||
String string =
|
||||
tileBrickOven.hasCustomName() ? tileBrickOven.getName() :
|
||||
I18n.format(tileBrickOven.getName());
|
||||
fontRendererObj.drawString(string, 40, 6, 4210752);
|
||||
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
|
||||
// In fuel zone
|
||||
if (mouseX >= k + 16 && mouseX <= k + 33 && mouseY >= l + 9 && mouseY <= l + 58)
|
||||
{
|
||||
drawFluidTooltip(mouseX - k, mouseY - l);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawFluidTooltip(int x, int y)
|
||||
{
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
lines.add("" + tileBrickOven.getFuelLevel() + " mB");
|
||||
drawHoveringText(lines, x, y); //Draw tooltip
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
mc.getTextureManager().bindTexture(ovenGuiTextures);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
int i1;
|
||||
|
||||
i1 = tileBrickOven.getCookProgressScaled(24);
|
||||
drawTexturedModalRect(k + 103, l + 34, 176, 14, i1 + 1, 16);
|
||||
|
||||
int tankFillPx = tileBrickOven.getFuelLevelScaled(48);
|
||||
//drawTexturedModalRect(k + 17, l + 58 - tankFillPx, 176, 31, 16, tankFillPx);
|
||||
//drawFluid(tileBrickOven.getFuelStack(), k + 17, l + 10, 16, 48, tileBrickOven.fuelTank.getCapacity());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void drawFluid(FluidStack fluid, int x, int y, int width, int height, int maxCapacity)
|
||||
{
|
||||
if (fluid == null || fluid.getFluid() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//IIcon icon = fluid.getFluid().getIcon(fluid);
|
||||
mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
setGLColorFromInt(fluid.getFluid().getColor(fluid));
|
||||
int fullX = width / 16;
|
||||
int fullY = height / 16;
|
||||
int lastX = width - fullX * 16;
|
||||
int lastY = height - fullY * 16;
|
||||
int level = fluid.amount * height / maxCapacity;
|
||||
int fullLvl = (height - level) / 16;
|
||||
int lastLvl = height - level - fullLvl * 16;
|
||||
for (int i = 0; i < fullX; i++)
|
||||
{
|
||||
for (int j = 0; j < fullY; j++)
|
||||
{
|
||||
if (j >= fullLvl)
|
||||
{
|
||||
//drawCutIcon(icon, x + i * 16, y + j * 16, 16, 16, j == fullLvl ? lastLvl : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < fullX; i++)
|
||||
{
|
||||
//drawCutIcon(icon, x + i * 16, y + fullY * 16, 16, lastY, fullLvl == fullY ? lastLvl : 0);
|
||||
}
|
||||
for (int i = 0; i < fullY; i++)
|
||||
{
|
||||
if (i >= fullLvl)
|
||||
{
|
||||
//drawCutIcon(icon, x + fullX * 16, y + i * 16, lastX, 16, i == fullLvl ? lastLvl : 0);
|
||||
}
|
||||
}
|
||||
//drawCutIcon(icon, x + fullX * 16, y + fullY * 16, lastX, lastY, fullLvl == fullY ? lastLvl : 0);
|
||||
}
|
||||
|
||||
public static void setGLColorFromInt(int color)
|
||||
{
|
||||
float red = (color >> 16 & 255) / 255.0F;
|
||||
float green = (color >> 8 & 255) / 255.0F;
|
||||
float blue = (color & 255) / 255.0F;
|
||||
GL11.glColor4f(red, green, blue, 1.0F);
|
||||
}
|
||||
|
||||
/*
|
||||
//The magic is here
|
||||
private void drawCutIcon(IIcon icon, int x, int y, int width, int height, int cut)
|
||||
{
|
||||
Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawingQuads();
|
||||
tess.addVertexWithUV(x, y + height, zLevel, icon.getMinU(), icon.getInterpolatedV(height));
|
||||
tess.addVertexWithUV(x + width, y + height, zLevel, icon.getInterpolatedU(width),
|
||||
icon.getInterpolatedV(height));
|
||||
tess.addVertexWithUV(x + width, y + cut, zLevel, icon.getInterpolatedU(width), icon.getInterpolatedV(cut));
|
||||
tess.addVertexWithUV(x, y + cut, zLevel, icon.getMinU(), icon.getInterpolatedV(cut));
|
||||
tess.draw();
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.inventory.ContainerObsidianKiln;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityObsidianKiln;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/17/2014.
|
||||
*/
|
||||
public class GuiObsidianKiln extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation kilnGuiTextures = new ResourceLocation(
|
||||
"minecraft:textures/gui/container/furnace.png");
|
||||
private TileEntityObsidianKiln tileKiln;
|
||||
|
||||
public GuiObsidianKiln(InventoryPlayer invPlayer, TileEntityObsidianKiln tile)
|
||||
{
|
||||
super(new ContainerObsidianKiln(invPlayer, tile));
|
||||
tileKiln = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
String string = tileKiln.hasCustomName() ? tileKiln.getName() :
|
||||
I18n.format(tileKiln.getName());
|
||||
fontRendererObj.drawString(string, xSize / 2 - fontRendererObj.getStringWidth(string), 6, 4210752);
|
||||
fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 94, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
mc.getTextureManager().bindTexture(kilnGuiTextures);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
int i1;
|
||||
|
||||
if (tileKiln.isBurning())
|
||||
{
|
||||
i1 = tileKiln.getBurnTimeRemainingScaled(12);
|
||||
drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
|
||||
}
|
||||
|
||||
i1 = tileKiln.getCookProgressScaled(24);
|
||||
drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.inventory.ContainerSimpleWorkbench;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiSimpleWorkbench extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation craftingTableGuiTextures =
|
||||
new ResourceLocation(ModMain.MODID + ":textures/gui/container/simpleWorkbench.png");
|
||||
private ContainerSimpleWorkbench container;
|
||||
|
||||
public GuiSimpleWorkbench(InventoryPlayer invPlayer, World world, BlockPos pos)
|
||||
{
|
||||
super(new ContainerSimpleWorkbench(invPlayer, world, pos));
|
||||
|
||||
container = (ContainerSimpleWorkbench)inventorySlots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the foreground layer for the GuiContainer (everything in front of
|
||||
* the items)
|
||||
*/
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
// I'm guessing the really big number at the end is the z layer.
|
||||
fontRendererObj.drawString(I18n.format("container.crafting"), 28, 6, 4210752);
|
||||
fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(craftingTableGuiTextures);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
|
||||
if (container.needsBigBoyBench())
|
||||
{
|
||||
drawTexturedModalRect(k + 87, l + 32, xSize, 0, 28, 21);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
package net.einsteinsci.betterbeginnings.gui;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.inventory.ContainerSmelter;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntitySmelter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiSmelter extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation smelterGuiTextures = new ResourceLocation(ModMain.MODID +
|
||||
":textures/gui/container/smelter.png");
|
||||
//RenderItemPartialTransparency partialTransItemRenderer = new RenderItemPartialTransparency();
|
||||
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
|
||||
private TileEntitySmelter tileSmelter;
|
||||
|
||||
public GuiSmelter(InventoryPlayer invPlayer, TileEntitySmelter tile)
|
||||
{
|
||||
super(new ContainerSmelter(invPlayer, tile));
|
||||
tileSmelter = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
String string =
|
||||
tileSmelter.hasCustomName() ? tileSmelter.getName() : I18n.format(tileSmelter.getName());
|
||||
fontRendererObj.drawString(string, xSize / 2 - fontRendererObj.getStringWidth(string), 6, 4210752);
|
||||
fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 94, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
|
||||
{
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
mc.getTextureManager().bindTexture(smelterGuiTextures);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
int i1;
|
||||
|
||||
if (tileSmelter.isBurning())
|
||||
{
|
||||
i1 = tileSmelter.getBurnTimeRemainingScaled(12);
|
||||
drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
|
||||
}
|
||||
|
||||
i1 = tileSmelter.getCookProgressScaled(24);
|
||||
drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
|
||||
|
||||
if (tileSmelter.getStackInSlot(TileEntitySmelter.GRAVEL) == null)
|
||||
{
|
||||
drawItemStack(new ItemStack(Blocks.gravel), k + 66, l + 17, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void drawItemStack(ItemStack stack, int xPos, int yPos, String note)
|
||||
{
|
||||
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
|
||||
zLevel = 200.0F;
|
||||
FontRenderer font = null;
|
||||
if (stack != null)
|
||||
{
|
||||
font = stack.getItem().getFontRenderer(stack);
|
||||
}
|
||||
if (font == null)
|
||||
{
|
||||
font = fontRendererObj;
|
||||
}
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
//partialTransItemRenderer.renderItemAndEffectIntoGUI(font, mc.getTextureManager(), stack, xPos, yPos);
|
||||
itemRenderer.renderItemIntoGUI(stack, xPos, yPos);
|
||||
itemRenderer.renderItemOverlayIntoGUI(font, stack, xPos, yPos, note);
|
||||
//partialTransItemRenderer.renderItemOverlayIntoGUI(font, mc.getTextureManager(), stack, xPos, yPos, note);
|
||||
zLevel = 0.0F;
|
||||
//partialTransItemRenderer.zLevel = 0.0F;
|
||||
itemRenderer.zLevel = 0.0f;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.BrickOvenRecipeHandler;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerBrickOven extends Container
|
||||
{
|
||||
private TileEntityBrickOven tileBrickOven;
|
||||
private int lastCookTime;
|
||||
private int lastBurnTime;
|
||||
private int lastItemBurnTime;
|
||||
|
||||
public ContainerBrickOven(InventoryPlayer playerInv, TileEntityBrickOven tileEntityBrickOven)
|
||||
{
|
||||
tileBrickOven = tileEntityBrickOven;
|
||||
addSlotToContainer(new SlotFurnaceFuel(tileEntityBrickOven, TileEntityBrickOven.FUEL, 92, 58));
|
||||
addSlotToContainer(
|
||||
new SlotFurnaceOutput(playerInv.player, tileEntityBrickOven, TileEntityBrickOven.OUTPUT, 124, 21));
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
addSlotToContainer(new Slot(tileEntityBrickOven, j + i * 3 + TileEntityBrickOven.INPUTSTART,
|
||||
30 + j * 18, 17 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting craft)
|
||||
{
|
||||
super.addCraftingToCrafters(craft);
|
||||
|
||||
craft.sendProgressBarUpdate(this, 0, tileBrickOven.ovenCookTime);
|
||||
craft.sendProgressBarUpdate(this, 1, tileBrickOven.ovenBurnTime);
|
||||
craft.sendProgressBarUpdate(this, 2, tileBrickOven.currentItemBurnLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (Object listItem : crafters)
|
||||
{
|
||||
ICrafting crafter = (ICrafting)listItem;
|
||||
|
||||
if (lastCookTime != tileBrickOven.ovenCookTime)
|
||||
{
|
||||
crafter.sendProgressBarUpdate(this, 0, tileBrickOven.ovenCookTime);
|
||||
}
|
||||
if (lastBurnTime != tileBrickOven.ovenBurnTime)
|
||||
{
|
||||
crafter.sendProgressBarUpdate(this, 1, tileBrickOven.ovenBurnTime);
|
||||
}
|
||||
if (lastItemBurnTime != tileBrickOven.currentItemBurnLength)
|
||||
{
|
||||
crafter.sendProgressBarUpdate(this, 2, tileBrickOven.currentItemBurnLength);
|
||||
}
|
||||
}
|
||||
|
||||
lastBurnTime = tileBrickOven.ovenBurnTime;
|
||||
lastCookTime = tileBrickOven.ovenCookTime;
|
||||
lastItemBurnTime = tileBrickOven.currentItemBurnLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(slotId);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (slotId == TileEntityBrickOven.OUTPUT)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 11, 47, true)) // move to inventory (all, avoid hotbar)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (slotId >= 11 && slotId < 38) // non-hotbar inventory
|
||||
{
|
||||
if (TileEntityBrickOven.isItemFuel(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, TileEntityBrickOven.FUEL, TileEntityBrickOven.FUEL + 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (BrickOvenRecipeHandler.instance().isInRecipe(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, TileEntityBrickOven.INPUTSTART, TileEntityBrickOven.INPUTSTART + 9,
|
||||
false)) // move to craft matrix
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 38, 47, false)) // move to hotbar
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (slotId >= 37 && slotId < 46) // hotbar
|
||||
{
|
||||
if (TileEntityBrickOven.isItemFuel(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, TileEntityBrickOven.FUEL, TileEntityBrickOven.FUEL + 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (BrickOvenRecipeHandler.instance().isInRecipe(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, TileEntityBrickOven.INPUTSTART, TileEntityBrickOven.INPUTSTART + 9,
|
||||
false)) // move to craft matrix
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 11, 38, false)) // move to inventory (non-hotbar)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 11, 47, false)) // move to inventory (all)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack)null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(player, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int par1, int par2)
|
||||
{
|
||||
if (par1 == 0)
|
||||
{
|
||||
tileBrickOven.ovenCookTime = par2;
|
||||
}
|
||||
if (par1 == 1)
|
||||
{
|
||||
tileBrickOven.ovenBurnTime = par2;
|
||||
}
|
||||
if (par1 == 2)
|
||||
{
|
||||
tileBrickOven.currentItemBurnLength = par2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return tileBrickOven.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.CampfireRecipes;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityCampfire;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerCampfire extends Container
|
||||
{
|
||||
private static final int SLOT_INPUT = TileEntityCampfire.SLOT_INPUT;
|
||||
private static final int SLOT_OUTPUT = TileEntityCampfire.SLOT_OUTPUT;
|
||||
private static final int SLOT_PAN = TileEntityCampfire.SLOT_PAN;
|
||||
private static final int SLOT_FUEL = TileEntityCampfire.SLOT_FUEL;
|
||||
public int lastItemBurnTime;
|
||||
public int lastCookTime;
|
||||
private TileEntityCampfire tileCampfire;
|
||||
private int lastBurnTime;
|
||||
private int lastDecayTime;
|
||||
|
||||
public ContainerCampfire(InventoryPlayer inventory, TileEntityCampfire campfire)
|
||||
{
|
||||
|
||||
tileCampfire = campfire;
|
||||
addSlotToContainer(new Slot(tileCampfire, SLOT_INPUT, 58, 12));
|
||||
addSlotToContainer(new Slot(tileCampfire, SLOT_PAN, 32, 35));
|
||||
addSlotToContainer(new SlotFurnaceFuel(tileCampfire, SLOT_FUEL, 58, 57));
|
||||
addSlotToContainer(new SlotFurnaceOutput(inventory.player, campfire, SLOT_OUTPUT, 118, 34));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
public void addCraftingToCrafters(ICrafting craft)
|
||||
{
|
||||
super.addCraftingToCrafters(craft);
|
||||
|
||||
craft.sendProgressBarUpdate(this, 0, tileCampfire.cookTime);
|
||||
craft.sendProgressBarUpdate(this, 1, tileCampfire.burnTime);
|
||||
craft.sendProgressBarUpdate(this, 2, tileCampfire.currentItemBurnTime);
|
||||
craft.sendProgressBarUpdate(this, 3, tileCampfire.decayTime);
|
||||
}
|
||||
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (Object crafter : crafters)
|
||||
{
|
||||
ICrafting craft = (ICrafting)crafter;
|
||||
|
||||
if (lastCookTime != tileCampfire.cookTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 0, tileCampfire.cookTime);
|
||||
}
|
||||
if (lastBurnTime != tileCampfire.burnTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 1, tileCampfire.burnTime);
|
||||
}
|
||||
if (lastItemBurnTime != tileCampfire.currentItemBurnTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 2, tileCampfire.currentItemBurnTime);
|
||||
}
|
||||
if (lastDecayTime != tileCampfire.decayTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 3, tileCampfire.decayTime);
|
||||
}
|
||||
}
|
||||
|
||||
lastBurnTime = tileCampfire.burnTime;
|
||||
lastCookTime = tileCampfire.cookTime;
|
||||
lastItemBurnTime = tileCampfire.currentItemBurnTime;
|
||||
lastDecayTime = tileCampfire.decayTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int par2)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(par2);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (par2 == 2)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 3, 39, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (par2 != 1 && par2 != 0)
|
||||
{
|
||||
if (CampfireRecipes.smelting().getSmeltingResult(itemstack1) != null)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (TileEntityCampfire.isItemFuel(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par2 >= 3 && par2 < 30)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 30, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par2 >= 30 && par2 < 39 && !mergeItemStack(itemstack1, 3, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 3, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
slot.onPickupFromSlot(player, itemstack1);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int barId, int newValue)
|
||||
{
|
||||
if (barId == 0)
|
||||
{
|
||||
tileCampfire.cookTime = newValue;
|
||||
}
|
||||
if (barId == 1)
|
||||
{
|
||||
tileCampfire.burnTime = newValue;
|
||||
}
|
||||
if (barId == 2)
|
||||
{
|
||||
tileCampfire.currentItemBurnTime = newValue;
|
||||
}
|
||||
if (barId == 3)
|
||||
{
|
||||
tileCampfire.decayTime = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return tileCampfire.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,255 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.blocks.BlockDoubleWorkbench;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.AdvancedCraftingHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ContainerDoubleWorkbench extends Container
|
||||
{
|
||||
/**
|
||||
* The crafting matrix inventory (3x3).
|
||||
*/
|
||||
public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3);
|
||||
public InventoryWorkbenchAdditionalMaterials addedMats = new InventoryWorkbenchAdditionalMaterials(this, 4);
|
||||
public IInventory craftResult = new InventoryCraftResult();
|
||||
public World worldObj;
|
||||
public Slot[] matSlots = new Slot[4];
|
||||
public Slot resultSlot;
|
||||
|
||||
private BlockPos pos;
|
||||
|
||||
public ContainerDoubleWorkbench(InventoryPlayer invPlayer, World world, BlockPos loc)
|
||||
{
|
||||
worldObj = world;
|
||||
pos = loc;
|
||||
|
||||
resultSlot = new SlotAdvancedCrafting(invPlayer.player, craftMatrix, craftResult, addedMats, 0, 129, 35);
|
||||
addSlotToContainer(resultSlot);
|
||||
int i;
|
||||
int j;
|
||||
|
||||
// Matrix
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (j = 0; j < 3; ++j)
|
||||
{
|
||||
addSlotToContainer(new Slot(craftMatrix, j + i * 3, 35 + j * 18, 17 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Inventory
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (j = 0; j < 9; ++j)
|
||||
{
|
||||
addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Hotbar
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142));
|
||||
}
|
||||
|
||||
// Additional materials
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
matSlots[i] = new Slot(addedMats, i, 8, 7 + i * 18);
|
||||
// matSlots[i].setBackgroundIcon(Items.apple.getIconFromDamage(0));
|
||||
addSlotToContainer(matSlots[i]);
|
||||
|
||||
onCraftMatrixChanged(craftMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
for (int i = 0; i < inventorySlots.size(); ++i)
|
||||
{
|
||||
ItemStack itemstack = ((Slot)inventorySlots.get(i)).getStack();
|
||||
ItemStack itemstack1 = (ItemStack)inventoryItemStacks.get(i);
|
||||
|
||||
if (!ItemStack.areItemStacksEqual(itemstack1, itemstack))
|
||||
{
|
||||
itemstack1 = itemstack == null ? null : itemstack.copy();
|
||||
inventoryItemStacks.set(i, itemstack1);
|
||||
|
||||
for (Object listItem : crafters)
|
||||
{
|
||||
ICrafting crafter = (ICrafting)listItem;
|
||||
crafter.sendSlotContents(this, i, itemstack1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onCraftMatrixChanged(craftMatrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. I
|
||||
* am not touching this code.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(slotId);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (slotId == 0)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 10, 46, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (slotId >= 10 && slotId < 37)
|
||||
{
|
||||
if (AdvancedCraftingHandler.crafting().isAddedMaterial(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 46, 50, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 37, 46, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (slotId >= 37 && slotId < 46)
|
||||
{
|
||||
if (AdvancedCraftingHandler.crafting().isAddedMaterial(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 46, 50, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 10, 37, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 10, 46, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(player, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
// Can Stack Enter? (I think)
|
||||
@Override
|
||||
public boolean canMergeSlot(ItemStack stack, Slot slot)
|
||||
{
|
||||
return slot.inventory != craftResult && super.canMergeSlot(stack, slot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the container is closed.
|
||||
*/
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
super.onContainerClosed(player);
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
player.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < addedMats.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack = addedMats.getStackInSlotOnClosing(i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
player.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for when the crafting matrix is changed. Detects if recipe is valid.
|
||||
*/
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventory)
|
||||
{
|
||||
boolean hasAddedMats = false;
|
||||
ItemStack result = AdvancedCraftingHandler.crafting().findMatchingRecipe(craftMatrix, addedMats, worldObj);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
result = CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj);
|
||||
}
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
hasAddedMats = true;
|
||||
}
|
||||
|
||||
if (hasAddedMats)
|
||||
{
|
||||
craftResult.setInventorySlotContents(0, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
craftResult.setInventorySlotContents(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
// return worldObj.getBlock(posX, posY, posZ) !=
|
||||
// RegisterBlocks.blockDoubleWorkbench ? false : player.getDistanceSq(
|
||||
// posX + 0.5D, posY + 0.5D, posZ + 0.5D) <= 64.0D;
|
||||
|
||||
return worldObj.getBlockState(pos).getBlock() == RegisterBlocks.doubleWorkbench &&
|
||||
worldObj.getBlockState(pos).getValue(BlockDoubleWorkbench.CONNECTION) != EnumFacing.UP &&
|
||||
player.getDistanceSq((double)pos.getX() + 0.5d, (double)pos.getY() + 0.5d,
|
||||
(double)pos.getZ() + 0.5d) <= 64.0D;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.SmelterRecipeHandler;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityEnderSmelter;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/21/2014.
|
||||
*/
|
||||
public class ContainerEnderSmelter extends Container
|
||||
{
|
||||
private TileEntityEnderSmelter smelter;
|
||||
private int lastCookTime;
|
||||
private int lastBurnTime;
|
||||
private int lastItemBurnTime;
|
||||
|
||||
public ContainerEnderSmelter(InventoryPlayer playerInv, TileEntityEnderSmelter tileSmelter)
|
||||
{
|
||||
smelter = tileSmelter;
|
||||
addSlotToContainer(new Slot(tileSmelter, TileEntityEnderSmelter.INPUT, 46, 17));
|
||||
addSlotToContainer(new Slot(tileSmelter, TileEntityEnderSmelter.FUEL, 56, 53));
|
||||
addSlotToContainer(new SlotFurnaceOutput(playerInv.player, tileSmelter,
|
||||
TileEntityEnderSmelter.OUTPUT, 116, 35));
|
||||
addSlotToContainer(new Slot(tileSmelter, TileEntityEnderSmelter.GRAVEL, 66, 17));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting craft)
|
||||
{
|
||||
super.addCraftingToCrafters(craft);
|
||||
|
||||
craft.sendProgressBarUpdate(this, 0, smelter.smelterCookTime);
|
||||
craft.sendProgressBarUpdate(this, 1, smelter.smelterBurnTime);
|
||||
craft.sendProgressBarUpdate(this, 2, smelter.currentItemBurnLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (Object listItem : crafters)
|
||||
{
|
||||
ICrafting crafter = (ICrafting)listItem;
|
||||
|
||||
if (lastCookTime != smelter.smelterCookTime)
|
||||
{
|
||||
crafter.sendProgressBarUpdate(this, 0, smelter.smelterCookTime);
|
||||
}
|
||||
if (lastBurnTime != smelter.smelterBurnTime)
|
||||
{
|
||||
crafter.sendProgressBarUpdate(this, 1, smelter.smelterBurnTime);
|
||||
}
|
||||
if (lastItemBurnTime != smelter.currentItemBurnLength)
|
||||
{
|
||||
crafter.sendProgressBarUpdate(this, 2, smelter.currentItemBurnLength);
|
||||
}
|
||||
}
|
||||
|
||||
lastBurnTime = smelter.smelterBurnTime;
|
||||
lastCookTime = smelter.smelterCookTime;
|
||||
lastItemBurnTime = smelter.currentItemBurnLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int fromId)
|
||||
{
|
||||
ItemStack movedStackDupe = null;
|
||||
Slot slot = (Slot)inventorySlots.get(fromId);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack movedStack = slot.getStack();
|
||||
movedStackDupe = movedStack.copy();
|
||||
|
||||
if (fromId == TileEntityEnderSmelter.OUTPUT)
|
||||
{
|
||||
if (!mergeItemStack(movedStack, 4, 40, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
slot.onSlotChange(movedStack, movedStackDupe);
|
||||
}
|
||||
else if (fromId != TileEntityEnderSmelter.FUEL && fromId != TileEntityEnderSmelter.INPUT &&
|
||||
fromId != TileEntityEnderSmelter.GRAVEL)
|
||||
{
|
||||
if (SmelterRecipeHandler.smelting().getSmeltingResult(movedStack) != null)
|
||||
{
|
||||
if (!mergeItemStack(movedStack,
|
||||
TileEntityEnderSmelter.INPUT,
|
||||
TileEntityEnderSmelter.INPUT + 1,
|
||||
false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (movedStack.getItem() == Item.getItemFromBlock(Blocks.gravel))
|
||||
{
|
||||
if (!mergeItemStack(movedStack,
|
||||
TileEntityEnderSmelter.GRAVEL,
|
||||
TileEntityEnderSmelter.GRAVEL + 1,
|
||||
false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (TileEntityEnderSmelter.isItemFuel(movedStack))
|
||||
{
|
||||
if (!mergeItemStack(movedStack,
|
||||
TileEntityEnderSmelter.FUEL,
|
||||
TileEntityEnderSmelter.FUEL + 1,
|
||||
false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (fromId >= 4 && fromId < 31)
|
||||
{
|
||||
if (!mergeItemStack(movedStack, 31, 40, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (fromId >= 31 && fromId < 40 && !mergeItemStack(movedStack, 4, 31, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(movedStack, 4, 40, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (movedStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
if (movedStack.stackSize == movedStackDupe.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
slot.onPickupFromSlot(player, movedStack);
|
||||
}
|
||||
return movedStackDupe;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int par1, int par2)
|
||||
{
|
||||
if (par1 == 0)
|
||||
{
|
||||
smelter.smelterCookTime = par2;
|
||||
}
|
||||
if (par1 == 1)
|
||||
{
|
||||
smelter.smelterBurnTime = par2;
|
||||
}
|
||||
if (par1 == 2)
|
||||
{
|
||||
smelter.currentItemBurnLength = par2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return smelter.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
public boolean merge(ItemStack stack, int startSlot, int endSlot, boolean searchFromBottom)
|
||||
{
|
||||
return mergeItemStack(stack, startSlot, endSlot, searchFromBottom);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.InfusionRepairUtil;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/20/2014.
|
||||
*/
|
||||
public class ContainerInfusionRepair extends Container
|
||||
{
|
||||
public Slot[] circleSlots = new Slot[9];
|
||||
public Slot resultSlot;
|
||||
public InventoryInfusionRepair inputs = new InventoryInfusionRepair(this, 9);
|
||||
public IInventory output = new InventoryCraftResult();
|
||||
public World worldObj;
|
||||
EntityPlayer player;
|
||||
|
||||
private BlockPos pos;
|
||||
|
||||
public ContainerInfusionRepair(InventoryPlayer invPlayer, World world, BlockPos loc)
|
||||
{
|
||||
worldObj = world;
|
||||
pos = loc;
|
||||
|
||||
player = invPlayer.player;
|
||||
|
||||
circleSlots[0] = new Slot(inputs, 0, 44, 35);
|
||||
|
||||
circleSlots[1] = new Slot(inputs, 1, 44, 6);
|
||||
circleSlots[2] = new Slot(inputs, 2, 67, 12);
|
||||
circleSlots[3] = new Slot(inputs, 3, 73, 35);
|
||||
circleSlots[4] = new Slot(inputs, 4, 67, 58);
|
||||
circleSlots[5] = new Slot(inputs, 5, 44, 63);
|
||||
circleSlots[6] = new Slot(inputs, 6, 21, 58);
|
||||
circleSlots[7] = new Slot(inputs, 7, 15, 35);
|
||||
circleSlots[8] = new Slot(inputs, 8, 21, 12);
|
||||
|
||||
for (Slot slot : circleSlots)
|
||||
{
|
||||
addSlotToContainer(slot);
|
||||
}
|
||||
|
||||
resultSlot = new SlotInfusionRepairResult(invPlayer.player, inputs, output, 9, 136, 35);
|
||||
addSlotToContainer(resultSlot);
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142));
|
||||
}
|
||||
|
||||
onCraftMatrixChanged(inputs);
|
||||
}
|
||||
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if (InfusionRepairUtil.canRepair(inputs, player))
|
||||
{
|
||||
ItemStack result = inputs.getStackInSlot(0).copy();
|
||||
result.setItemDamage(0);
|
||||
output.setInventorySlotContents(0, result);
|
||||
//resultSlot.setBackgroundIcon(result.getItem().getIconFromDamage(0)); // TODO: Fix bg icons
|
||||
}
|
||||
else
|
||||
{
|
||||
output.setInventorySlotContents(0, null);
|
||||
//resultSlot.setBackgroundIcon(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(slotId);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (slotId < 10)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 10, 46, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (slotId >= 10 && slotId <= 45)
|
||||
{
|
||||
if (itemstack != null)
|
||||
{
|
||||
if (itemstack.getItem().isDamageable())
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 1, 9, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 10, 46, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(player, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
// Can Stack Enter? (I think)
|
||||
@Override
|
||||
public boolean canMergeSlot(ItemStack stack, Slot slot)
|
||||
{
|
||||
return slot.inventory != output && super.canMergeSlot(stack, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
//super.onContainerClosed(player);
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
ItemStack itemstack = inputs.getStackInSlotOnClosing(i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
player.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory craftInv)
|
||||
{
|
||||
detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return worldObj.getBlockState(pos).getBlock() == RegisterBlocks.infusionRepairStation
|
||||
&& player.getDistanceSq((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D,
|
||||
(double)pos.getZ() + 0.5D) <= 64.0D;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.KilnRecipes;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityKiln;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerKiln extends Container
|
||||
{
|
||||
private TileEntityKiln tileKiln;
|
||||
private int lastCookTime;
|
||||
private int lastBurnTime;
|
||||
private int lastItemBurnTime;
|
||||
|
||||
public ContainerKiln(InventoryPlayer playerInv, TileEntityKiln tileEntityKiln)
|
||||
{
|
||||
tileKiln = tileEntityKiln;
|
||||
addSlotToContainer(new Slot(tileEntityKiln, 0, 56, 17));
|
||||
addSlotToContainer(new Slot(tileEntityKiln, 1, 56, 53));
|
||||
addSlotToContainer(new SlotFurnaceOutput(playerInv.player, tileEntityKiln, 2, 116, 35));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting craft)
|
||||
{
|
||||
super.addCraftingToCrafters(craft);
|
||||
|
||||
craft.sendProgressBarUpdate(this, 0, tileKiln.kilnCookTime);
|
||||
craft.sendProgressBarUpdate(this, 1, tileKiln.kilnBurnTime);
|
||||
craft.sendProgressBarUpdate(this, 2, tileKiln.currentBurnTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); ++i)
|
||||
{
|
||||
ICrafting craft = (ICrafting)crafters.get(i);
|
||||
|
||||
if (lastCookTime != tileKiln.kilnCookTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 0, tileKiln.kilnCookTime);
|
||||
}
|
||||
if (lastBurnTime != tileKiln.kilnBurnTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 1, tileKiln.kilnBurnTime);
|
||||
}
|
||||
if (lastItemBurnTime != tileKiln.currentBurnTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 2, tileKiln.currentBurnTime);
|
||||
}
|
||||
}
|
||||
|
||||
lastBurnTime = tileKiln.kilnBurnTime;
|
||||
lastCookTime = tileKiln.kilnCookTime;
|
||||
lastItemBurnTime = tileKiln.currentBurnTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int par2)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(par2);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (par2 == 2)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 3, 39, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (par2 != 1 && par2 != 0)
|
||||
{
|
||||
if (KilnRecipes.smelting().getSmeltingResult(itemstack1) != null)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (TileEntityKiln.isItemFuel(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par2 >= 3 && par2 < 30)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 30, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par2 >= 30 && par2 < 39 && !mergeItemStack(itemstack1, 3, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 3, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
slot.onPickupFromSlot(player, itemstack1);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int par1, int par2)
|
||||
{
|
||||
if (par1 == 0)
|
||||
{
|
||||
tileKiln.kilnCookTime = par2;
|
||||
}
|
||||
if (par1 == 1)
|
||||
{
|
||||
tileKiln.kilnBurnTime = par2;
|
||||
}
|
||||
if (par1 == 2)
|
||||
{
|
||||
tileKiln.currentBurnTime = par2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return tileKiln.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.NetherBrickOvenRecipeHandler;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/21/2014.
|
||||
*/
|
||||
public class ContainerNetherBrickOven extends Container
|
||||
{
|
||||
private TileEntityNetherBrickOven tileBrickOven;
|
||||
private int lastCookTime;
|
||||
|
||||
public ContainerNetherBrickOven(InventoryPlayer playerInv, TileEntityNetherBrickOven tileEntityBrickOven)
|
||||
{
|
||||
tileBrickOven = tileEntityBrickOven;
|
||||
addSlotToContainer(new Slot(tileEntityBrickOven, TileEntityNetherBrickOven.FUELINPUT, 17, 63));
|
||||
addSlotToContainer(new SlotFurnaceOutput(playerInv.player, tileEntityBrickOven,
|
||||
TileEntityNetherBrickOven.OUTPUT, 138, 35));
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
addSlotToContainer(new Slot(tileEntityBrickOven, j + i * 3 + TileEntityNetherBrickOven.INPUTSTART,
|
||||
44 + j * 18, 17 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting craft)
|
||||
{
|
||||
super.addCraftingToCrafters(craft);
|
||||
|
||||
craft.sendProgressBarUpdate(this, 0, tileBrickOven.ovenCookTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); ++i)
|
||||
{
|
||||
ICrafting craft = (ICrafting)crafters.get(i);
|
||||
|
||||
if (lastCookTime != tileBrickOven.ovenCookTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 0, tileBrickOven.ovenCookTime);
|
||||
}
|
||||
}
|
||||
|
||||
lastCookTime = tileBrickOven.ovenCookTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(slotId);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (slotId == TileEntityNetherBrickOven.OUTPUT)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 11, 47, true)) // move to inventory (all, avoid hotbar)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (slotId >= 11 && slotId < 38) // non-hotbar inventory
|
||||
{
|
||||
if (FluidContainerRegistry.isBucket(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, TileEntityNetherBrickOven.FUELINPUT,
|
||||
TileEntityNetherBrickOven.FUELINPUT + 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (NetherBrickOvenRecipeHandler.instance().isInRecipe(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, TileEntityNetherBrickOven.INPUTSTART,
|
||||
TileEntityNetherBrickOven.INPUTSTART + 9,
|
||||
false)) // move to craft matrix
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 38, 47, false)) // move to hotbar
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (slotId >= 37 && slotId < 46) // hotbar
|
||||
{
|
||||
if (FluidContainerRegistry.isBucket(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, TileEntityNetherBrickOven.FUELINPUT,
|
||||
TileEntityNetherBrickOven.FUELINPUT + 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (NetherBrickOvenRecipeHandler.instance().isInRecipe(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, TileEntityNetherBrickOven.INPUTSTART,
|
||||
TileEntityNetherBrickOven.INPUTSTART + 9,
|
||||
false)) // move to craft matrix
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 11, 38, false)) // move to inventory (non-hotbar)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 11, 47, false)) // move to inventory (all)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(player, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int par1, int par2)
|
||||
{
|
||||
if (par1 == 0)
|
||||
{
|
||||
tileBrickOven.ovenCookTime = par2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return tileBrickOven.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.KilnRecipes;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityObsidianKiln;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/17/2014.
|
||||
*/
|
||||
public class ContainerObsidianKiln extends Container
|
||||
{
|
||||
private TileEntityObsidianKiln tileKiln;
|
||||
private int lastCookTime;
|
||||
private int lastBurnTime;
|
||||
private int lastItemBurnTime;
|
||||
|
||||
public ContainerObsidianKiln(InventoryPlayer playerInv, TileEntityObsidianKiln obsKiln)
|
||||
{
|
||||
tileKiln = obsKiln;
|
||||
addSlotToContainer(new Slot(obsKiln, 0, 56, 17));
|
||||
addSlotToContainer(new Slot(obsKiln, 1, 56, 53));
|
||||
addSlotToContainer(new SlotFurnaceOutput(playerInv.player, obsKiln, 2, 116, 35));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting craft)
|
||||
{
|
||||
super.addCraftingToCrafters(craft);
|
||||
|
||||
craft.sendProgressBarUpdate(this, 0, tileKiln.kilnCookTime);
|
||||
craft.sendProgressBarUpdate(this, 1, tileKiln.kilnBurnTime);
|
||||
craft.sendProgressBarUpdate(this, 2, tileKiln.currentBurnTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); ++i)
|
||||
{
|
||||
ICrafting craft = (ICrafting)crafters.get(i);
|
||||
|
||||
if (lastCookTime != tileKiln.kilnCookTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 0, tileKiln.kilnCookTime);
|
||||
}
|
||||
if (lastBurnTime != tileKiln.kilnBurnTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 1, tileKiln.kilnBurnTime);
|
||||
}
|
||||
if (lastItemBurnTime != tileKiln.currentBurnTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 2, tileKiln.currentBurnTime);
|
||||
}
|
||||
}
|
||||
|
||||
lastBurnTime = tileKiln.kilnBurnTime;
|
||||
lastCookTime = tileKiln.kilnCookTime;
|
||||
lastItemBurnTime = tileKiln.currentBurnTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int par2)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(par2);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (par2 == 2)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 3, 39, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (par2 != 1 && par2 != 0)
|
||||
{
|
||||
if (KilnRecipes.smelting().getSmeltingResult(itemstack1) != null)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (TileEntityObsidianKiln.isItemFuel(itemstack1))
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par2 >= 3 && par2 < 30)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 30, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par2 >= 30 && par2 < 39 && !mergeItemStack(itemstack1, 3, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 3, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
slot.onPickupFromSlot(player, itemstack1);
|
||||
}
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int par1, int par2)
|
||||
{
|
||||
if (par1 == 0)
|
||||
{
|
||||
tileKiln.kilnCookTime = par2;
|
||||
}
|
||||
if (par1 == 1)
|
||||
{
|
||||
tileKiln.kilnBurnTime = par2;
|
||||
}
|
||||
if (par1 == 2)
|
||||
{
|
||||
tileKiln.currentBurnTime = par2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return tileKiln.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.blocks.BlockDoubleWorkbench;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.AdvancedCraftingHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ContainerSimpleWorkbench extends Container
|
||||
{
|
||||
/**
|
||||
* The crafting matrix inventory (3x3).
|
||||
*/
|
||||
public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3);
|
||||
public IInventory craftResult = new InventoryCraftResult();
|
||||
BlockPos pos;
|
||||
private World worldObj;
|
||||
|
||||
public ContainerSimpleWorkbench(InventoryPlayer invPlayer, World world, BlockPos loc)
|
||||
{
|
||||
worldObj = world;
|
||||
pos = loc;
|
||||
|
||||
addSlotToContainer(new SlotCrafting(invPlayer.player, craftMatrix, craftResult, 0, 124, 35));
|
||||
int l;
|
||||
int i1;
|
||||
|
||||
for (l = 0; l < 3; ++l)
|
||||
{
|
||||
for (i1 = 0; i1 < 3; ++i1)
|
||||
{
|
||||
addSlotToContainer(new Slot(craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (l = 0; l < 3; ++l)
|
||||
{
|
||||
for (i1 = 0; i1 < 9; ++i1)
|
||||
{
|
||||
addSlotToContainer(new Slot(invPlayer, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (l = 0; l < 9; ++l)
|
||||
{
|
||||
addSlotToContainer(new Slot(invPlayer, l, 8 + l * 18, 142));
|
||||
}
|
||||
|
||||
onCraftMatrixChanged(craftMatrix);
|
||||
}
|
||||
|
||||
public boolean needsBigBoyBench()
|
||||
{
|
||||
return AdvancedCraftingHandler.crafting().hasRecipe(craftMatrix, worldObj);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player shift-clicks on a slot. You must override this or
|
||||
* you will crash when someone does that. I am not touching this code.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
|
||||
{
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(slotId);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (slotId == 0)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 10, 46, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
}
|
||||
else if (slotId >= 10 && slotId < 37)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 37, 46, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (slotId >= 37 && slotId < 46)
|
||||
{
|
||||
if (!mergeItemStack(itemstack1, 10, 37, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(itemstack1, 10, 46, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack)null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.stackSize == itemstack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(player, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
// Can Stack Enter? (I think)
|
||||
@Override
|
||||
public boolean canMergeSlot(ItemStack stack, Slot slot)
|
||||
{
|
||||
return slot.inventory != craftResult && super.canMergeSlot(stack, slot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the container is closed.
|
||||
*/
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player)
|
||||
{
|
||||
super.onContainerClosed(player);
|
||||
|
||||
if (!worldObj.isRemote)
|
||||
{
|
||||
for (int i = 0; i < 9; ++i)
|
||||
{
|
||||
ItemStack itemstack = craftMatrix.getStackInSlotOnClosing(i);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
player.dropPlayerItemWithRandomChoice(itemstack, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for when the crafting matrix is changed.
|
||||
*/
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventory)
|
||||
{
|
||||
craftResult.setInventorySlotContents(0,
|
||||
CraftingManager.getInstance().findMatchingRecipe(craftMatrix, worldObj));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
// return worldObj.getBlock(posX, posY, posZ) !=
|
||||
// RegisterBlocks.blockDoubleWorkbench ? false : player.getDistanceSq(
|
||||
// posX + 0.5D, posY + 0.5D, posZ + 0.5D) <= 64.0D;
|
||||
|
||||
return worldObj.getBlockState(pos) == RegisterBlocks.doubleWorkbench
|
||||
&& worldObj.getBlockState(pos).getValue(BlockDoubleWorkbench.CONNECTION) == EnumFacing.UP
|
||||
&& player.getDistanceSq((double)pos.getX() + 0.5d, (double)pos.getY() + 0.5d,
|
||||
(double)pos.getZ() + 0.5d) <= 64.0D;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,187 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.SmelterRecipeHandler;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntitySmelter;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerSmelter extends Container
|
||||
{
|
||||
private TileEntitySmelter smelter;
|
||||
private int lastCookTime;
|
||||
private int lastBurnTime;
|
||||
private int lastItemBurnTime;
|
||||
|
||||
public ContainerSmelter(InventoryPlayer playerInv, TileEntitySmelter tileEntitySmelter)
|
||||
{
|
||||
smelter = tileEntitySmelter;
|
||||
addSlotToContainer(new Slot(tileEntitySmelter, TileEntitySmelter.INPUT, 46, 17));
|
||||
addSlotToContainer(new Slot(tileEntitySmelter, TileEntitySmelter.FUEL, 56, 53));
|
||||
addSlotToContainer(new SlotFurnaceOutput(playerInv.player, tileEntitySmelter,
|
||||
TileEntitySmelter.OUTPUT, 116, 35));
|
||||
addSlotToContainer(new Slot(tileEntitySmelter, TileEntitySmelter.GRAVEL, 66, 17));
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting craft)
|
||||
{
|
||||
super.addCraftingToCrafters(craft);
|
||||
|
||||
craft.sendProgressBarUpdate(this, 0, smelter.smelterCookTime);
|
||||
craft.sendProgressBarUpdate(this, 1, smelter.smelterBurnTime);
|
||||
craft.sendProgressBarUpdate(this, 2, smelter.currentItemBurnLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (int i = 0; i < crafters.size(); ++i)
|
||||
{
|
||||
ICrafting craft = (ICrafting)crafters.get(i);
|
||||
|
||||
if (lastCookTime != smelter.smelterCookTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 0, smelter.smelterCookTime);
|
||||
}
|
||||
if (lastBurnTime != smelter.smelterBurnTime)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 1, smelter.smelterBurnTime);
|
||||
}
|
||||
if (lastItemBurnTime != smelter.currentItemBurnLength)
|
||||
{
|
||||
craft.sendProgressBarUpdate(this, 2, smelter.currentItemBurnLength);
|
||||
}
|
||||
}
|
||||
|
||||
lastBurnTime = smelter.smelterBurnTime;
|
||||
lastCookTime = smelter.smelterCookTime;
|
||||
lastItemBurnTime = smelter.currentItemBurnLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int fromId)
|
||||
{
|
||||
ItemStack movedStackDupe = null;
|
||||
Slot slot = (Slot)inventorySlots.get(fromId);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack movedStack = slot.getStack();
|
||||
movedStackDupe = movedStack.copy();
|
||||
|
||||
if (fromId == TileEntitySmelter.OUTPUT)
|
||||
{
|
||||
if (!mergeItemStack(movedStack, 4, 40, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
slot.onSlotChange(movedStack, movedStackDupe);
|
||||
}
|
||||
else if (fromId != TileEntitySmelter.FUEL && fromId != TileEntitySmelter.INPUT &&
|
||||
fromId != TileEntitySmelter.GRAVEL)
|
||||
{
|
||||
if (SmelterRecipeHandler.smelting().getSmeltingResult(movedStack) != null)
|
||||
{
|
||||
if (!mergeItemStack(movedStack, TileEntitySmelter.INPUT, TileEntitySmelter.INPUT + 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (movedStack.getItem() == Item.getItemFromBlock(Blocks.gravel))
|
||||
{
|
||||
if (!mergeItemStack(movedStack, TileEntitySmelter.GRAVEL, TileEntitySmelter.GRAVEL + 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (TileEntitySmelter.isItemFuel(movedStack))
|
||||
{
|
||||
if (!mergeItemStack(movedStack, TileEntitySmelter.FUEL, TileEntitySmelter.FUEL + 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (fromId >= 4 && fromId < 31)
|
||||
{
|
||||
if (!mergeItemStack(movedStack, 31, 40, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (fromId >= 31 && fromId < 40 && !mergeItemStack(movedStack, 4, 31, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!mergeItemStack(movedStack, 4, 40, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (movedStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
if (movedStack.stackSize == movedStackDupe.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
slot.onPickupFromSlot(player, movedStack);
|
||||
}
|
||||
return movedStackDupe;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int par1, int par2)
|
||||
{
|
||||
if (par1 == 0)
|
||||
{
|
||||
smelter.smelterCookTime = par2;
|
||||
}
|
||||
if (par1 == 1)
|
||||
{
|
||||
smelter.smelterBurnTime = par2;
|
||||
}
|
||||
if (par1 == 2)
|
||||
{
|
||||
smelter.currentItemBurnLength = par2;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return smelter.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
public boolean merge(ItemStack stack, int startSlot, int endSlot, boolean searchFromBottom)
|
||||
{
|
||||
return mergeItemStack(stack, startSlot, endSlot, searchFromBottom);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,202 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InventoryBrickOvenMatrix extends InventoryCrafting implements IInventory
|
||||
{
|
||||
/**
|
||||
* List of the stacks in the crafting matrix.
|
||||
*/
|
||||
private ItemStack[] stackList;
|
||||
/**
|
||||
* the width of the crafting inventory
|
||||
*/
|
||||
private int inventoryWidth;
|
||||
/**
|
||||
* Class containing the callbacks for the events on_GUIClosed and
|
||||
* on_CraftMaxtrixChanged.
|
||||
*/
|
||||
private Container eventHandler;
|
||||
|
||||
public InventoryBrickOvenMatrix(Container container, int width, int height)
|
||||
{
|
||||
super(container, width, height);
|
||||
int k = width * height;
|
||||
stackList = new ItemStack[k];
|
||||
eventHandler = container;
|
||||
inventoryWidth = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of slots in the inventory.
|
||||
*/
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return stackList.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stack in slot i
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
return slot >= getSizeInventory() ? null : stackList[slot];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the itemstack in the slot specified (Top left is 0, 0). Args:
|
||||
* row, column
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInRowAndColumn(int row, int column)
|
||||
{
|
||||
if (row >= 0 && row < inventoryWidth)
|
||||
{
|
||||
int k = row + column * inventoryWidth;
|
||||
return getStackInSlot(k);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the customName of the inventory
|
||||
*/
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "container.brickovenmatrix";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the inventory is named
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* When some containers are closed they call this on each slot, then drop
|
||||
* whatever it returns as an EntityItem - like when you close a workbench
|
||||
* GUI.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
{
|
||||
if (stackList[slot] != null)
|
||||
{
|
||||
ItemStack itemstack = stackList[slot];
|
||||
stackList[slot] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes from an inventory slot (first arg) up to a specified number
|
||||
* (second arg) of items and returns them in a new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount)
|
||||
{
|
||||
if (stackList[slot] != null)
|
||||
{
|
||||
ItemStack itemstack;
|
||||
|
||||
if (stackList[slot].stackSize <= amount)
|
||||
{
|
||||
itemstack = stackList[slot];
|
||||
stackList[slot] = null;
|
||||
eventHandler.onCraftMatrixChanged(this);
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = stackList[slot].splitStack(amount);
|
||||
|
||||
if (stackList[slot].stackSize == 0)
|
||||
{
|
||||
stackList[slot] = null;
|
||||
}
|
||||
|
||||
eventHandler.onCraftMatrixChanged(this);
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given item stack to the specified slot in the inventory (can be
|
||||
* crafting or armor sections).
|
||||
*/
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
stackList[slot] = stack;
|
||||
eventHandler.onCraftMatrixChanged(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum stack size for a inventory slot.
|
||||
*/
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
/**
|
||||
* For tile entities, ensures the chunk containing the tile entity is saved
|
||||
* to disk later - the game won't think it hasn't changed and skip it.
|
||||
*/
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
super.markDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not make give this method the customName canInteractWith because it clashes
|
||||
* with Container
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation is allowed to insert the given stack (ignoring
|
||||
* stack size) into the given slot.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack item)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public class InventoryInfusionRepair implements IInventory
|
||||
{
|
||||
public ItemStack[] stackList;
|
||||
public Container eventHandler;
|
||||
|
||||
public InventoryInfusionRepair(Container container, int size)
|
||||
{
|
||||
stackList = new ItemStack[size];
|
||||
eventHandler = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return stackList.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
if (getSizeInventory() <= slot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return stackList[slot];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount)
|
||||
{
|
||||
if (stackList[slot] != null)
|
||||
{
|
||||
ItemStack itemstack;
|
||||
|
||||
if (stackList[slot].stackSize <= amount)
|
||||
{
|
||||
itemstack = stackList[slot];
|
||||
stackList[slot] = null;
|
||||
eventHandler.onCraftMatrixChanged(this);
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = stackList[slot].splitStack(amount);
|
||||
|
||||
if (stackList[slot].stackSize == 0)
|
||||
{
|
||||
stackList[slot] = null;
|
||||
}
|
||||
|
||||
eventHandler.onCraftMatrixChanged(this);
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
{
|
||||
if (stackList[slot] != null)
|
||||
{
|
||||
ItemStack itemstack = stackList[slot];
|
||||
stackList[slot] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
stackList[slot] = stack;
|
||||
eventHandler.onCraftMatrixChanged(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "container.inputs";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName()
|
||||
{
|
||||
return new ChatComponentText(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack)
|
||||
{
|
||||
if (stack != null && slot == 0) // center slot
|
||||
{
|
||||
return stack.getItem().isDamageable();
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
for (int i = 0; i < stackList.length; i++)
|
||||
{
|
||||
stackList[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
public class InventoryWorkbenchAdditionalMaterials implements IInventory
|
||||
{
|
||||
private ItemStack[] stackList;
|
||||
|
||||
private Container eventHandler;
|
||||
|
||||
public InventoryWorkbenchAdditionalMaterials(Container container, int size)
|
||||
{
|
||||
stackList = new ItemStack[size];
|
||||
eventHandler = container;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return stackList.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
if (getSizeInventory() <= slot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return stackList[slot];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount)
|
||||
{
|
||||
if (stackList[slot] != null)
|
||||
{
|
||||
ItemStack itemstack;
|
||||
|
||||
if (stackList[slot].stackSize <= amount)
|
||||
{
|
||||
itemstack = stackList[slot];
|
||||
stackList[slot] = null;
|
||||
eventHandler.onCraftMatrixChanged(this);
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = stackList[slot].splitStack(amount);
|
||||
|
||||
if (stackList[slot].stackSize == 0)
|
||||
{
|
||||
stackList[slot] = null;
|
||||
}
|
||||
|
||||
eventHandler.onCraftMatrixChanged(this);
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot)
|
||||
{
|
||||
if (stackList[slot] != null)
|
||||
{
|
||||
ItemStack itemstack = stackList[slot];
|
||||
stackList[slot] = null;
|
||||
return itemstack;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
stackList[slot] = stack;
|
||||
eventHandler.onCraftMatrixChanged(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "container.workbenchmaterials";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName()
|
||||
{
|
||||
return new ChatComponentText(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
for (int i = 0; i < stackList.length; i++)
|
||||
{
|
||||
stackList[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.AdvancedCraftingHandler;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.AdvancedRecipe;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.stats.AchievementList;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class SlotAdvancedCrafting extends Slot
|
||||
{
|
||||
/**
|
||||
* The craft matrix inventory linked to this result slot.
|
||||
*/
|
||||
private final IInventory craftMatrix;
|
||||
/**
|
||||
* The added materials necessary for advanced crafting.
|
||||
*/
|
||||
private final IInventory additionalMaterials;
|
||||
/**
|
||||
* The player that is using the GUI where this slot resides.
|
||||
*/
|
||||
private EntityPlayer thePlayer;
|
||||
/**
|
||||
* The number of items that have been crafted so far. Gets passed to
|
||||
* ItemStack.onCrafting before being reset.
|
||||
*/
|
||||
private int amountCrafted;
|
||||
|
||||
public SlotAdvancedCrafting(EntityPlayer player, IInventory matrix, IInventory resultInv,
|
||||
IInventory addedMats, int id, int x, int y)
|
||||
{
|
||||
super(resultInv, id, x, y);
|
||||
thePlayer = player;
|
||||
craftMatrix = matrix;
|
||||
additionalMaterials = addedMats;
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes,
|
||||
* not ore and wood. Typically increases an internal count then calls
|
||||
* onCrafting(item).
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting(ItemStack stack, int resultCount)
|
||||
{
|
||||
amountCrafted += resultCount;
|
||||
onCrafting(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* the itemStack passed in is the output - ie, iron ingots, and pickaxes,
|
||||
* not ore and wood.
|
||||
*/
|
||||
@Override
|
||||
protected void onCrafting(ItemStack stack)
|
||||
{
|
||||
stack.onCrafting(thePlayer.worldObj, thePlayer, amountCrafted);
|
||||
amountCrafted = 0;
|
||||
|
||||
if (stack.getItem() == Item.getItemFromBlock(Blocks.crafting_table))
|
||||
{
|
||||
thePlayer.addStat(AchievementList.buildWorkBench, 1);
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof ItemPickaxe)
|
||||
{
|
||||
thePlayer.addStat(AchievementList.buildPickaxe, 1);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Item.getItemFromBlock(Blocks.furnace))
|
||||
{
|
||||
thePlayer.addStat(AchievementList.buildFurnace, 1);
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof ItemHoe)
|
||||
{
|
||||
thePlayer.addStat(AchievementList.buildHoe, 1);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Items.bread)
|
||||
{
|
||||
thePlayer.addStat(AchievementList.makeBread, 1);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Items.cake)
|
||||
{
|
||||
thePlayer.addStat(AchievementList.bakeCake, 1);
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof ItemPickaxe
|
||||
&& ((ItemPickaxe)stack.getItem()).getToolMaterial() != Item.ToolMaterial.WOOD)
|
||||
{
|
||||
thePlayer.addStat(AchievementList.buildBetterPickaxe, 1);
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof ItemSword
|
||||
&& ((ItemSword)stack.getItem()).getToolMaterialName() != "noobwood")
|
||||
{
|
||||
thePlayer.addStat(AchievementList.buildSword, 1);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Item.getItemFromBlock(Blocks.enchanting_table))
|
||||
{
|
||||
thePlayer.addStat(AchievementList.enchantments, 1);
|
||||
}
|
||||
|
||||
if (stack.getItem() == Item.getItemFromBlock(Blocks.bookshelf))
|
||||
{
|
||||
thePlayer.addStat(AchievementList.bookcase, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// onCraftingEvent?
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer player, ItemStack resultStack)
|
||||
{
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent(player, resultStack, craftMatrix);
|
||||
onCrafting(resultStack);
|
||||
|
||||
// Decrease crafted materials
|
||||
for (int i = 0; i < craftMatrix.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack ingredientStack = craftMatrix.getStackInSlot(i);
|
||||
|
||||
if (ingredientStack != null)
|
||||
{
|
||||
craftMatrix.decrStackSize(i, 1);
|
||||
|
||||
if (ingredientStack.getItem().hasContainerItem(ingredientStack))
|
||||
{
|
||||
ItemStack containerStack = ingredientStack.getItem().getContainerItem(ingredientStack);
|
||||
|
||||
if (containerStack != null && containerStack.isItemStackDamageable()
|
||||
&& containerStack.getItemDamage() > containerStack.getMaxDamage())
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, containerStack));
|
||||
continue;
|
||||
}
|
||||
|
||||
//if (!ingredientStack.getItem().doesContainerItemLeaveCraftingGrid(ingredientStack)
|
||||
// || !thePlayer.inventory.addItemStackToInventory(containerStack))
|
||||
//{
|
||||
// if (craftMatrix.getStackInSlot(i) == null)
|
||||
// {
|
||||
// craftMatrix.setInventorySlotContents(i, containerStack);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// thePlayer.dropPlayerItemWithRandomChoice(containerStack, false);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Decrease added materials
|
||||
for (int i = 0; i < additionalMaterials.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack matStack = additionalMaterials.getStackInSlot(i);
|
||||
|
||||
if (matStack != null)
|
||||
{
|
||||
int amount = 0;
|
||||
AdvancedRecipe advRecipe = AdvancedCraftingHandler.AdvancedRecipeByResult(resultStack);
|
||||
|
||||
if (advRecipe != null)
|
||||
{
|
||||
amount = advRecipe.getNeededMaterialCount(matStack.getItem());
|
||||
}
|
||||
|
||||
additionalMaterials.decrStackSize(i, amount);
|
||||
|
||||
// Containers
|
||||
if (matStack.getItem().hasContainerItem(matStack))
|
||||
{
|
||||
ItemStack containerStack = matStack.getItem().getContainerItem(matStack);
|
||||
|
||||
if (containerStack != null && containerStack.isItemStackDamageable()
|
||||
&& containerStack.getItemDamage() > containerStack.getMaxDamage())
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, containerStack));
|
||||
continue;
|
||||
}
|
||||
|
||||
//if (!matStack.getItem().doesContainerItemLeaveCraftingGrid(matStack)
|
||||
// || !thePlayer.inventory.addItemStackToInventory(containerStack))
|
||||
//{
|
||||
// if (additionalMaterials.getStackInSlot(i) == null)
|
||||
// {
|
||||
// additionalMaterials.setInventorySlotContents(i, containerStack);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// thePlayer.dropPlayerItemWithRandomChoice(containerStack, false);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the stack is a valid item for this slot. Always true beside for
|
||||
* the armor slots.
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
// One way only.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrease the size of the stack in slot (first int arg) by the amount of
|
||||
* the second int arg. Returns the new stack.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack decrStackSize(int amount)
|
||||
{
|
||||
if (getHasStack())
|
||||
{
|
||||
amountCrafted += Math.min(amount, getStack().stackSize);
|
||||
}
|
||||
|
||||
return super.decrStackSize(amount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// BUFFER
|
|
@ -0,0 +1,12 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class SlotBrickOvenOutput extends Slot
|
||||
{
|
||||
public SlotBrickOvenOutput(IInventory container, int slotId, int x, int y)
|
||||
{
|
||||
super(container, slotId, x, y);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.InfusionRepairUtil;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterItems;
|
||||
import net.einsteinsci.betterbeginnings.register.achievement.RegisterAchievements;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/20/2014.
|
||||
*/
|
||||
public class SlotInfusionRepairResult extends Slot
|
||||
{
|
||||
IInventory inputSlots;
|
||||
EntityPlayer player;
|
||||
IInventory outputSlot;
|
||||
|
||||
public SlotInfusionRepairResult(EntityPlayer entityPlayer, InventoryInfusionRepair inputs, IInventory output,
|
||||
int slotId, int xPos, int yPos)
|
||||
{
|
||||
super(inputs, slotId, xPos, yPos);
|
||||
player = entityPlayer;
|
||||
outputSlot = output;
|
||||
|
||||
inputSlots = inputs;
|
||||
}
|
||||
|
||||
public void onPickupFromSlot(EntityPlayer entityPlayer, ItemStack stack)
|
||||
{
|
||||
onCrafting(stack);
|
||||
|
||||
InventoryInfusionRepair inputs = (InventoryInfusionRepair)inputSlots;
|
||||
|
||||
ArrayList<ItemStack> required = InfusionRepairUtil.getRequiredStacks(inputs);
|
||||
|
||||
for (ItemStack requiredStack : required)
|
||||
{
|
||||
for (int i = 0; i < inputSlots.getSizeInventory(); ++i)
|
||||
{
|
||||
if (requiredStack != null && inputSlots.getStackInSlot(i) != null)
|
||||
{
|
||||
if (requiredStack.getItem() == inputSlots.getStackInSlot(i).getItem() &&
|
||||
(requiredStack.getItemDamage() == OreDictionary.WILDCARD_VALUE ||
|
||||
requiredStack.getItemDamage() == inputSlots.getStackInSlot(i).getItemDamage()))
|
||||
{
|
||||
inputSlots.decrStackSize(i, requiredStack.stackSize);
|
||||
|
||||
ItemStack itemstack1 = inputSlots.getStackInSlot(i);
|
||||
|
||||
if (itemstack1 != null)
|
||||
{
|
||||
if (itemstack1.getItem().hasContainerItem(itemstack1))
|
||||
{
|
||||
ItemStack containerStack = itemstack1.getItem().getContainerItem(itemstack1);
|
||||
|
||||
if (containerStack != null && containerStack.isItemStackDamageable() && containerStack
|
||||
.getItemDamage() > containerStack.getMaxDamage())
|
||||
{
|
||||
MinecraftForge.EVENT_BUS
|
||||
.post(new PlayerDestroyItemEvent(entityPlayer, containerStack));
|
||||
continue;
|
||||
}
|
||||
|
||||
//if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) ||
|
||||
// !entityPlayer.inventory.addItemStackToInventory(containerStack))
|
||||
//{
|
||||
// if (inputSlots.getStackInSlot(i) == null)
|
||||
// {
|
||||
// inputSlots.setInventorySlotContents(i, containerStack);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// entityPlayer.dropPlayerItemWithRandomChoice(containerStack, false);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!entityPlayer.capabilities.isCreativeMode)
|
||||
{
|
||||
entityPlayer.addExperienceLevel(-InfusionRepairUtil.getTakenLevels(inputs));
|
||||
}
|
||||
|
||||
inputSlots.setInventorySlotContents(0, null);
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack.getItem() == RegisterItems.noobWoodSword)
|
||||
{
|
||||
RegisterAchievements.achievementGet(entityPlayer, "repairNoobSword");
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().firePlayerCraftingEvent(entityPlayer, stack, inputSlots);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package net.einsteinsci.betterbeginnings.inventory;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/21/2014.
|
||||
*/
|
||||
public class TankNetherBrickOvenFuel extends FluidTank implements IFluidTank
|
||||
{
|
||||
public TankNetherBrickOvenFuel(TileEntityNetherBrickOven oven, int capacity)
|
||||
{
|
||||
super(capacity);
|
||||
|
||||
tile = oven;
|
||||
}
|
||||
|
||||
public boolean fillFromContainer(ItemStack container)
|
||||
{
|
||||
FluidStack stack = FluidContainerRegistry.getFluidForFilledItem(container);
|
||||
if (stack != null)
|
||||
{
|
||||
if (getCapacity() - getFluidAmount() > stack.amount)
|
||||
{
|
||||
if (getFluid() != null)
|
||||
{
|
||||
if (getFluid().isFluidEqual(stack))
|
||||
{
|
||||
fluid.amount += stack.amount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fluid = stack.copy();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFluidAmount()
|
||||
{
|
||||
if (fluid == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return fluid.amount;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.ItemPickaxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemBonePickaxe extends ItemPickaxe implements IBBName
|
||||
{
|
||||
public ItemBonePickaxe()
|
||||
{
|
||||
super(ToolMaterial.WOOD);
|
||||
|
||||
setUnlocalizedName("bonePickaxe");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "bonePickaxe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass)
|
||||
{
|
||||
return toolMaterial.getHarvestLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getToolClasses(ItemStack stack)
|
||||
{
|
||||
Set<String> res = new HashSet<>();
|
||||
|
||||
res.add("pickaxe");
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemBoneShard extends Item implements IBBName
|
||||
{
|
||||
public ItemBoneShard()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("boneShard");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "boneShard";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.einsteinsci.betterbeginnings.register.achievement.RegisterAchievements;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
// "That's disgusting!"
|
||||
public class ItemCharredMeat extends ItemFood implements IBBName
|
||||
{
|
||||
public ItemCharredMeat()
|
||||
{
|
||||
super(4, 8.0f, true);
|
||||
setUnlocalizedName("charredMeat");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFoodEaten(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
super.onFoodEaten(stack, world, player);
|
||||
|
||||
RegisterAchievements.achievementGet(player, "charredMeat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "charredMeat";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemCloth extends Item implements IBBName
|
||||
{
|
||||
public ItemCloth()
|
||||
{
|
||||
super();
|
||||
|
||||
setUnlocalizedName("cloth");
|
||||
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "cloth";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
|
||||
public class ItemClothArmor extends ItemArmor implements IBBName
|
||||
{
|
||||
public ItemClothArmor(ArmorMaterial material, int armorIndex, String name)
|
||||
{
|
||||
super(material, 0, armorIndex);
|
||||
|
||||
setUnlocalizedName(name);
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "clothArmor_" + armorType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFireBow extends Item implements IBBName
|
||||
{
|
||||
public ItemFireBow()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("fireBow");
|
||||
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(8);
|
||||
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side,
|
||||
float hitX, float hitY, float hitZ)
|
||||
{
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
|
||||
if (side == EnumFacing.DOWN)
|
||||
{
|
||||
--y;
|
||||
}
|
||||
|
||||
if (side == EnumFacing.UP)
|
||||
{
|
||||
++y;
|
||||
}
|
||||
|
||||
if (side == EnumFacing.NORTH)
|
||||
{
|
||||
--z;
|
||||
}
|
||||
|
||||
if (side == EnumFacing.SOUTH)
|
||||
{
|
||||
++z;
|
||||
}
|
||||
|
||||
if (side == EnumFacing.WEST)
|
||||
{
|
||||
--x;
|
||||
}
|
||||
|
||||
if (side == EnumFacing.EAST)
|
||||
{
|
||||
++x;
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(pos, side, stack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (world.isAirBlock(pos))
|
||||
{
|
||||
world.playSoundEffect((double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, "fire.ignite", 1.0F,
|
||||
itemRand.nextFloat() * 0.4F + 0.8F);
|
||||
world.setBlockState(pos, Blocks.fire.getDefaultState());
|
||||
}
|
||||
|
||||
stack.damageItem(1, player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "fireBow";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.ItemAxe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemFlintHatchet extends ItemAxe implements IBBName
|
||||
{
|
||||
public ItemFlintHatchet()
|
||||
{
|
||||
super(ToolMaterial.WOOD);
|
||||
setUnlocalizedName(getName());
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "flintHatchet";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass)
|
||||
{
|
||||
return toolMaterial.getHarvestLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getToolClasses(ItemStack stack)
|
||||
{
|
||||
Set<String> res = new HashSet<>();
|
||||
|
||||
res.add("axe");
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.*;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemHammer extends ItemTool
|
||||
{
|
||||
private static final Set breakableBlocks = Sets
|
||||
.newHashSet(Blocks.stone, Blocks.cobblestone, Blocks.gravel, Blocks.sandstone);
|
||||
|
||||
protected ItemHammer(Item.ToolMaterial material)
|
||||
{
|
||||
super(2.0F, material, breakableBlocks);
|
||||
}
|
||||
|
||||
public static ItemStack getCrushResult(Block broken)
|
||||
{
|
||||
if (broken == Blocks.stone)
|
||||
{
|
||||
return new ItemStack(Blocks.cobblestone);
|
||||
}
|
||||
else if (broken == Blocks.cobblestone)
|
||||
{
|
||||
return new ItemStack(Blocks.gravel);
|
||||
}
|
||||
else if (broken == Blocks.gravel)
|
||||
{
|
||||
return new ItemStack(Items.flint, 2);
|
||||
}
|
||||
else if (broken == Blocks.sandstone)
|
||||
{
|
||||
return new ItemStack(Blocks.sand);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemIronNugget extends Item implements IBBName
|
||||
{
|
||||
public ItemIronNugget()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("ironNugget");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "ironNugget";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.ItemFood;
|
||||
|
||||
public class ItemJerkyBeef extends ItemFood implements IBBName
|
||||
{
|
||||
public ItemJerkyBeef()
|
||||
{
|
||||
super(4, 8.0f, true);
|
||||
setUnlocalizedName("jerkyBeef");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "jerkyBeef";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.ItemFood;
|
||||
|
||||
public class ItemJerkyRaw extends ItemFood implements IBBName
|
||||
{
|
||||
public ItemJerkyRaw()
|
||||
{
|
||||
super(0, 8.0f, true);
|
||||
setUnlocalizedName("jerkyRaw");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
setPotionEffect(17, 30, 1, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "jerkyRaw";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTool;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class ItemKnife extends ItemTool implements IBBName
|
||||
{
|
||||
public static final float DAMAGE = 3.0f;
|
||||
|
||||
public ItemKnife(ToolMaterial material)
|
||||
{
|
||||
super(DAMAGE, material, getBreakable());
|
||||
}
|
||||
|
||||
public static Set getBreakable()
|
||||
{
|
||||
Set<Block> s = new HashSet<>();
|
||||
|
||||
// s.add(Blocks.log);
|
||||
// s.add(Blocks.log2);
|
||||
// s.add(Blocks.planks);
|
||||
s.add(Blocks.pumpkin);
|
||||
s.add(Blocks.lit_pumpkin);
|
||||
s.add(Blocks.melon_block);
|
||||
s.add(Blocks.clay);
|
||||
s.add(Blocks.grass);
|
||||
s.add(Blocks.mycelium);
|
||||
s.add(Blocks.leaves);
|
||||
s.add(Blocks.leaves2);
|
||||
s.add(Blocks.brown_mushroom_block);
|
||||
s.add(Blocks.red_mushroom_block);
|
||||
s.add(Blocks.glass);
|
||||
s.add(Blocks.glass_pane);
|
||||
s.add(Blocks.soul_sand);
|
||||
s.add(Blocks.stained_glass);
|
||||
s.add(Blocks.stained_glass_pane);
|
||||
s.add(Blocks.cactus);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// Determines if a block broken with the tool will drop its drops.
|
||||
//@Override
|
||||
//public boolean func_150897_b(Block block)
|
||||
//{
|
||||
// if (block.getMaterial() == Material.rock && toolMaterial.getHarvestLevel() >= 0)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// if (block.getMaterial() == Material.wood && toolMaterial.getHarvestLevel() >= 0)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// return false;
|
||||
//}
|
||||
|
||||
//@Override
|
||||
//public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass)
|
||||
{
|
||||
return toolMaterial.getHarvestLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getToolClasses(ItemStack stack)
|
||||
{
|
||||
Set<String> res = new HashSet<>();
|
||||
|
||||
res.add("knife");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// ...which also requires this...
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
itemStack.setItemDamage(itemStack.getItemDamage() + 1);
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
// Allows durability-based crafting.
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract String getName();
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
|
||||
public class ItemKnifeBone extends ItemKnife
|
||||
{
|
||||
public ItemKnifeBone()
|
||||
{
|
||||
super(ToolMaterial.STONE);
|
||||
setUnlocalizedName("boneKnife");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "boneKnife";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
|
||||
public class ItemKnifeDiamond extends ItemKnife
|
||||
{
|
||||
public ItemKnifeDiamond()
|
||||
{
|
||||
super(ToolMaterial.EMERALD);
|
||||
setUnlocalizedName("diamondKnife");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "diamondKnife";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
|
||||
public class ItemKnifeFlint extends ItemKnife
|
||||
{
|
||||
public ItemKnifeFlint()
|
||||
{
|
||||
super(ToolMaterial.WOOD);
|
||||
setUnlocalizedName("flintKnife");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "flintKnife";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
|
||||
public class ItemKnifeGold extends ItemKnife
|
||||
{
|
||||
public ItemKnifeGold()
|
||||
{
|
||||
super(ToolMaterial.GOLD);
|
||||
setUnlocalizedName("goldKnife");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "goldKnife";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
|
||||
public class ItemKnifeIron extends ItemKnife
|
||||
{
|
||||
public ItemKnifeIron()
|
||||
{
|
||||
super(ToolMaterial.IRON);
|
||||
setUnlocalizedName("ironKnife");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "ironKnife";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemLeatherStrip extends Item implements IBBName
|
||||
{
|
||||
public ItemLeatherStrip()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("leatherStrip");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "leatherStrip";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.ItemFood;
|
||||
|
||||
public class ItemMarshmallow extends ItemFood implements IBBName
|
||||
{
|
||||
public ItemMarshmallow()
|
||||
{
|
||||
super(1, 2.0f, false);
|
||||
setUnlocalizedName("marshmallow");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "marshmallow";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.ItemFood;
|
||||
|
||||
public class ItemMarshmallowCooked extends ItemFood implements IBBName
|
||||
{
|
||||
public ItemMarshmallowCooked()
|
||||
{
|
||||
super(5, 6.0f, false);
|
||||
setUnlocalizedName("marshmallowCooked");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
setPotionEffect(1, 15, 0, 0.8f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "marshmallowCooked";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.ItemSword;
|
||||
|
||||
//Replaces Vanilla Wood Sword
|
||||
public class ItemNoobWoodSword extends ItemSword implements IBBName
|
||||
{
|
||||
public ItemNoobWoodSword(ToolMaterial material)
|
||||
{
|
||||
super(material);
|
||||
setUnlocalizedName("noobWoodSword");
|
||||
//setTextureName(ModMain.MODID + ":" + getUnlocalizedName().substring(5));
|
||||
//setMaxDamage(60);
|
||||
//setCreativeTab(CreativeTabs.tabCombat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "noobWoodSword";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemPan extends Item implements IBBName
|
||||
{
|
||||
public ItemPan()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("pan");
|
||||
setMaxDamage(250);
|
||||
setMaxStackSize(1);
|
||||
//setTextureName(ModMain.MODID + ":" + getUnlocalizedName().substring(5));
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "pan";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemRoastingStick extends Item implements IBBName
|
||||
{
|
||||
|
||||
public ItemRoastingStick()
|
||||
{
|
||||
setUnlocalizedName("roastingStick");
|
||||
//shouldRotateAroundWhenRendering();
|
||||
//setTextureName(ModMain.MODID + ":" + getUnlocalizedName().substring(5));
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
setMaxStackSize(5);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (player.inventory.hasItemStack(new ItemStack(RegisterItems.marshmallow)))
|
||||
{
|
||||
player.inventory.consumeInventoryItem(RegisterItems.marshmallow);
|
||||
stack = new ItemStack(RegisterItems.roastingStickRawMallow);
|
||||
}
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "roastingStick";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemRoastingStickMallow extends Item implements IBBName
|
||||
{
|
||||
boolean isCooked;
|
||||
|
||||
public ItemRoastingStickMallow(boolean cooked)
|
||||
{
|
||||
if (cooked)
|
||||
{
|
||||
setUnlocalizedName("roastingStickCookedMallow");
|
||||
}
|
||||
else
|
||||
{
|
||||
setUnlocalizedName("roastingStickRawMallow");
|
||||
}
|
||||
isCooked = cooked;
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (isCooked)
|
||||
{
|
||||
player.inventory.addItemStackToInventory(new ItemStack(RegisterItems.marshmallowCooked));
|
||||
player.inventory.addItemStackToInventory(new ItemStack(RegisterItems.roastingStick));
|
||||
player.inventory.consumeInventoryItem(stack.getItem());
|
||||
}
|
||||
else
|
||||
{
|
||||
player.inventory.addItemStackToInventory(new ItemStack(RegisterItems.marshmallow));
|
||||
player.inventory.addItemStackToInventory(new ItemStack(RegisterItems.roastingStick));
|
||||
player.inventory.consumeInventoryItem(stack.getItem());
|
||||
}
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
if (isCooked)
|
||||
{
|
||||
return "roastingStickCookedMallow";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "roastingStickRawMallow";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
|
||||
|
||||
public class ItemRockHammer extends ItemHammer implements IBBName
|
||||
{
|
||||
public ItemRockHammer(ToolMaterial material)
|
||||
{
|
||||
super(material);
|
||||
setUnlocalizedName("rockHammer");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "rockHammer";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemSilk extends Item implements IBBName
|
||||
{
|
||||
public ItemSilk()
|
||||
{
|
||||
super();
|
||||
|
||||
setUnlocalizedName("silk");
|
||||
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "silk";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemTestItem extends Item implements IBBName
|
||||
{
|
||||
public ItemTestItem()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("testItem");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side,
|
||||
float hitX, float hitY, float hitZ)
|
||||
{
|
||||
Block tested = world.getBlockState(pos).getBlock();
|
||||
String blockName = tested.getUnlocalizedName().substring(5);
|
||||
ChatComponentTranslation trans = new ChatComponentTranslation(blockName);
|
||||
trans.appendText(" : " + world.getBlockState(pos).hashCode());
|
||||
player.addChatMessage(trans);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "testItem";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemThread extends Item implements IBBName
|
||||
{
|
||||
public ItemThread()
|
||||
{
|
||||
super();
|
||||
setUnlocalizedName("thread");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "thread";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package net.einsteinsci.betterbeginnings.items;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.register.IBBName;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class ItemTwine extends Item implements IBBName
|
||||
{
|
||||
public ItemTwine()
|
||||
{
|
||||
super();
|
||||
|
||||
setUnlocalizedName("twine");
|
||||
setCreativeTab(ModMain.tabBetterBeginnings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "twine";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package net.einsteinsci.betterbeginnings.network;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
public class ClientProxy extends ServerProxy
|
||||
{
|
||||
@Override
|
||||
public void registerRenderThings()
|
||||
{
|
||||
//Campfire
|
||||
//TileEntitySpecialRenderer render = new RenderCampfire();
|
||||
//ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCampfire.class, render);
|
||||
}
|
||||
|
||||
public void registerTileEntitySpecialRenderer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx)
|
||||
{
|
||||
switch (ctx.side)
|
||||
{
|
||||
case CLIENT:
|
||||
{
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
case SERVER:
|
||||
{
|
||||
return ctx.getServerHandler().playerEntity;
|
||||
}
|
||||
default:
|
||||
ModMain.Log(Level.ERROR, "Invalid side in TestMsgHandler: " + ctx.side);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package net.einsteinsci.betterbeginnings.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.*;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/22/2014.
|
||||
*/
|
||||
public class PacketNetherBrickOvenFuelLevel implements IMessage
|
||||
{
|
||||
BlockPos pos;
|
||||
|
||||
FluidStack fluid;
|
||||
|
||||
public static class PacketHandler implements IMessageHandler<PacketNetherBrickOvenFuelLevel, IMessage>
|
||||
{
|
||||
@Override
|
||||
public IMessage onMessage(PacketNetherBrickOvenFuelLevel message, MessageContext ctx)
|
||||
{
|
||||
EntityPlayer player = ModMain.proxy.getPlayerFromMessageContext(ctx);
|
||||
|
||||
TileEntityNetherBrickOven oven = (TileEntityNetherBrickOven)player.worldObj.getTileEntity(message.pos);
|
||||
oven.setFuelLevel(message.fluid);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public PacketNetherBrickOvenFuelLevel()
|
||||
{
|
||||
pos = new BlockPos(0, 0, 0);
|
||||
|
||||
fluid = null;
|
||||
}
|
||||
|
||||
public PacketNetherBrickOvenFuelLevel(BlockPos loc, FluidStack fuel)
|
||||
{
|
||||
pos = loc;
|
||||
|
||||
fluid = fuel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf)
|
||||
{
|
||||
pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
||||
|
||||
int fluidId = buf.readInt();
|
||||
int level = buf.readInt();
|
||||
|
||||
if (level != 0)
|
||||
{
|
||||
fluid = new FluidStack(fluidId, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
fluid = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf)
|
||||
{
|
||||
buf.writeInt(pos.getX());
|
||||
buf.writeInt(pos.getY());
|
||||
buf.writeInt(pos.getZ());
|
||||
|
||||
if (fluid != null)
|
||||
{
|
||||
buf.writeInt(fluid.getFluid().getID());
|
||||
buf.writeInt(fluid.amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
buf.writeInt(0);
|
||||
buf.writeInt(0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package net.einsteinsci.betterbeginnings.network;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.gui.BBGuiHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
public class ServerProxy
|
||||
{
|
||||
public void registerRenderThings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerTileEntitySpecialRenderer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void registerNetworkStuff()
|
||||
{
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(ModMain.modInstance, new BBGuiHandler());
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayerFromMessageContext(MessageContext ctx)
|
||||
{
|
||||
switch (ctx.side)
|
||||
{
|
||||
case CLIENT:
|
||||
ModMain.Log(Level.ERROR, "Message for CLIENT received for dedicated server");
|
||||
return null;
|
||||
case SERVER:
|
||||
return ctx.getServerHandler().playerEntity;
|
||||
default:
|
||||
ModMain.Log(Level.ERROR, "Invalid side in RepairTableRepairPacket.Handler: " + ctx.side);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 4/4/2015.
|
||||
*/
|
||||
public interface IBBName
|
||||
{
|
||||
public String getName();
|
||||
}
|
|
@ -0,0 +1,525 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.inventory.InventoryInfusionRepair;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by einsteinsci on 8/20/2014.
|
||||
*/
|
||||
public class InfusionRepairUtil
|
||||
{
|
||||
public static boolean canRepair(InventoryInfusionRepair repairTable, EntityPlayer player)
|
||||
{
|
||||
return canRepairIgnoreXp(repairTable) && player.experienceLevel >= getNeededLevels(repairTable);
|
||||
}
|
||||
|
||||
public static boolean canRepairIgnoreXp(InventoryInfusionRepair repairTable)
|
||||
{
|
||||
ArrayList<ItemStack> requiredItems = getRequiredStacks(repairTable);
|
||||
|
||||
if (repairTable.getStackInSlot(0) == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!repairTable.getStackInSlot(0).isItemStackDamageable())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ItemStack needed : requiredItems)
|
||||
{
|
||||
boolean foundIt = false;
|
||||
for (int j = 1; j < repairTable.getSizeInventory(); ++j)
|
||||
{
|
||||
if (repairTable.getStackInSlot(j) != null)
|
||||
{
|
||||
ItemStack tested = repairTable.getStackInSlot(j);
|
||||
if (tested.getItem() == needed.getItem() &&
|
||||
(tested.getItemDamage() == needed.getItemDamage() || needed
|
||||
.getItemDamage() == OreDictionary.WILDCARD_VALUE) &&
|
||||
tested.stackSize >= needed.stackSize)
|
||||
{
|
||||
foundIt = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundIt)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getNeededLevels(InventoryInfusionRepair repairTable)
|
||||
{
|
||||
ItemStack infusedItem = repairTable.getStackInSlot(0);
|
||||
|
||||
if (infusedItem == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (infusedItem.getItem() instanceof ItemBow)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
if (infusedItem.getItem() == RegisterItems.noobWoodSword)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (infusedItem.getItem() == RegisterItems.flintKnife || infusedItem
|
||||
.getItem() == RegisterItems.flintHatchet)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (infusedItem.getItem() == RegisterItems.boneKnife)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
else if (infusedItem.getItem() == RegisterItems.bonePickaxe)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (infusedItem.getItem() instanceof ItemTool)
|
||||
{
|
||||
ItemTool tool = (ItemTool)infusedItem.getItem();
|
||||
Item.ToolMaterial material = Item.ToolMaterial.valueOf(tool.getToolMaterialName());
|
||||
|
||||
switch (material)
|
||||
{
|
||||
case WOOD:
|
||||
return 1;
|
||||
case STONE:
|
||||
return 5;
|
||||
case IRON:
|
||||
return 10;
|
||||
case GOLD:
|
||||
return 20;
|
||||
case EMERALD: // See "WTF" below.
|
||||
return 20;
|
||||
default:
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
else if (infusedItem.getItem() instanceof ItemSword)
|
||||
{
|
||||
ItemSword sword = (ItemSword)infusedItem.getItem();
|
||||
Item.ToolMaterial material = Item.ToolMaterial.valueOf(sword.getToolMaterialName());
|
||||
|
||||
switch (material)
|
||||
{
|
||||
case WOOD:
|
||||
return 1;
|
||||
case STONE:
|
||||
return 5;
|
||||
case IRON:
|
||||
return 10;
|
||||
case GOLD:
|
||||
return 20;
|
||||
case EMERALD: // See "WTF" below.
|
||||
return 20;
|
||||
default:
|
||||
if (material == RegisterItems.NOOBWOOD)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (infusedItem.getItem() instanceof ItemArmor)
|
||||
{
|
||||
ItemArmor armor = (ItemArmor)infusedItem.getItem();
|
||||
|
||||
switch (armor.getArmorMaterial())
|
||||
{
|
||||
case LEATHER:
|
||||
return 1;
|
||||
case CHAIN:
|
||||
return 5;
|
||||
case IRON:
|
||||
return 10;
|
||||
case GOLD:
|
||||
return 20;
|
||||
case DIAMOND: // WTF MOJANG?! (See above)
|
||||
return 20;
|
||||
default:
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
else if (infusedItem.getItem() == Items.shears)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
else if (infusedItem.getItem() == Items.fishing_rod)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
else if (infusedItem.getItem() == Items.flint_and_steel)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ArrayList<ItemStack> getRequiredStacks(InventoryInfusionRepair repairTable)
|
||||
{
|
||||
ArrayList<ItemStack> requiredItems = new ArrayList<ItemStack>();
|
||||
|
||||
ItemStack repaired = repairTable.getStackInSlot(0);
|
||||
|
||||
if (repaired == null)
|
||||
{
|
||||
return requiredItems;
|
||||
}
|
||||
|
||||
if (!repaired.isItemDamaged())
|
||||
{
|
||||
return requiredItems;
|
||||
}
|
||||
|
||||
if (repaired.getItem() instanceof ItemBow)
|
||||
{
|
||||
requiredItems.add(new ItemStack(Items.stick, 2));
|
||||
requiredItems.add(new ItemStack(Items.string, 2));
|
||||
}
|
||||
|
||||
if (repaired.getItem() == RegisterItems.noobWoodSword)
|
||||
{
|
||||
requiredItems.add(new ItemStack(Blocks.planks, 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
else if (repaired.getItem() == RegisterItems.flintKnife || repaired.getItem() == RegisterItems.flintHatchet)
|
||||
{
|
||||
requiredItems.add(new ItemStack(Items.flint));
|
||||
}
|
||||
else if (repaired.getItem() == RegisterItems.boneKnife)
|
||||
{
|
||||
requiredItems.add(new ItemStack(Items.bone));
|
||||
}
|
||||
else if (repaired.getItem() == RegisterItems.bonePickaxe)
|
||||
{
|
||||
requiredItems.add(new ItemStack(RegisterItems.boneShard));
|
||||
}
|
||||
else if (repaired.getItem() instanceof ItemTool)
|
||||
{
|
||||
ItemTool tool = (ItemTool)repaired.getItem();
|
||||
Item.ToolMaterial material = Item.ToolMaterial.valueOf(tool.getToolMaterialName());
|
||||
|
||||
switch (material)
|
||||
{
|
||||
case WOOD:
|
||||
requiredItems.add(new ItemStack(Blocks.planks, 1, OreDictionary.WILDCARD_VALUE));
|
||||
break;
|
||||
case STONE:
|
||||
requiredItems.add(new ItemStack(Blocks.stone, 1));
|
||||
break;
|
||||
case IRON:
|
||||
requiredItems.add(new ItemStack(Items.iron_ingot));
|
||||
break;
|
||||
case GOLD:
|
||||
requiredItems.add(new ItemStack(Items.gold_nugget, 2));
|
||||
break;
|
||||
case EMERALD: // See "WTF" below.
|
||||
requiredItems.add(new ItemStack(Items.redstone, 24));
|
||||
break;
|
||||
default:
|
||||
requiredItems.add(new ItemStack(Items.emerald, 4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (repaired.getItem() instanceof ItemSword)
|
||||
{
|
||||
ItemSword sword = (ItemSword)repaired.getItem();
|
||||
Item.ToolMaterial material = Item.ToolMaterial.valueOf(sword.getToolMaterialName());
|
||||
|
||||
switch (material)
|
||||
{
|
||||
case WOOD:
|
||||
requiredItems.add(new ItemStack(Blocks.planks, 1, OreDictionary.WILDCARD_VALUE));
|
||||
break;
|
||||
case STONE:
|
||||
requiredItems.add(new ItemStack(Blocks.stone, 1));
|
||||
case IRON:
|
||||
requiredItems.add(new ItemStack(Items.iron_ingot));
|
||||
break;
|
||||
case GOLD:
|
||||
requiredItems.add(new ItemStack(Items.gold_nugget, 2));
|
||||
break;
|
||||
case EMERALD: // See "WTF" below.
|
||||
requiredItems.add(new ItemStack(Items.redstone, 16));
|
||||
break;
|
||||
default:
|
||||
if (material == RegisterItems.NOOBWOOD)
|
||||
{
|
||||
requiredItems.add(new ItemStack(Blocks.planks, 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
else
|
||||
{
|
||||
requiredItems.add(new ItemStack(Items.emerald, 4));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (repaired.getItem() instanceof ItemArmor)
|
||||
{
|
||||
ItemArmor armor = (ItemArmor)repaired.getItem();
|
||||
|
||||
switch (armor.getArmorMaterial())
|
||||
{
|
||||
case LEATHER:
|
||||
requiredItems.add(new ItemStack(Items.leather));
|
||||
break;
|
||||
case CHAIN:
|
||||
requiredItems.add(new ItemStack(RegisterItems.ironNugget));
|
||||
break;
|
||||
case IRON:
|
||||
requiredItems.add(new ItemStack(Items.iron_ingot));
|
||||
case GOLD:
|
||||
requiredItems.add(new ItemStack(Items.gold_nugget, 2));
|
||||
case DIAMOND: // WTF MOJANG?! (See above)
|
||||
requiredItems.add(new ItemStack(Items.redstone, 24));
|
||||
default:
|
||||
requiredItems.add(new ItemStack(Items.emerald, 4));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (repaired.getItem() == Items.shears)
|
||||
{
|
||||
requiredItems.add(new ItemStack(Items.iron_ingot));
|
||||
}
|
||||
else if (repaired.getItem() == Items.fishing_rod)
|
||||
{
|
||||
requiredItems.add(new ItemStack(Items.string, 4));
|
||||
}
|
||||
else if (repaired.getItem() == Items.flint_and_steel)
|
||||
{
|
||||
requiredItems.add(new ItemStack(Items.flint));
|
||||
}
|
||||
|
||||
if (repaired.isItemEnchanted())
|
||||
{
|
||||
if (repaired.getTagCompound() != null)
|
||||
{
|
||||
if (repaired.getTagCompound().getTag("ench") != null)
|
||||
{
|
||||
NBTTagList enchants = (NBTTagList)repaired.getTagCompound().getTag("ench");
|
||||
for (int i = 0; i < enchants.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound enchant = enchants.getCompoundTagAt(i);
|
||||
int enchId = enchant.getInteger("id");
|
||||
int level = enchant.getInteger("lvl");
|
||||
|
||||
switch (enchId)
|
||||
{
|
||||
case 0: // Protection
|
||||
requiredItems.add(new ItemStack(Blocks.iron_bars, 2 * level));
|
||||
break;
|
||||
case 1: // Fire Protection
|
||||
requiredItems.add(new ItemStack(Items.bucket, level));
|
||||
break;
|
||||
case 2: // Feather Falling
|
||||
requiredItems.add(new ItemStack(Items.feather, 2 * level));
|
||||
break;
|
||||
case 3: // Blast Protection
|
||||
requiredItems.add(new ItemStack(Blocks.cobblestone, 8 * level));
|
||||
break;
|
||||
case 4: // Projectile Protection
|
||||
requiredItems.add(new ItemStack(Items.snowball, 4 * level));
|
||||
break;
|
||||
case 5: // Respiration
|
||||
requiredItems.add(new ItemStack(Items.glass_bottle, level));
|
||||
break;
|
||||
case 6: // Aqua Affinity
|
||||
requiredItems.add(new ItemStack(Blocks.clay, level));
|
||||
break;
|
||||
case 7: // Thorns
|
||||
requiredItems.add(new ItemStack(Blocks.cactus, 4 * level));
|
||||
break;
|
||||
case 8: // Depth Strider
|
||||
// requiredItems.add(new ItemStack(Blocks.prismarine, level));
|
||||
break;
|
||||
case 16: // Sharpness
|
||||
requiredItems.add(new ItemStack(Items.quartz, 4 * level));
|
||||
break;
|
||||
case 17: // Smite
|
||||
requiredItems.add(new ItemStack(Blocks.soul_sand, 2 * level));
|
||||
break;
|
||||
case 18: // Anthropods
|
||||
requiredItems.add(new ItemStack(Items.fermented_spider_eye, level));
|
||||
break;
|
||||
case 19: // Knockback
|
||||
requiredItems.add(new ItemStack(Blocks.piston, level));
|
||||
break;
|
||||
case 20: // Fire Aspect
|
||||
requiredItems.add(new ItemStack(Items.blaze_powder, 2 * level));
|
||||
break;
|
||||
case 21: // Looting
|
||||
requiredItems.add(new ItemStack(Items.gold_ingot, 2 * level));
|
||||
break;
|
||||
case 32: // Efficiency
|
||||
requiredItems.add(new ItemStack(Items.sugar, 4 * level));
|
||||
break;
|
||||
case 33: // Silk Touch
|
||||
requiredItems.add(new ItemStack(RegisterItems.cloth, 8 * level));
|
||||
break;
|
||||
case 34: // Unbreaking
|
||||
requiredItems.add(new ItemStack(Blocks.obsidian, level));
|
||||
break;
|
||||
case 35: // Fortune
|
||||
requiredItems.add(new ItemStack(Items.dye, 4 * level, 4));
|
||||
break;
|
||||
case 48: // Power
|
||||
requiredItems.add(new ItemStack(RegisterItems.leatherStrip, level));
|
||||
break;
|
||||
case 49: // Punch
|
||||
requiredItems.add(new ItemStack(Items.gunpowder, level));
|
||||
break;
|
||||
case 50: // Flame
|
||||
requiredItems.add(new ItemStack(Items.fire_charge, level));
|
||||
break;
|
||||
case 51: // Infinity
|
||||
requiredItems.add(new ItemStack(Items.arrow, 16 * level));
|
||||
break;
|
||||
case 61: // Luck of the Sea
|
||||
requiredItems.add(new ItemStack(Blocks.waterlily, level));
|
||||
break;
|
||||
case 62: // Lure
|
||||
requiredItems.add(new ItemStack(Items.fish, level, 3));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return requiredItems;
|
||||
}
|
||||
|
||||
public static int getTakenLevels(InventoryInfusionRepair repairTable)
|
||||
{
|
||||
ItemStack infusedItem = repairTable.getStackInSlot(0);
|
||||
|
||||
if (infusedItem == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (infusedItem.getItem() == RegisterItems.noobWoodSword)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (infusedItem.getItem() == RegisterItems.flintKnife || infusedItem
|
||||
.getItem() == RegisterItems.flintHatchet)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (infusedItem.getItem() == RegisterItems.boneKnife)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else if (infusedItem.getItem() == RegisterItems.bonePickaxe)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (infusedItem.getItem() instanceof ItemTool)
|
||||
{
|
||||
ItemTool tool = (ItemTool)infusedItem.getItem();
|
||||
Item.ToolMaterial material = Item.ToolMaterial.valueOf(tool.getToolMaterialName());
|
||||
|
||||
switch (material)
|
||||
{
|
||||
case WOOD:
|
||||
return 1;
|
||||
case STONE:
|
||||
return 5;
|
||||
case IRON:
|
||||
return 5;
|
||||
case GOLD:
|
||||
return 3;
|
||||
case EMERALD: // See "WTF" below.
|
||||
return 8;
|
||||
default:
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
else if (infusedItem.getItem() instanceof ItemSword)
|
||||
{
|
||||
ItemSword sword = (ItemSword)infusedItem.getItem();
|
||||
Item.ToolMaterial material = Item.ToolMaterial.valueOf(sword.getToolMaterialName());
|
||||
|
||||
switch (material)
|
||||
{
|
||||
case WOOD:
|
||||
return 1;
|
||||
case STONE:
|
||||
return 2;
|
||||
case IRON:
|
||||
return 5;
|
||||
case GOLD:
|
||||
return 3;
|
||||
case EMERALD: // See "WTF" below.
|
||||
return 8;
|
||||
default:
|
||||
if (material == RegisterItems.NOOBWOOD)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (infusedItem.getItem() instanceof ItemArmor)
|
||||
{
|
||||
ItemArmor armor = (ItemArmor)infusedItem.getItem();
|
||||
|
||||
switch (armor.getArmorMaterial())
|
||||
{
|
||||
case LEATHER:
|
||||
return 1;
|
||||
case CHAIN:
|
||||
return 2;
|
||||
case IRON:
|
||||
return 5;
|
||||
case GOLD:
|
||||
return 3;
|
||||
case DIAMOND: // WTF MOJANG?! (See above)
|
||||
return 8;
|
||||
default:
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
else if (infusedItem.getItem() == Items.shears)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else if (infusedItem.getItem() == Items.fishing_rod)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
else if (infusedItem.getItem() == Items.flint_and_steel)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.blocks.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RegisterBlocks
|
||||
{
|
||||
public static final BlockKiln kiln = new BlockKiln(false);
|
||||
public static final BlockKiln kilnLit = new BlockKiln(true);
|
||||
public static final BlockDoubleWorkbench doubleWorkbench = new BlockDoubleWorkbench();
|
||||
public static final BlockBrickOven brickOven = new BlockBrickOven(false);
|
||||
public static final BlockBrickOven brickOvenLit = new BlockBrickOven(true);
|
||||
public static final BlockSmelter smelter = new BlockSmelter(false);
|
||||
public static final BlockSmelter smelterLit = new BlockSmelter(true);
|
||||
public static final BlockInfusionRepairStation infusionRepairStation = new BlockInfusionRepairStation();
|
||||
public static final BlockCampfire campfire = new BlockCampfire(false);
|
||||
public static final BlockCampfire campfireLit = new BlockCampfire(true);
|
||||
public static final BlockObsidianKiln obsidianKiln = new BlockObsidianKiln(false);
|
||||
public static final BlockObsidianKiln obsidianKilnLit = new BlockObsidianKiln(true);
|
||||
public static final BlockNetherBrickOven netherBrickOven = new BlockNetherBrickOven(false);
|
||||
public static final BlockNetherBrickOven netherBrickOvenLit = new BlockNetherBrickOven(true);
|
||||
public static final BlockEnderSmelter enderSmelter = new BlockEnderSmelter(false);
|
||||
public static final BlockEnderSmelter enderSmelterLit = new BlockEnderSmelter(true);
|
||||
|
||||
public static final List<Block> allBlocks = new ArrayList<>();
|
||||
|
||||
public static void register()
|
||||
{
|
||||
RegisterHelper.registerBlock(kiln);
|
||||
RegisterHelper.registerBlock(kilnLit);
|
||||
|
||||
RegisterHelper.registerBlock(doubleWorkbench);
|
||||
|
||||
RegisterHelper.registerBlock(brickOven);
|
||||
RegisterHelper.registerBlock(brickOvenLit);
|
||||
|
||||
RegisterHelper.registerBlock(smelter);
|
||||
RegisterHelper.registerBlock(smelterLit);
|
||||
|
||||
RegisterHelper.registerBlock(infusionRepairStation);
|
||||
|
||||
RegisterHelper.registerBlock(campfire);
|
||||
RegisterHelper.registerBlock(campfireLit);
|
||||
|
||||
RegisterHelper.registerBlock(obsidianKiln);
|
||||
RegisterHelper.registerBlock(obsidianKilnLit);
|
||||
|
||||
RegisterHelper.registerBlock(netherBrickOven);
|
||||
RegisterHelper.registerBlock(netherBrickOvenLit);
|
||||
|
||||
RegisterHelper.registerBlock(enderSmelter);
|
||||
RegisterHelper.registerBlock(enderSmelterLit);
|
||||
|
||||
oreDictionary();
|
||||
loadAllBlocks();
|
||||
}
|
||||
|
||||
public static void oreDictionary()
|
||||
{
|
||||
OreDictionary.registerOre("craftingTableWood", doubleWorkbench);
|
||||
}
|
||||
|
||||
private static void loadAllBlocks()
|
||||
{
|
||||
List<Field> fields = new ArrayList<>();
|
||||
Field[] allFields = RegisterBlocks.class.getFields();
|
||||
for (Field f : allFields)
|
||||
{
|
||||
if (Block.class.isAssignableFrom(f.getType()) &&
|
||||
IBBName.class.isAssignableFrom(f.getType()))
|
||||
{
|
||||
fields.add(f);
|
||||
}
|
||||
}
|
||||
|
||||
for (Field f : fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
allBlocks.add((Block)f.get(null));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ModMain.Log(Level.ERROR, "Field " + f.getName() + " does not inherit from Block.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.SmelterRecipeHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RegisterHelper
|
||||
{
|
||||
public static <T extends Item & IBBName> void registerItem(T item)
|
||||
{
|
||||
GameRegistry.registerItem(item, item.getName());
|
||||
}
|
||||
|
||||
public static <T extends Block & IBBName> void registerBlock(T block)
|
||||
{
|
||||
GameRegistry.registerBlock(block, block.getName());
|
||||
}
|
||||
|
||||
public static void registerSmelterOreRecipe(String input, ItemStack output, float experience, int gravel, int bonus,
|
||||
float chance)
|
||||
{
|
||||
for (ItemStack stack : OreDictionary.getOres(input))
|
||||
{
|
||||
SmelterRecipeHandler.addRecipe(stack, output, experience, gravel, bonus, chance);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerSmelterOreRecipe(String input, String output, float experience, int gravel, int bonus,
|
||||
float chance)
|
||||
{
|
||||
for (ItemStack stack : OreDictionary.getOres(input))
|
||||
{
|
||||
List<ItemStack> valid = OreDictionary.getOres(output);
|
||||
if (!valid.isEmpty())
|
||||
{
|
||||
SmelterRecipeHandler.addRecipe(stack, OreDictionary.getOres(output).get(0),
|
||||
experience, gravel, bonus, chance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,155 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.items.*;
|
||||
import net.einsteinsci.betterbeginnings.items.ItemCloth;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.Item.ToolMaterial;
|
||||
import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RegisterItems
|
||||
{
|
||||
public static final ToolMaterial NOOBWOOD = EnumHelper.addToolMaterial("NOOBWOOD", 0, 60, 2.0f, -4, 35);
|
||||
public static final ItemNoobWoodSword noobWoodSword = new ItemNoobWoodSword(NOOBWOOD);
|
||||
public static final ItemArmor.ArmorMaterial CLOTH = EnumHelper.addArmorMaterial(
|
||||
"CLOTH", "CLOTH", 5, new int[] {1, 3, 2, 1}, 25);
|
||||
public static final ItemClothArmor clothHat = new ItemClothArmor(CLOTH, 0, "clothHat");
|
||||
public static final ItemClothArmor clothShirt = new ItemClothArmor(CLOTH, 1, "clothShirt");
|
||||
public static final ItemClothArmor clothPants = new ItemClothArmor(CLOTH, 2, "clothPants");
|
||||
public static final ItemClothArmor clothBoots = new ItemClothArmor(CLOTH, 3, "clothBoots");
|
||||
public static final ItemKnife flintKnife = new ItemKnifeFlint();
|
||||
public static final ItemKnife boneKnife = new ItemKnifeBone();
|
||||
public static final ItemKnife ironKnife = new ItemKnifeIron();
|
||||
public static final ItemKnife diamondKnife = new ItemKnifeDiamond();
|
||||
public static final ItemKnife goldKnife = new ItemKnifeGold();
|
||||
public static final ItemFlintHatchet flintHatchet = new ItemFlintHatchet();
|
||||
public static final ItemBonePickaxe bonePickaxe = new ItemBonePickaxe();
|
||||
public static final ItemBoneShard boneShard = new ItemBoneShard();
|
||||
public static final ItemTestItem testItem = new ItemTestItem();
|
||||
public static final ItemSilk silk = new ItemSilk();
|
||||
public static final ItemThread thread = new ItemThread();
|
||||
public static final ItemCloth cloth = new ItemCloth();
|
||||
public static final ItemLeatherStrip leatherStrip = new ItemLeatherStrip();
|
||||
public static final ItemIronNugget ironNugget = new ItemIronNugget();
|
||||
public static final ItemCharredMeat charredMeat = new ItemCharredMeat();
|
||||
public static final ItemFireBow fireBow = new ItemFireBow();
|
||||
public static final ItemMarshmallow marshmallow = new ItemMarshmallow();
|
||||
public static final ItemMarshmallowCooked marshmallowCooked = new ItemMarshmallowCooked();
|
||||
public static final ItemRoastingStick roastingStick = new ItemRoastingStick();
|
||||
public static final ItemRoastingStickMallow roastingStickRawMallow = new ItemRoastingStickMallow(false);
|
||||
public static final ItemRoastingStickMallow roastingStickCookedMallow = new ItemRoastingStickMallow(true);
|
||||
public static final ItemTwine twine = new ItemTwine();
|
||||
public static final ItemRockHammer rockHammer = new ItemRockHammer(ToolMaterial.IRON);
|
||||
public static final ItemPan pan = new ItemPan();
|
||||
|
||||
public static final List<Item> allItems = new ArrayList<>();
|
||||
|
||||
public static void register()
|
||||
{
|
||||
RegisterHelper.registerItem(flintKnife);
|
||||
RegisterHelper.registerItem(boneKnife);
|
||||
RegisterHelper.registerItem(ironKnife);
|
||||
RegisterHelper.registerItem(goldKnife);
|
||||
RegisterHelper.registerItem(diamondKnife);
|
||||
|
||||
RegisterHelper.registerItem(flintHatchet);
|
||||
RegisterHelper.registerItem(bonePickaxe);
|
||||
|
||||
RegisterHelper.registerItem(boneShard);
|
||||
RegisterHelper.registerItem(testItem);
|
||||
RegisterHelper.registerItem(silk);
|
||||
RegisterHelper.registerItem(thread);
|
||||
RegisterHelper.registerItem(cloth);
|
||||
RegisterHelper.registerItem(twine);
|
||||
RegisterHelper.registerItem(leatherStrip);
|
||||
RegisterHelper.registerItem(ironNugget);
|
||||
RegisterHelper.registerItem(charredMeat);
|
||||
RegisterHelper.registerItem(fireBow);
|
||||
RegisterHelper.registerItem(rockHammer);
|
||||
RegisterHelper.registerItem(pan);
|
||||
|
||||
RegisterHelper.registerItem(marshmallow);
|
||||
RegisterHelper.registerItem(roastingStick);
|
||||
RegisterHelper.registerItem(marshmallowCooked);
|
||||
RegisterHelper.registerItem(roastingStickCookedMallow);
|
||||
RegisterHelper.registerItem(roastingStickRawMallow);
|
||||
|
||||
RegisterHelper.registerItem(clothHat);
|
||||
RegisterHelper.registerItem(clothShirt);
|
||||
RegisterHelper.registerItem(clothPants);
|
||||
RegisterHelper.registerItem(clothBoots);
|
||||
|
||||
RegisterHelper.registerItem(noobWoodSword);
|
||||
|
||||
oreDictRegistry();
|
||||
loadAllItems();
|
||||
}
|
||||
|
||||
public static void oreDictRegistry()
|
||||
{
|
||||
OreDictionary.registerOre("nuggetIron", ironNugget);
|
||||
OreDictionary.registerOre("itemKnife", new ItemStack(flintKnife, 1, OreDictionary.WILDCARD_VALUE));
|
||||
OreDictionary.registerOre("itemKnife", new ItemStack(boneKnife, 1, OreDictionary.WILDCARD_VALUE));
|
||||
OreDictionary.registerOre("itemKnife", new ItemStack(ironKnife, 1, OreDictionary.WILDCARD_VALUE));
|
||||
OreDictionary.registerOre("itemKnife", new ItemStack(goldKnife, 1, OreDictionary.WILDCARD_VALUE));
|
||||
OreDictionary.registerOre("itemKnife", new ItemStack(diamondKnife, 1, OreDictionary.WILDCARD_VALUE));
|
||||
|
||||
OreDictionary.registerOre("itemString", new ItemStack(Items.string));
|
||||
OreDictionary.registerOre("itemString", new ItemStack(thread));
|
||||
OreDictionary.registerOre("itemString", new ItemStack(twine));
|
||||
}
|
||||
|
||||
private static void loadAllItems()
|
||||
{
|
||||
List<Field> fields = new ArrayList<>();
|
||||
Field[] allFields = RegisterItems.class.getFields();
|
||||
for (Field f : allFields)
|
||||
{
|
||||
if (Item.class.isAssignableFrom(f.getType()) &&
|
||||
IBBName.class.isAssignableFrom(f.getType()))
|
||||
{
|
||||
fields.add(f);
|
||||
}
|
||||
}
|
||||
|
||||
for (Field f : fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
allItems.add((Item)f.get(null));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ModMain.Log(Level.ERROR, "Field " + f.getName() + " does not inherit from Item.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void tweakVanilla()
|
||||
{
|
||||
((ItemFood)GameRegistry.findItem("minecraft", "beef")).setPotionEffect(17, 20, 0, 20);
|
||||
((ItemFood)GameRegistry.findItem("minecraft", "porkchop")).setPotionEffect(17, 25, 0, 25);
|
||||
((ItemFood)GameRegistry.findItem("minecraft", "fish")).setPotionEffect(17, 30, 1, 60); // Both fish types here
|
||||
((ItemFood)GameRegistry.findItem("minecraft", "mutton")).setPotionEffect(17, 20, 0, 25);
|
||||
((ItemFood)GameRegistry.findItem("minecraft", "rabbit")).setPotionEffect(17, 25, 0, 30);
|
||||
|
||||
// Let's face it, the vanilla stack sizes for these suck.
|
||||
GameRegistry.findItem("minecraft", "minecart").setMaxStackSize(16);
|
||||
// Strangely enough the oak one doesn't change.
|
||||
GameRegistry.findItem("minecraft", "wooden_door").setMaxStackSize(16);
|
||||
GameRegistry.findItem("minecraft", "spruce_door").setMaxStackSize(16);
|
||||
GameRegistry.findItem("minecraft", "birch_door").setMaxStackSize(16);
|
||||
GameRegistry.findItem("minecraft", "acacia_door").setMaxStackSize(16);
|
||||
GameRegistry.findItem("minecraft", "dark_oak_door").setMaxStackSize(16);
|
||||
GameRegistry.findItem("minecraft", "iron_door").setMaxStackSize(16);
|
||||
GameRegistry.findItem("minecraft", "potion").setMaxStackSize(16);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public class RegisterModels
|
||||
{
|
||||
public static <BBBlock extends Block & IBBName, BBItem extends Item & IBBName> void register()
|
||||
{
|
||||
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
|
||||
|
||||
// blocks
|
||||
for (Block b : RegisterBlocks.allBlocks)
|
||||
{
|
||||
registerBlock((BBBlock)b);
|
||||
}
|
||||
|
||||
// items
|
||||
for (Item i : RegisterItems.allItems)
|
||||
{
|
||||
registerItem((BBItem)i);
|
||||
}
|
||||
}
|
||||
|
||||
public static <BBBlock extends Block & IBBName> void registerBlock(BBBlock block)
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(
|
||||
Item.getItemFromBlock(block), 0, new ModelResourceLocation(
|
||||
ModMain.MODID + ":" + block.getName(), "inventory"));
|
||||
}
|
||||
|
||||
public static <BBItem extends Item & IBBName> void registerItem(BBItem item)
|
||||
{
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(
|
||||
item, 0, new ModelResourceLocation(ModMain.MODID + ":" + item.getName(), "inventory"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,832 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.config.BBConfig;
|
||||
import net.einsteinsci.betterbeginnings.register.recipe.*;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.*;
|
||||
|
||||
public class RegisterRecipes
|
||||
{
|
||||
public static void addShapelessRecipes()
|
||||
{
|
||||
// Sticks from Saplings & Knife
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Items.stick), "treeSapling", "itemKnife"));
|
||||
|
||||
// Bone Shard
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(RegisterItems.boneShard, 2),
|
||||
Items.bone, "itemKnife"));
|
||||
|
||||
// Leather Strip
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(RegisterItems.leatherStrip, 3),
|
||||
Items.leather, "itemKnife"));
|
||||
|
||||
// Bonemeal from Bone Shard (a bit more rewarding)
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 2, 15), RegisterItems.boneShard);
|
||||
|
||||
// Iron Nugget
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(RegisterItems.ironNugget, 9), Items.iron_ingot);
|
||||
|
||||
// String
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Items.string, 4),
|
||||
new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE),
|
||||
"itemKnife"));
|
||||
|
||||
// Twine
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(RegisterItems.twine, 2), Blocks.vine, "itemKnife"));
|
||||
}
|
||||
|
||||
public static void addFurnaceRecipes()
|
||||
{
|
||||
addKilnRecipes();
|
||||
addBrickOvenRecipes();
|
||||
addSmelterRecipes();
|
||||
addCampfireRecipes();
|
||||
}
|
||||
|
||||
private static void addKilnRecipes()
|
||||
{
|
||||
KilnRecipes.addRecipe(Items.clay_ball, new ItemStack(Items.brick), 0.35f);
|
||||
KilnRecipes.addRecipe(Blocks.clay, new ItemStack(Blocks.hardened_clay), 0.1f);
|
||||
KilnRecipes.addRecipe(Blocks.cobblestone, new ItemStack(Blocks.stone), 0.1f);
|
||||
KilnRecipes.addRecipe(Blocks.cactus, new ItemStack(Items.dye, 1, 2), 0.1f);
|
||||
KilnRecipes.addRecipe(Blocks.log, new ItemStack(Items.coal, 1, 1), 0.15f);
|
||||
KilnRecipes.addRecipe(Blocks.log2, new ItemStack(Items.coal, 1, 1), 0.15f);
|
||||
KilnRecipes.addRecipe(Blocks.sand, new ItemStack(Blocks.glass), 0.1f);
|
||||
KilnRecipes.addRecipe(Items.beef, new ItemStack(RegisterItems.charredMeat), 0.1f);
|
||||
KilnRecipes.addRecipe(Items.porkchop, new ItemStack(RegisterItems.charredMeat), 0.1f);
|
||||
KilnRecipes.addRecipe(Items.chicken, new ItemStack(RegisterItems.charredMeat), 0.1f);
|
||||
KilnRecipes.addRecipe(new ItemStack(Items.fish, 1, 0), new ItemStack(RegisterItems.charredMeat), 0.1f);
|
||||
KilnRecipes.addRecipe(new ItemStack(Items.fish, 1, 1), new ItemStack(RegisterItems.charredMeat), 0.1f);
|
||||
}
|
||||
|
||||
private static void addBrickOvenRecipes()
|
||||
{
|
||||
BrickOvenRecipeHandler.addShapedRecipe(new ItemStack(Items.golden_apple), "GGG", "GAG", "GGG", 'G',
|
||||
Items.gold_ingot, 'A', Items.apple);
|
||||
BrickOvenRecipeHandler.addShapedRecipe(new ItemStack(Items.golden_apple, 1, 1), "###", "#A#", "###", '#',
|
||||
Blocks.gold_block, 'A', Items.apple);
|
||||
BrickOvenRecipeHandler.addShapedRecipe(new ItemStack(Items.golden_carrot), "***", "*C*", "***", '*',
|
||||
Items.gold_nugget, 'C', Items.carrot);
|
||||
BrickOvenRecipeHandler.addShapedRecipe(new ItemStack(Items.cake), "MMM", "SES", "WWW", 'M', Items.milk_bucket,
|
||||
'S', Items.sugar, 'E', Items.egg, 'W', Items.wheat);
|
||||
BrickOvenRecipeHandler.addShapedRecipe(new ItemStack(Items.bread, 2), "WWW", 'W', Items.wheat);
|
||||
BrickOvenRecipeHandler.addShapedRecipe(new ItemStack(Items.cookie, 8), "WCW", 'W', Items.wheat, 'C',
|
||||
new ItemStack(Items.dye, 1, 3)); // Cocoa bean
|
||||
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.mushroom_stew), Blocks.brown_mushroom,
|
||||
Blocks.red_mushroom, Items.bowl);
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.cooked_beef), Items.beef);
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.cooked_porkchop), Items.porkchop);
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.cooked_chicken), Items.chicken);
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.cooked_fish), Items.fish);
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.cooked_fish, 1, 1), new ItemStack(Items.fish,
|
||||
1, 1));
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.baked_potato), Items.potato);
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.pumpkin_pie), Items.egg, Items.sugar,
|
||||
Blocks.pumpkin);
|
||||
BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(Items.fermented_spider_eye), Items.spider_eye,
|
||||
Items.sugar, Blocks.brown_mushroom);
|
||||
BrickOvenRecipeHandler
|
||||
.addShapelessRecipe(new ItemStack(Items.magma_cream), Items.slime_ball, Items.blaze_powder);
|
||||
//BrickOvenRecipeHandler.addShapelessRecipe(new ItemStack(RegisterItems.roastingStickCookedMallow), RegisterItems.roastingStickRawMallow);
|
||||
}
|
||||
|
||||
private static void addSmelterRecipes()
|
||||
{
|
||||
// Vanilla Ore Recipes (keep the result vanilla to prevent weirdness)
|
||||
RegisterHelper.registerSmelterOreRecipe("oreIron", new ItemStack(Items.iron_ingot), 0.7f, 1, 1, 0.3f);
|
||||
RegisterHelper.registerSmelterOreRecipe("oreGold", new ItemStack(Items.gold_ingot), 1.0f, 2, 1, 0.2f);
|
||||
|
||||
// Modded Ore Recipes
|
||||
RegisterHelper.registerSmelterOreRecipe("oreCopper", "ingotCopper", 0.6f, 1, 1, 0.3f);
|
||||
RegisterHelper.registerSmelterOreRecipe("oreTin", "ingotTin", 0.6f, 1, 1, 0.2f);
|
||||
RegisterHelper.registerSmelterOreRecipe("oreAluminum", "ingotAluminum", 0.8f, 1, 1, 0.2f);
|
||||
RegisterHelper.registerSmelterOreRecipe("oreSilver", "ingotSilver", 1.0f, 1, 1, 0.2f);
|
||||
RegisterHelper.registerSmelterOreRecipe("oreLead", "ingotLead", 0.6f, 1, 1, 0.3f);
|
||||
|
||||
// Recipes that might be better suited in Kiln only
|
||||
if (BBConfig.canSmelterDoKilnStuff)
|
||||
{
|
||||
SmelterRecipeHandler
|
||||
.addRecipe(new ItemStack(Blocks.sand, 1, 0), new ItemStack(Blocks.glass), 0.1f, 1, 0, 0.0f);
|
||||
SmelterRecipeHandler
|
||||
.addRecipe(new ItemStack(Blocks.sand, 1, 1), new ItemStack(Blocks.stained_glass, 1, 1),
|
||||
0.1f, 1, 0, 0.0f); // Red sand makes orange stained glass.
|
||||
SmelterRecipeHandler.addRecipe(Blocks.netherrack, new ItemStack(Items.netherbrick), 0.25f, 1, 1, 0.25f);
|
||||
SmelterRecipeHandler.addRecipe(Blocks.stonebrick, new ItemStack(Blocks.stonebrick, 1, 2), 0.1f, 1, 0, 0.0f);
|
||||
|
||||
RegisterHelper.registerSmelterOreRecipe("cobblestone", new ItemStack(Blocks.stone), 0.1f, 0, 0, 0.0f);
|
||||
SmelterRecipeHandler.addRecipe(Items.clay_ball, new ItemStack(Items.brick), 0.3f, 0, 0, 0.0f);
|
||||
SmelterRecipeHandler.addRecipe(Blocks.clay, new ItemStack(Blocks.hardened_clay), 0.35f, 0, 0, 0.0f);
|
||||
}
|
||||
|
||||
// Silk touch recipes
|
||||
RegisterHelper.registerSmelterOreRecipe("oreCoal", new ItemStack(Items.coal, 1), 0.25f, 2, 2, 0.8f);
|
||||
RegisterHelper.registerSmelterOreRecipe("oreQuartz", new ItemStack(Items.quartz, 2), 0.4f, 2, 4, 0.6f);
|
||||
RegisterHelper.registerSmelterOreRecipe("oreLapis", new ItemStack(Items.dye, 8, 4), 0.5f, 2, 8, 0.8f);
|
||||
RegisterHelper.registerSmelterOreRecipe("oreRedstone", new ItemStack(Items.redstone, 4), 0.8f, 2, 4, 0.6f);
|
||||
RegisterHelper.registerSmelterOreRecipe("oreDiamond", new ItemStack(Items.diamond, 1), 1.0f, 3, 2, 0.3f);
|
||||
RegisterHelper.registerSmelterOreRecipe("oreEmerald", new ItemStack(Items.emerald, 1), 1.0f, 3, 2, 0.5f);
|
||||
|
||||
// Silk touch recipes (modded)
|
||||
}
|
||||
|
||||
private static void addCampfireRecipes()
|
||||
{
|
||||
CampfireRecipes.addRecipe(RegisterItems.roastingStickRawMallow,
|
||||
new ItemStack(RegisterItems.roastingStickCookedMallow), 0.5f);
|
||||
CampfireRecipes.addRecipe(Blocks.log, new ItemStack(Items.coal, 1, 1), 0.15f);
|
||||
CampfireRecipes.addRecipe(Blocks.log2, new ItemStack(Items.coal, 1, 1), 0.15f);
|
||||
CampfireRecipes.addRecipe(Items.beef, new ItemStack(RegisterItems.charredMeat), 0.1f);
|
||||
CampfireRecipes.addRecipe(Items.porkchop, new ItemStack(RegisterItems.charredMeat), 0.1f);
|
||||
CampfireRecipes.addRecipe(Items.chicken, new ItemStack(RegisterItems.charredMeat), 0.1f);
|
||||
CampfireRecipes.addRecipe(new ItemStack(Items.fish, 1, 0), new ItemStack(RegisterItems.charredMeat), 0.1f);
|
||||
CampfireRecipes.addRecipe(new ItemStack(Items.fish, 1, 1), new ItemStack(RegisterItems.charredMeat), 0.1f);
|
||||
|
||||
if (BBConfig.canCampfireDoAllKilnStuff)
|
||||
{
|
||||
CampfireRecipes.addRecipe(Items.clay_ball, new ItemStack(Items.brick), 0.35f);
|
||||
CampfireRecipes.addRecipe(Blocks.clay, new ItemStack(Blocks.hardened_clay), 0.1f);
|
||||
CampfireRecipes.addRecipe(Blocks.cobblestone, new ItemStack(Blocks.stone), 0.1f);
|
||||
CampfireRecipes.addRecipe(Blocks.sand, new ItemStack(Blocks.glass), 0.1f);
|
||||
}
|
||||
|
||||
CampfirePanRecipes.addRecipe(Items.beef, new ItemStack(Items.cooked_beef), 0.1f);
|
||||
CampfirePanRecipes.addRecipe(Items.porkchop, new ItemStack(Items.cooked_porkchop), 0.1f);
|
||||
CampfirePanRecipes.addRecipe(Items.chicken, new ItemStack(Items.cooked_chicken), 0.1f);
|
||||
CampfirePanRecipes.addRecipe(new ItemStack(Items.fish, 1, 0), new ItemStack(Items.cooked_fish, 1, 0), 0.1f);
|
||||
CampfirePanRecipes.addRecipe(new ItemStack(Items.fish, 1, 1), new ItemStack(Items.cooked_fish, 1, 1), 0.1f);
|
||||
}
|
||||
|
||||
public static void addAdvancedRecipes()
|
||||
{
|
||||
if (BBConfig.advancedCraftingForLotsOfThings)
|
||||
{
|
||||
// Wooden Door
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.oak_door),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"##", "##", "##",
|
||||
'#', "plankWood");
|
||||
// Iron Door
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_door),
|
||||
new Object[] {"nuggetIron", 2},
|
||||
"II", "II", "II",
|
||||
'I', "ingotIron");
|
||||
// Fence Gate
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.oak_fence_gate),
|
||||
new Object[] {"itemString", 4,
|
||||
new ItemStack(RegisterItems.leatherStrip, 4)},
|
||||
"/#/",
|
||||
"/#/",
|
||||
'/', "stickWood",
|
||||
'#', "plankWood");
|
||||
// Trapdoor
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.trapdoor),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"###", "###",
|
||||
'#', "plankWood");
|
||||
// Chest. Yep, you need iron before you can make a chest. If you absolutely must store stuff before you have
|
||||
// iron, use your kiln (provided it isn't kiln-able ;D).
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.chest),
|
||||
new Object[] {"nuggetIron", 3,
|
||||
new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"###",
|
||||
"# #",
|
||||
"###",
|
||||
'#', "plankWood");
|
||||
// Trapped Chest
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.trapped_chest),
|
||||
new Object[] {new ItemStack(RegisterItems.thread, 2),
|
||||
"dustRedstone", 2},
|
||||
"C", "H",
|
||||
'C', Blocks.chest,
|
||||
'H', Blocks.tripwire_hook);
|
||||
// Tripwire Hook
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.tripwire_hook),
|
||||
new Object[] {new ItemStack(RegisterItems.thread,
|
||||
1), // Must be thread
|
||||
"dustRedstone", 1},
|
||||
"I", "/", "#",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood",
|
||||
'#', "plankWood");
|
||||
// Piston
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.piston),
|
||||
new Object[] {"nuggetIron", 2},
|
||||
"###", "CIC", "CRC",
|
||||
'#', "plankWood",
|
||||
'I', "ingotIron",
|
||||
'C', "cobblestone",
|
||||
'R', "dustRedstone");
|
||||
// Dispenser
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.dispenser),
|
||||
new Object[] {"nuggetIron", 2},
|
||||
"###", "#B#", "#R#",
|
||||
'#', "cobblestone",
|
||||
'B', new ItemStack(Items.bow, 1, 0),
|
||||
'R', "dustRedstone");
|
||||
// Note Block
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.noteblock),
|
||||
new Object[] {"itemString", 2},
|
||||
"###", "#R#", "###",
|
||||
'#', "plankWood",
|
||||
'R', "dustRedstone");
|
||||
// Gold Rail
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.golden_rail, 6),
|
||||
new Object[] {"nuggetGold", 2},
|
||||
"G G", "G/G", "GRG",
|
||||
'G', "ingotGold",
|
||||
'/', "stickWood",
|
||||
'R', "dustRedstone");
|
||||
// Detector Rail
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.detector_rail, 6),
|
||||
new Object[] {"nuggetIron", 2, "stickWood", 4},
|
||||
"I I", "I_I", "IRI",
|
||||
'I', "ingotIron",
|
||||
'_', Blocks.stone_pressure_plate,
|
||||
'R', "dustRedstone");
|
||||
// TNT
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.tnt, 2),
|
||||
new Object[] {"itemString", 3},
|
||||
"G#G", "#G#", "G#G",
|
||||
'G', Items.gunpowder,
|
||||
'#', Blocks.sand);
|
||||
// Bookshelf
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.bookshelf),
|
||||
new Object[] {"nuggetIron", 1},
|
||||
"###", "BBB", "###",
|
||||
'#', "plankWood",
|
||||
'B', Items.book);
|
||||
// Ladder
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.ladder, 4),
|
||||
new Object[] {"itemString", 1},
|
||||
"/ /", "///", "/ /",
|
||||
'/', "stickWood");
|
||||
// Rail
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.rail, 16),
|
||||
new Object[] {"nuggetIron", 1},
|
||||
"I I", "I/I", "I I",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood");
|
||||
// Enchanting Table
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.enchanting_table),
|
||||
new Object[] {new ItemStack(Items.leather),
|
||||
"dyeRed", 1, "dyeBlue", 1},
|
||||
" B ", "D#D", "###",
|
||||
'B', Items.book,
|
||||
'D', "gemDiamond",
|
||||
'#', Blocks.obsidian);
|
||||
// Beacon
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.beacon),
|
||||
new Object[] {"blockDiamond", 1,
|
||||
new ItemStack(Items.blaze_rod, 4),
|
||||
new ItemStack(Items.potionitem, 1, 16)}, //Awkward potion
|
||||
"+++", "+S+", "###",
|
||||
'+', "blockGlassColorless",
|
||||
'S', Items.nether_star,
|
||||
'#', Blocks.obsidian);
|
||||
// Anvil
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.anvil), new Object[] {"nuggetIron", 4},
|
||||
"###", " I ", "III",
|
||||
'#', "blockIron",
|
||||
'I', "ingotIron");
|
||||
// Hopper
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.hopper, 4), new Object[] {"nuggetIron", 2,
|
||||
new ItemStack(Blocks.stone_pressure_plate, 1)},
|
||||
"I I", "I#I", " I ",
|
||||
'I', "ingotIron",
|
||||
'#', Blocks.chest);
|
||||
// Activator Rail
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.activator_rail, 6),
|
||||
new Object[] {"nuggetIron", 4},
|
||||
"I/I", "IiI", "I/I",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood",
|
||||
'i', Blocks.redstone_torch);
|
||||
// Dropper
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Blocks.dropper),
|
||||
new Object[] {"nuggetIron", 2},
|
||||
"###", "# #", "#R#",
|
||||
'#', "cobblestone",
|
||||
'R', "dustRedstone");
|
||||
// Minecart
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.minecart),
|
||||
new Object[] {"nuggetIron", 2,
|
||||
new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"I I", "III",
|
||||
'I', "ingotIron");
|
||||
// Compass
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.compass),
|
||||
new Object[] {"nuggetIron", 3,
|
||||
new ItemStack(Items.potionitem, 1, 0)}, //Water Bottle
|
||||
" I ", "IRI", " I ",
|
||||
'I', "ingotIron",
|
||||
'R', "dustRedstone");
|
||||
// Clock
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.clock),
|
||||
new Object[] {"nuggetGold", 3, "dyeBlack", 1},
|
||||
" G ", "GRG", " G ",
|
||||
'G', "ingotGold",
|
||||
'R', "dustRedstone");
|
||||
// Bed
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.bed), new Object[] {"nuggetIron", 2},
|
||||
"***", "###",
|
||||
'*', new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE),
|
||||
'#', "plankWood");
|
||||
// Brewing Stand
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.brewing_stand),
|
||||
new Object[] {"nuggetGold", 1, "nuggetIron", 3},
|
||||
" / ", "###",
|
||||
'/', Items.blaze_rod,
|
||||
'#', "cobblestone");
|
||||
// Cauldron
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.cauldron), new Object[] {"nuggetIron", 3},
|
||||
"I I", "I I", "III",
|
||||
'I', "ingotIron");
|
||||
}
|
||||
|
||||
// Bow
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.bow),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 3)},
|
||||
" /s", "/ s", " /s",
|
||||
's', "itemString",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.bow),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 3)},
|
||||
"s/ ", "s /", "s/ ",
|
||||
's', "itemString",
|
||||
'/', "stickWood");
|
||||
|
||||
// Fishing rod
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.fishing_rod),
|
||||
new Object[] {new ItemStack(RegisterItems.ironNugget)},
|
||||
" /", " /s", "/ s",
|
||||
'/', "stickWood",
|
||||
's', "itemString");
|
||||
|
||||
// Bone Pickaxe
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.bonePickaxe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"sBs", " / ", " / ",
|
||||
's', RegisterItems.boneShard,
|
||||
'B', Items.bone,
|
||||
'/', "stickWood");
|
||||
|
||||
// Leather armor
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.leather_helmet),
|
||||
new Object[] {"itemString", 3,
|
||||
new ItemStack(Blocks.wool, 2, OreDictionary.WILDCARD_VALUE)},
|
||||
"LLL",
|
||||
"L L",
|
||||
'L', Items.leather);
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.leather_chestplate),
|
||||
new Object[] {"itemString", 2,
|
||||
new ItemStack(Blocks.wool, 4, OreDictionary.WILDCARD_VALUE)},
|
||||
"L L",
|
||||
"LLL",
|
||||
"LLL",
|
||||
'L', Items.leather);
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.leather_leggings),
|
||||
new Object[] {"itemString", 4,
|
||||
new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE)},
|
||||
"LLL",
|
||||
"L L",
|
||||
"L L",
|
||||
'L', Items.leather);
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.leather_boots),
|
||||
new Object[] {"itemString", 4,
|
||||
new ItemStack(Blocks.wool, 3, OreDictionary.WILDCARD_VALUE)},
|
||||
"L L", "L L",
|
||||
'L', Items.leather);
|
||||
|
||||
// Stone Tools/Weapons
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.stone_pickaxe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"###", " / ", " / ",
|
||||
'#', "stone",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.stone_sword),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"#", "#", "/",
|
||||
'#', "stone",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.stone_shovel),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"#", "/", "/",
|
||||
'#', "stone",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.stone_axe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"##", "#/", " /",
|
||||
'#', "stone",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.stone_axe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"##", "/#", "/ ",
|
||||
'#', "stone",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.stone_hoe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"##", " /", " /",
|
||||
'#', "stone",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.stone_hoe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"##", "/ ", "/ ",
|
||||
'#', "stone",
|
||||
'/', "stickWood");
|
||||
|
||||
// Iron armor
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_helmet),
|
||||
new Object[] {"nuggetIron", 2,
|
||||
new ItemStack(RegisterItems.leatherStrip, 3),
|
||||
new ItemStack(Blocks.wool, 2, OreDictionary.WILDCARD_VALUE)},
|
||||
"III", "I I",
|
||||
'I', "ingotIron");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_chestplate),
|
||||
new Object[] {"nuggetIron", 6,
|
||||
new ItemStack(RegisterItems.leatherStrip, 2),
|
||||
new ItemStack(Blocks.wool, 4, OreDictionary.WILDCARD_VALUE)},
|
||||
"I I", "III", "III",
|
||||
'I', "ingotIron");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_leggings),
|
||||
new Object[] {"nuggetIron", 4,
|
||||
new ItemStack(RegisterItems.leatherStrip, 4),
|
||||
new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE)},
|
||||
"III", "I I", "I I",
|
||||
'I', "ingotIron");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_boots),
|
||||
new Object[] {"nuggetIron", 3,
|
||||
new ItemStack(RegisterItems.leatherStrip, 2),
|
||||
new ItemStack(Blocks.wool, 3, OreDictionary.WILDCARD_VALUE)},
|
||||
"I I", "I I",
|
||||
'I', "ingotIron");
|
||||
|
||||
// Iron Tools/Weapons
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_pickaxe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 3)},
|
||||
"III", " / ", " / ",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_sword),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"I", "I", "/",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_shovel),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"I", "/", "/",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_axe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"II", "I/", " /",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_axe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"II", "/I", "/ ",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_hoe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"II", " /", " /",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.iron_hoe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"II", "/ ", "/ ",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.ironKnife),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
" I", "/ ",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.ironKnife),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"I ", " /",
|
||||
'I', "ingotIron",
|
||||
'/', "stickWood");
|
||||
//Gold armor
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_helmet),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 3),
|
||||
"nuggetGold", 2,
|
||||
new ItemStack(Blocks.wool, 2, OreDictionary.WILDCARD_VALUE)},
|
||||
"III", "I I",
|
||||
'I', "ingotGold");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_chestplate),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2),
|
||||
"nuggetGold", 6,
|
||||
new ItemStack(Blocks.wool, 4, OreDictionary.WILDCARD_VALUE)},
|
||||
"I I",
|
||||
"III",
|
||||
"III",
|
||||
'I', "ingotGold");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_leggings),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 4),
|
||||
"nuggetGold", 4,
|
||||
new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE)},
|
||||
"III",
|
||||
"I I",
|
||||
"I I",
|
||||
'I', "ingotGold");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_boots),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2),
|
||||
"nuggetGold", 3,
|
||||
new ItemStack(Blocks.wool, 3, OreDictionary.WILDCARD_VALUE)},
|
||||
"I I", "I I",
|
||||
'I', "ingotGold");
|
||||
|
||||
|
||||
//Gold Weapons/Tools
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_pickaxe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 3)},
|
||||
"III", " / ", " / ",
|
||||
'I', "ingotGold",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_sword),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"I", "I", "/",
|
||||
'I', "ingotGold",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_shovel),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"I", "/", "/",
|
||||
'I', "ingotGold",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_axe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"II", "I/", " /",
|
||||
'I', "ingotGold",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_axe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"II", "/I", "/ ",
|
||||
'I', "ingotGold",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_hoe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"II", " /", " /",
|
||||
'I', Items.gold_ingot,
|
||||
'/', Items.stick);
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.golden_hoe),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"II", "/ ", "/ ",
|
||||
'I', "ingotGold",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.goldKnife),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
" I", "/ ",
|
||||
'I', "ingotGold",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.goldKnife),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"I ", " /",
|
||||
'I', "ingotGold",
|
||||
'/', "stickWood");
|
||||
|
||||
// Diamond armor
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_helmet),
|
||||
new Object[] {"dustRedstone", 3,
|
||||
new ItemStack(Items.blaze_powder, 2),
|
||||
new ItemStack(RegisterItems.leatherStrip, 3),
|
||||
new ItemStack(Blocks.wool, 2, OreDictionary.WILDCARD_VALUE)},
|
||||
"DDD", "D D",
|
||||
'D', "gemDiamond");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_chestplate),
|
||||
new Object[] {"dustRedstone", 4,
|
||||
new ItemStack(Items.blaze_powder, 6),
|
||||
new ItemStack(RegisterItems.leatherStrip, 2),
|
||||
new ItemStack(Blocks.wool, 4, OreDictionary.WILDCARD_VALUE)},
|
||||
"D D", "DDD", "DDD",
|
||||
'D', "gemDiamond");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_leggings),
|
||||
new Object[] {"dustRedstone", 4,
|
||||
new ItemStack(Items.blaze_powder, 3),
|
||||
new ItemStack(RegisterItems.leatherStrip, 4),
|
||||
new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE)},
|
||||
"DDD", "D D", "D D",
|
||||
'D', "gemDiamond");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_boots),
|
||||
new Object[] {"dustRedstone", 3,
|
||||
new ItemStack(Items.blaze_powder, 3),
|
||||
new ItemStack(RegisterItems.leatherStrip, 2),
|
||||
new ItemStack(Blocks.wool, 3, OreDictionary.WILDCARD_VALUE)},
|
||||
"D D", "D D",
|
||||
'D', "gemDiamond");
|
||||
|
||||
// Diamond Tools/Weapons
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_pickaxe),
|
||||
new Object[] {"dustRedstone", 5,
|
||||
new ItemStack(RegisterItems.leatherStrip, 3)},
|
||||
"DDD", " / ", " / ",
|
||||
'D', "gemDiamond",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_sword),
|
||||
new Object[] {"dustRedstone", 4,
|
||||
new ItemStack(Items.blaze_powder, 5),
|
||||
new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"D", "D", "/",
|
||||
'D', "gemDiamond",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_shovel),
|
||||
new Object[] {"dustRedstone", 2,
|
||||
new ItemStack(Items.blaze_powder, 1),
|
||||
new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"D", "/", "/",
|
||||
'D', "gemDiamond",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_axe),
|
||||
new Object[] {"dustRedstone", 3,
|
||||
new ItemStack(Items.blaze_powder, 2),
|
||||
new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"DD", "D/", " /",
|
||||
'D', "gemDiamond",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_axe),
|
||||
new Object[] {"dustRedstone", 3,
|
||||
new ItemStack(Items.blaze_powder, 2),
|
||||
new ItemStack(RegisterItems.leatherStrip, 2)},
|
||||
"DD", "/D", "/ ",
|
||||
'D', "gemDiamond",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_hoe),
|
||||
new Object[] {"dustRedstone", 1,
|
||||
new ItemStack(Items.blaze_powder, 1),
|
||||
new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"DD", " /", " /",
|
||||
'D', "gemDiamond",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(Items.diamond_hoe),
|
||||
new Object[] {"dustRedstone", 1,
|
||||
new ItemStack(Items.blaze_powder, 1),
|
||||
new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"DD", "/ ", "/ ",
|
||||
'D', "gemDiamond",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.diamondKnife),
|
||||
new Object[] {"dustRedstone", 3,
|
||||
new ItemStack(Items.blaze_powder, 3),
|
||||
new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
" D", "/ ",
|
||||
'D', "gemDiamond",
|
||||
'/', "stickWood");
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.diamondKnife),
|
||||
new Object[] {"dustRedstone", 3,
|
||||
new ItemStack(Items.blaze_powder, 3),
|
||||
new ItemStack(RegisterItems.leatherStrip, 1)},
|
||||
"D ", " /",
|
||||
'D', "gemDiamond",
|
||||
'/', "stickWood");
|
||||
|
||||
// Repair Infusion Station
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterBlocks.infusionRepairStation),
|
||||
new Object[] {"dustRedstone", 32, "dyeBlue", 32,
|
||||
new ItemStack(Items.blaze_powder, 16)},
|
||||
"DID", "OSO", "OOO",
|
||||
'D', "gemDiamond",
|
||||
'I', "blockIron",
|
||||
'S', Blocks.bookshelf,
|
||||
'O', Blocks.obsidian);
|
||||
|
||||
// Obsidian Kiln
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterBlocks.obsidianKiln),
|
||||
new Object[] {"dustRedstone", 16},
|
||||
"ROR", "OKO", "ROR",
|
||||
'R', "dustRedstone",
|
||||
'O', Blocks.obsidian,
|
||||
'K', RegisterBlocks.kiln);
|
||||
|
||||
// Nether Brick Oven
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterBlocks.netherBrickOven),
|
||||
new Object[] {new ItemStack(Items.blaze_powder, 4),
|
||||
new ItemStack(Blocks.obsidian, 1)},
|
||||
"NNN", "NBN", "NGN",
|
||||
'N', Blocks.nether_brick,
|
||||
'G', "blockGlassColorless",
|
||||
'B', RegisterBlocks.brickOven);
|
||||
|
||||
// Ender Smelter
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterBlocks.enderSmelter),
|
||||
new Object[] {new ItemStack(Items.ender_pearl, 4), "nuggetIron", 4},
|
||||
"#E#", "#S#", "#E#",
|
||||
'#', Blocks.end_stone,
|
||||
'S', RegisterBlocks.smelter,
|
||||
'E', Items.ender_eye);
|
||||
|
||||
// Rock Hammer
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.rockHammer),
|
||||
new Object[] {new ItemStack(RegisterItems.leatherStrip, 2),
|
||||
"nuggetIron", 2},
|
||||
"I#I", " / ", " / ",
|
||||
'I', "ingotIron",
|
||||
'#', Blocks.stone,
|
||||
'/', "stickWood");
|
||||
|
||||
// Pan
|
||||
AdvancedCraftingHandler.addAdvancedRecipe(new ItemStack(RegisterItems.pan), new Object[] {"nuggetIron", 2,},
|
||||
"/ ", " II",
|
||||
'/', "stickWood",
|
||||
'I', "ingotIron");
|
||||
}
|
||||
|
||||
public static void addShapedRecipes()
|
||||
{
|
||||
//Roasting stick
|
||||
GameRegistry.addRecipe(
|
||||
new ShapedOreRecipe(new ItemStack(RegisterItems.roastingStick), " s", "s ", 's', "stickWood"));
|
||||
|
||||
// Knife
|
||||
GameRegistry.addShapedRecipe(new ItemStack(RegisterItems.flintKnife), "F ", " F", 'F', Items.flint);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(RegisterItems.flintKnife), " F", "F ", 'F', Items.flint);
|
||||
|
||||
GameRegistry.addShapedRecipe(new ItemStack(RegisterItems.boneKnife), " S", "/ ", 'S', RegisterItems.boneShard,
|
||||
'/', Items.bone);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(RegisterItems.boneKnife), "S ", " /", 'S', RegisterItems.boneShard,
|
||||
'/', Items.bone);
|
||||
|
||||
// Thread
|
||||
GameRegistry.addShapedRecipe(new ItemStack(RegisterItems.thread), "ss", "ss", 's', RegisterItems.silk);
|
||||
|
||||
// Cloth
|
||||
GameRegistry.addShapedRecipe(new ItemStack(RegisterItems.cloth, 4), "ttt", "ttt", 't', RegisterItems.thread);
|
||||
|
||||
// Flint Hatchet
|
||||
GameRegistry.addRecipe(
|
||||
new ShapedOreRecipe(new ItemStack(RegisterItems.flintHatchet), "FL", " /", 'F', Items.flint, 'L',
|
||||
RegisterItems.leatherStrip, '/', "stickWood"));
|
||||
|
||||
// Noob Wood Sword
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RegisterItems.noobWoodSword), "#", "#", "/",
|
||||
'#', "plankWood", '/', "stickWood"));
|
||||
|
||||
// Kiln
|
||||
GameRegistry.addRecipe(
|
||||
new ShapedOreRecipe(new ItemStack(RegisterBlocks.kiln), "###", "# #", "###", '#', "cobblestone"));
|
||||
|
||||
// Brick Oven
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RegisterBlocks.brickOven), "BBB", "# #", "###",
|
||||
'#', Blocks.brick_block, 'B', "ingotBrick"));
|
||||
|
||||
// Smelter
|
||||
GameRegistry.addShapedRecipe(new ItemStack(RegisterBlocks.smelter), "###", "#C#", "###", '#', new ItemStack(
|
||||
Blocks.stonebrick, 1, 0), 'C', new ItemStack(Items.coal, 1, 1));
|
||||
|
||||
// Vanilla Furnace
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Blocks.furnace), "###", "# #", "---", '#', Blocks.cobblestone, '-',
|
||||
Blocks.stone_slab);
|
||||
|
||||
// Gravel->Flint
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Items.flint), "##", "##", '#', Blocks.gravel);
|
||||
|
||||
// Iron Nugget->Ingot
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Items.iron_ingot), "***", "***", "***", '*',
|
||||
RegisterItems.ironNugget);
|
||||
|
||||
// Workbench
|
||||
GameRegistry.addShapedRecipe(new ItemStack(RegisterBlocks.doubleWorkbench), "##", "##", '#', new ItemStack(
|
||||
Blocks.planks, 1, OreDictionary.WILDCARD_VALUE));
|
||||
|
||||
if (BBConfig.canMakeChainArmor)
|
||||
{
|
||||
// Chain Armor
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Items.chainmail_helmet), "***", "* *", '*',
|
||||
RegisterItems.ironNugget);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Items.chainmail_chestplate), "* *", "***", "***", '*',
|
||||
RegisterItems.ironNugget);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Items.chainmail_leggings), "***", "* *", "* *", '*',
|
||||
RegisterItems.ironNugget);
|
||||
GameRegistry.addShapedRecipe(new ItemStack(Items.chainmail_boots), "* *", "* *", '*',
|
||||
RegisterItems.ironNugget);
|
||||
}
|
||||
|
||||
// Craft vanilla benches into BB workbenches
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RegisterBlocks.doubleWorkbench, 2), "##", '#',
|
||||
"craftingTableWood"));
|
||||
GameRegistry
|
||||
.addShapedRecipe(new ItemStack(RegisterBlocks.doubleWorkbench, 2), "##", '#', Blocks.crafting_table);
|
||||
|
||||
// Craft BB workbenches into vanilla ones
|
||||
if (BBConfig.canMakeVanillaWorkbench)
|
||||
{
|
||||
GameRegistry.addShapedRecipe(
|
||||
new ItemStack(Blocks.crafting_table), "#", '#', RegisterBlocks.doubleWorkbench);
|
||||
}
|
||||
|
||||
// Campfire
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RegisterBlocks.campfire),
|
||||
"LL", "##",
|
||||
'L', "logWood",
|
||||
'#', "cobblestone"));
|
||||
|
||||
// Fire Bow
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(RegisterItems.fireBow),
|
||||
"//", "/s",
|
||||
'/', "stickWood",
|
||||
's', "itemString"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.ModMain;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.*;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
public class RegisterTileEntities
|
||||
{
|
||||
public static void register()
|
||||
{
|
||||
GameRegistry.registerTileEntity(TileEntityKiln.class, ModMain.MODID + ":TileEntityKiln");
|
||||
GameRegistry.registerTileEntity(TileEntityBrickOven.class, ModMain.MODID + ":TileEntityBrickOven");
|
||||
GameRegistry.registerTileEntity(TileEntitySmelter.class, ModMain.MODID + ":TileEntitySmelter");
|
||||
GameRegistry.registerTileEntity(TileEntityCampfire.class, ModMain.MODID + ":TileEntityCampfire");
|
||||
GameRegistry.registerTileEntity(TileEntityObsidianKiln.class, ModMain.MODID + ":TileEntityObsidianKiln");
|
||||
GameRegistry.registerTileEntity(TileEntityNetherBrickOven.class, ModMain.MODID + ":TileEntityNetherBrickOven");
|
||||
GameRegistry.registerTileEntity(TileEntityEnderSmelter.class, ModMain.MODID + ":TileEntityEnderSmelter");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
package net.einsteinsci.betterbeginnings.register;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.config.BBConfig;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class RemoveRecipes
|
||||
{
|
||||
public static void remove()
|
||||
{
|
||||
List<Item> removedRecipes = new ArrayList<Item>();
|
||||
|
||||
// Be sure to get the correct quantity and damage
|
||||
|
||||
// Replaced/Obsolete Items
|
||||
removedRecipes.add(Items.wooden_sword);
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.furnace));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.crafting_table));
|
||||
|
||||
if (BBConfig.removeWoodToolRecipes)
|
||||
{
|
||||
removedRecipes.add(Items.wooden_pickaxe);
|
||||
removedRecipes.add(Items.wooden_axe);
|
||||
removedRecipes.add(Items.wooden_shovel);
|
||||
removedRecipes.add(Items.wooden_hoe);
|
||||
}
|
||||
|
||||
// Advanced Crafting
|
||||
if (BBConfig.requireAdvancedCrafting)
|
||||
{
|
||||
if (BBConfig.advancedCraftingForLotsOfThings)
|
||||
{
|
||||
// TODO: remove recipes for all types of doors and gates
|
||||
|
||||
removedRecipes.add(Items.oak_door); // here
|
||||
removedRecipes.add(Items.iron_door);
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.oak_fence_gate)); // and here
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.trapdoor));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.chest));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.trapped_chest));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.piston));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.tripwire_hook));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.dispenser));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.noteblock));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.golden_rail));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.detector_rail));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.tnt));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.bookshelf));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.ladder));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.rail));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.enchanting_table));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.beacon));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.anvil));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.hopper));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.activator_rail));
|
||||
removedRecipes.add(Item.getItemFromBlock(Blocks.dropper));
|
||||
removedRecipes.add(Items.minecart);
|
||||
removedRecipes.add(Items.compass);
|
||||
removedRecipes.add(Items.clock);
|
||||
removedRecipes.add(Items.bed);
|
||||
removedRecipes.add(Items.brewing_stand);
|
||||
removedRecipes.add(Items.cauldron);
|
||||
}
|
||||
|
||||
removedRecipes.add(Items.bow);
|
||||
removedRecipes.add(Items.fishing_rod);
|
||||
|
||||
removedRecipes.add(Items.leather_helmet);
|
||||
removedRecipes.add(Items.leather_chestplate);
|
||||
removedRecipes.add(Items.leather_leggings);
|
||||
removedRecipes.add(Items.leather_boots);
|
||||
|
||||
removedRecipes.add(Items.stone_pickaxe);
|
||||
removedRecipes.add(Items.stone_sword);
|
||||
removedRecipes.add(Items.stone_axe);
|
||||
removedRecipes.add(Items.stone_shovel);
|
||||
removedRecipes.add(Items.stone_hoe);
|
||||
|
||||
removedRecipes.add(Items.iron_pickaxe);
|
||||
removedRecipes.add(Items.iron_sword);
|
||||
removedRecipes.add(Items.iron_axe);
|
||||
removedRecipes.add(Items.iron_shovel);
|
||||
removedRecipes.add(Items.iron_hoe);
|
||||
|
||||
removedRecipes.add(Items.iron_helmet);
|
||||
removedRecipes.add(Items.iron_chestplate);
|
||||
removedRecipes.add(Items.iron_leggings);
|
||||
removedRecipes.add(Items.iron_boots);
|
||||
|
||||
removedRecipes.add(Items.diamond_sword);
|
||||
removedRecipes.add(Items.diamond_pickaxe);
|
||||
removedRecipes.add(Items.diamond_axe);
|
||||
removedRecipes.add(Items.diamond_shovel);
|
||||
removedRecipes.add(Items.diamond_hoe);
|
||||
|
||||
removedRecipes.add(Items.diamond_helmet);
|
||||
removedRecipes.add(Items.diamond_chestplate);
|
||||
removedRecipes.add(Items.diamond_leggings);
|
||||
removedRecipes.add(Items.diamond_boots);
|
||||
}
|
||||
|
||||
// Food that should be cooked in ovens
|
||||
if (BBConfig.removeCraftedFoodRecipes)
|
||||
{
|
||||
removedRecipes.add(Items.bread);
|
||||
removedRecipes.add(Items.cake);
|
||||
removedRecipes.add(Items.cookie);
|
||||
removedRecipes.add(Items.fermented_spider_eye);
|
||||
removedRecipes.add(Items.golden_apple);
|
||||
removedRecipes.add(Items.magma_cream);
|
||||
removedRecipes.add(Items.pumpkin_pie);
|
||||
}
|
||||
|
||||
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
|
||||
Iterator<IRecipe> iterator = recipes.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ItemStack stack = iterator.next().getRecipeOutput();
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
if (item != null && removedRecipes.contains(item))
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeFurnaceRecipes()
|
||||
{
|
||||
List<ItemStack> vanillaSmeltingOutputs = new ArrayList<ItemStack>();
|
||||
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.baked_potato));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.brick));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.coal)); //charcoal, coal silk-touched
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.cooked_beef));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.cooked_chicken));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.cooked_fish));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.cooked_porkchop));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.diamond)); //silk-touched
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.dye)); //Cactus green, lapis silk-touched
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.emerald)); //silk-touched
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.gold_ingot));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.iron_ingot));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.netherbrick));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.quartz)); //silk-touched
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Items.redstone)); //silk-touched
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Blocks.glass));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Blocks.hardened_clay));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Blocks.sponge)); //1.8
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Blocks.stone));
|
||||
vanillaSmeltingOutputs.add(new ItemStack(Blocks.stonebrick)); //1.8
|
||||
|
||||
if (BBConfig.removeSmeltingRecipes)
|
||||
{
|
||||
// Remove ALL THE THINGS!
|
||||
Map recipes = FurnaceRecipes.instance().getSmeltingList();
|
||||
Iterator iterator = recipes.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Map.Entry entry = (Map.Entry)iterator.next();
|
||||
ItemStack result = (ItemStack)entry.getValue();
|
||||
boolean isVanilla = false;
|
||||
for (ItemStack vanilla : vanillaSmeltingOutputs)
|
||||
{
|
||||
if (vanilla.getItem() == result.getItem())
|
||||
{
|
||||
isVanilla = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!BBConfig.removeOnlyVanillaSmeltingRecipes || isVanilla)
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Buffer
|
|
@ -0,0 +1,90 @@
|
|||
package net.einsteinsci.betterbeginnings.register.achievement;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterBlocks;
|
||||
import net.einsteinsci.betterbeginnings.register.RegisterItems;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.Achievement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class RegisterAchievements
|
||||
{
|
||||
public static final RegisterAchievements instance = new RegisterAchievements();
|
||||
|
||||
private static Map<String, Achievement> achievements;
|
||||
|
||||
public static RegisterAchievements getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static Achievement[] getAchievements()
|
||||
{
|
||||
addAchievements();
|
||||
|
||||
return achievements.values().toArray(new Achievement[1]);
|
||||
}
|
||||
|
||||
public static void addAchievements()
|
||||
{
|
||||
achievements = new HashMap<String, Achievement>();
|
||||
|
||||
achievements.put("flintKnife", new Achievement("achievement.flintKnife", "flintKnife", 0, 0,
|
||||
RegisterItems.flintKnife, null).setSpecial());
|
||||
achievements.put("makeString", new Achievement("achievement.makeString", "makeString", -2, -1,
|
||||
Items.string, get("flintKnife")));
|
||||
achievements.put("makeTwine", new Achievement("achievement.makeTwine", "makeTwine", 0, -2, RegisterItems.twine,
|
||||
get("flintKnife")));
|
||||
achievements.put("upgradeKnife", new Achievement("achievement.upgradeKnife", "upgradeKnife", 3, -1,
|
||||
RegisterItems.boneKnife, get("flintKnife")));
|
||||
achievements.put("makeSticks", new Achievement("achievement.makeSticks", "makeSticks", -2, 1, Items.stick,
|
||||
get("flintKnife")));
|
||||
achievements.put("makeHatchet", new Achievement("achievement.makeHatchet", "makeHatchet", -1, 3,
|
||||
RegisterItems.flintHatchet, get("makeSticks")));
|
||||
achievements.put("doubleWorkbench", new Achievement("achievement.doubleWorkbench", "doubleWorkbench", -3, 4,
|
||||
RegisterBlocks.doubleWorkbench, get("makeHatchet")));
|
||||
achievements.put("makeSword", new Achievement("achievement.makeSword", "makeSword", -4, 6, Items.stone_sword,
|
||||
get("doubleWorkbench")));
|
||||
achievements.put("infusionRepair", new Achievement("achievement.infusionRepair", "infusionRepair", -2, 7,
|
||||
RegisterBlocks.infusionRepairStation,
|
||||
get("doubleWorkbench")));
|
||||
achievements.put("repairNoobSword", new Achievement("achievement.repairNoobSword", "repairNoobSword", -1, 9,
|
||||
RegisterItems.noobWoodSword, get("infusionRepair")));
|
||||
achievements.put("boneShards", new Achievement("achievement.boneShards", "boneShards", 3, 2,
|
||||
RegisterItems.boneShard, get("flintKnife")));
|
||||
achievements.put("bonePick", new Achievement("achievement.bonePick", "bonePick", 4, 4,
|
||||
RegisterItems.bonePickaxe, get("boneShards")));
|
||||
achievements.put("makeKiln", new Achievement("achievement.makeKiln", "makeKiln", 5, 6, RegisterBlocks.kiln,
|
||||
get("bonePick")));
|
||||
achievements.put("charredMeat", new Achievement("achievement.charredMeat", "charredMeat", 4, 8,
|
||||
RegisterItems.charredMeat, get("makeKiln")));
|
||||
achievements.put("obsidianKiln", new Achievement("achievement.obsidianKiln", "obsidianKiln", 6, 9,
|
||||
RegisterBlocks.obsidianKiln, get("makeKiln")));
|
||||
achievements.put("makeSmelter", new Achievement("achievement.makeSmelter", "makeSmelter", 2, 6,
|
||||
RegisterBlocks.smelter, get("makeKiln")));
|
||||
achievements.put("enderSmelter", new Achievement("achievement.enderSmelter", "enderSmelter", 1, 8,
|
||||
RegisterBlocks.enderSmelter, get("makeSmelter")));
|
||||
//achievements.put("oreDoubling", new Achievement("achievement.oreDoubling", "oreDoubling", 5, 6,
|
||||
// Items.gold_ingot, get("enderSmelter")));
|
||||
achievements.put("makeBrickOven", new Achievement("achievement.makeBrickOven", "makeBrickOven", 8, 5,
|
||||
RegisterBlocks.brickOven, get("makeKiln")));
|
||||
achievements.put("cake", new Achievement("achievement.cake", "cake", 7, 3, Items.cake, get("makeBrickOven")));
|
||||
achievements.put("netherBrickOven", new Achievement("achievement.netherBrickOven", "netherBrickOven", 9, 8,
|
||||
RegisterBlocks.netherBrickOven, get("makeBrickOven")));
|
||||
achievements.put("notchApple", new Achievement("achievement.notchApple", "notchApple", 11, 9, new ItemStack(
|
||||
Items.golden_apple, 1, 0), get("netherBrickOven")));
|
||||
}
|
||||
|
||||
public static Achievement get(String key)
|
||||
{
|
||||
return achievements.get(key);
|
||||
}
|
||||
|
||||
public static void achievementGet(EntityPlayer player, String achievementKey)
|
||||
{
|
||||
player.addStat(RegisterAchievements.get(achievementKey), 1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,268 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.inventory.InventoryWorkbenchAdditionalMaterials;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class AdvancedCraftingHandler
|
||||
{
|
||||
private static final AdvancedCraftingHandler CRAFTING = new AdvancedCraftingHandler();
|
||||
public List<AdvancedRecipe> recipes = new ArrayList<>();
|
||||
|
||||
public AdvancedCraftingHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void addAdvancedRecipe(ItemStack result, Object[] additionalMaterials, Object... args)
|
||||
{
|
||||
crafting().addRecipe(result, additionalMaterials, args);
|
||||
}
|
||||
|
||||
public AdvancedRecipe addRecipe(ItemStack result, Object[] additionalMaterials, Object... args)
|
||||
{
|
||||
String totalRecipe = "";
|
||||
int i = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
List<OreRecipeElement> addedMatList = new ArrayList<OreRecipeElement>();
|
||||
String lastString = "";
|
||||
for (Object mat : additionalMaterials)
|
||||
{
|
||||
if (mat instanceof ItemStack)
|
||||
{
|
||||
addedMatList.add(new OreRecipeElement((ItemStack)mat));
|
||||
}
|
||||
else if (mat instanceof String)
|
||||
{
|
||||
lastString = (String)mat;
|
||||
}
|
||||
else if (mat instanceof Integer)
|
||||
{
|
||||
addedMatList.add(new OreRecipeElement(lastString, (Integer)mat));
|
||||
}
|
||||
}
|
||||
OreRecipeElement[] addedMats = addedMatList.toArray(new OreRecipeElement[0]);
|
||||
|
||||
// First String(s) in args
|
||||
if (args[i] instanceof String[])
|
||||
{
|
||||
String[] astring = (String[])args[i];
|
||||
i++;
|
||||
|
||||
for (String s1 : astring)
|
||||
{
|
||||
height++;
|
||||
width = s1.length();
|
||||
totalRecipe += s1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (args[i] instanceof String)
|
||||
{
|
||||
String s2 = (String)args[i];
|
||||
i++;
|
||||
height++;
|
||||
width = s2.length();
|
||||
totalRecipe += s2;
|
||||
}
|
||||
}
|
||||
|
||||
HashMap hashmap = new HashMap();
|
||||
|
||||
for (; i < args.length; i += 2)
|
||||
{
|
||||
Character character = (Character)args[i];
|
||||
OreRecipeElement stackInRecipe = null;
|
||||
|
||||
if (args[i + 1] instanceof Item)
|
||||
{
|
||||
stackInRecipe = new OreRecipeElement(new ItemStack((Item)args[i + 1], 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
else if (args[i + 1] instanceof Block)
|
||||
{
|
||||
stackInRecipe = new OreRecipeElement(
|
||||
new ItemStack((Block)args[i + 1], 1, OreDictionary.WILDCARD_VALUE));
|
||||
}
|
||||
else if (args[i + 1] instanceof ItemStack)
|
||||
{
|
||||
stackInRecipe = new OreRecipeElement((ItemStack)args[i + 1]);
|
||||
}
|
||||
else if (args[i + 1] instanceof String)
|
||||
{
|
||||
stackInRecipe = new OreRecipeElement((String)args[i + 1], 1);
|
||||
}
|
||||
|
||||
hashmap.put(character, stackInRecipe);
|
||||
}
|
||||
|
||||
OreRecipeElement[] neededItems = new OreRecipeElement[width * height];
|
||||
|
||||
for (int j = 0; j < width * height; ++j)
|
||||
{
|
||||
char iterChar = totalRecipe.charAt(j);
|
||||
|
||||
if (hashmap.containsKey(Character.valueOf(iterChar)))
|
||||
{
|
||||
neededItems[j] = ((OreRecipeElement)hashmap.get(Character.valueOf(iterChar))).copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
neededItems[j] = null;
|
||||
}
|
||||
}
|
||||
|
||||
AdvancedRecipe advancedrecipes = new AdvancedRecipe(width, height, neededItems, result, addedMats);
|
||||
recipes.add(advancedrecipes);
|
||||
return advancedrecipes;
|
||||
}
|
||||
|
||||
public static AdvancedCraftingHandler crafting()
|
||||
{
|
||||
return CRAFTING;
|
||||
}
|
||||
|
||||
public static AdvancedRecipe AdvancedRecipeByResult(ItemStack result)
|
||||
{
|
||||
for (Object obj : crafting().recipes)
|
||||
{
|
||||
if (obj instanceof AdvancedRecipe)
|
||||
{
|
||||
AdvancedRecipe recipe = (AdvancedRecipe)obj;
|
||||
|
||||
if (recipe.getRecipeOutput().getItem() == result.getItem())
|
||||
{
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasRecipe(InventoryCrafting crafting, World world)
|
||||
{
|
||||
int i = 0;
|
||||
ItemStack itemstack = null;
|
||||
ItemStack itemstack1 = null;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < crafting.getSizeInventory(); ++j)
|
||||
{
|
||||
ItemStack itemstack2 = crafting.getStackInSlot(j);
|
||||
|
||||
if (itemstack2 != null)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
itemstack = itemstack2;
|
||||
}
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
itemstack1 = itemstack2;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < recipes.size(); ++j)
|
||||
{
|
||||
AdvancedRecipe advrecipe = recipes.get(j);
|
||||
|
||||
if (advrecipe.matchesMostly(crafting, world))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack findMatchingRecipe(InventoryCrafting crafting, InventoryWorkbenchAdditionalMaterials materials,
|
||||
World world)
|
||||
{
|
||||
int i = 0;
|
||||
ItemStack itemstack = null;
|
||||
ItemStack itemstack1 = null;
|
||||
int j;
|
||||
|
||||
for (j = 0; j < crafting.getSizeInventory(); ++j)
|
||||
{
|
||||
ItemStack itemstack2 = crafting.getStackInSlot(j);
|
||||
|
||||
if (itemstack2 != null)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
itemstack = itemstack2;
|
||||
}
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
itemstack1 = itemstack2;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 &&
|
||||
itemstack1.stackSize == 1 && itemstack.getItem().isRepairable())
|
||||
{
|
||||
Item item = itemstack.getItem();
|
||||
int j1 = item.getMaxDamage() - itemstack.getItemDamage();
|
||||
int k = item.getMaxDamage() - itemstack1.getItemDamage();
|
||||
int l = j1 + k + item.getMaxDamage() * 5 / 100;
|
||||
int i1 = item.getMaxDamage() - l;
|
||||
|
||||
if (i1 < 0)
|
||||
{
|
||||
i1 = 0;
|
||||
}
|
||||
|
||||
return new ItemStack(itemstack.getItem(), 1, i1);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < recipes.size(); ++j)
|
||||
{
|
||||
AdvancedRecipe advrecipe = recipes.get(j);
|
||||
|
||||
if (advrecipe.matches(crafting, materials, world))
|
||||
{
|
||||
return advrecipe.getCraftingResult(crafting);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAddedMaterial(ItemStack stack)
|
||||
{
|
||||
for (Object obj : recipes)
|
||||
{
|
||||
if (obj instanceof AdvancedRecipe)
|
||||
{
|
||||
AdvancedRecipe recipe = (AdvancedRecipe)obj;
|
||||
|
||||
if (recipe.hasMaterial(stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,268 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.inventory.InventoryWorkbenchAdditionalMaterials;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AdvancedRecipe
|
||||
{
|
||||
/**
|
||||
* How many horizontal slots this recipe is wide.
|
||||
*/
|
||||
public final int recipeWidth;
|
||||
/**
|
||||
* How many vertical slots this recipe uses.
|
||||
*/
|
||||
public final int recipeHeight;
|
||||
/**
|
||||
* Is a array of ItemStack that composes the recipe.
|
||||
*/
|
||||
public final OreRecipeElement[] recipeItems;
|
||||
/**
|
||||
* Is the ItemStack that you get when craft the recipe.
|
||||
*/
|
||||
private ItemStack recipeOutput;
|
||||
|
||||
// additional materials in the side slots
|
||||
private OreRecipeElement[] addedMaterials;
|
||||
|
||||
// ...something...
|
||||
private boolean strangeFlag;
|
||||
|
||||
public AdvancedRecipe(int width, int height, OreRecipeElement[] items, ItemStack output,
|
||||
OreRecipeElement[] materials)
|
||||
{
|
||||
recipeWidth = width;
|
||||
recipeHeight = height;
|
||||
recipeItems = items;
|
||||
recipeOutput = output;
|
||||
addedMaterials = materials;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public boolean matches(InventoryCrafting invCrafting, InventoryWorkbenchAdditionalMaterials materials,
|
||||
World world)
|
||||
{
|
||||
for (int i = 0; i <= 3 - recipeWidth; ++i)
|
||||
{
|
||||
for (int j = 0; j <= 3 - recipeHeight; ++j)
|
||||
{
|
||||
if (checkMatch(invCrafting, materials, i, j, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkMatch(invCrafting, materials, i, j, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Not sure what that fourth flag is...
|
||||
private boolean checkMatch(InventoryCrafting crafting, InventoryWorkbenchAdditionalMaterials materials, int width,
|
||||
int height, boolean flag4)
|
||||
{
|
||||
for (int k = 0; k < 3; ++k)
|
||||
{
|
||||
for (int l = 0; l < 3; ++l)
|
||||
{
|
||||
int i1 = k - width;
|
||||
int j1 = l - height;
|
||||
OreRecipeElement neededCraftingStack = null;
|
||||
|
||||
if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight)
|
||||
{
|
||||
if (flag4)
|
||||
{
|
||||
neededCraftingStack = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth];
|
||||
}
|
||||
else
|
||||
{
|
||||
neededCraftingStack = recipeItems[i1 + j1 * recipeWidth];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack craftingStackInQuestion = crafting.getStackInRowAndColumn(k, l);
|
||||
|
||||
if (craftingStackInQuestion != null || neededCraftingStack != null)
|
||||
{
|
||||
if (craftingStackInQuestion == null && neededCraftingStack != null ||
|
||||
craftingStackInQuestion != null && neededCraftingStack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!neededCraftingStack.matches(craftingStackInQuestion))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (OreRecipeElement requiredMatStack : addedMaterials)
|
||||
{
|
||||
boolean foundIt = false;
|
||||
for (int i2 = 0; i2 < materials.getSizeInventory(); ++i2)
|
||||
{
|
||||
ItemStack testedMatStack = materials.getStackInSlot(i2);
|
||||
if (testedMatStack != null)
|
||||
{
|
||||
foundIt = requiredMatStack.matchesCheckSize(testedMatStack);
|
||||
}
|
||||
|
||||
if (foundIt)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundIt)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean matchesMostly(InventoryCrafting invCrafting, World world)
|
||||
{
|
||||
for (int i = 0; i <= 3 - recipeWidth; ++i)
|
||||
{
|
||||
for (int j = 0; j <= 3 - recipeHeight; ++j)
|
||||
{
|
||||
if (checkMatchMostly(invCrafting, i, j, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkMatchMostly(invCrafting, i, j, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkMatchMostly(InventoryCrafting crafting, int width, int height, boolean flag4)
|
||||
{
|
||||
for (int k = 0; k < 3; ++k)
|
||||
{
|
||||
for (int l = 0; l < 3; ++l)
|
||||
{
|
||||
int i1 = k - width;
|
||||
int j1 = l - height;
|
||||
OreRecipeElement neededCraftingStack = null;
|
||||
|
||||
if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight)
|
||||
{
|
||||
if (flag4)
|
||||
{
|
||||
neededCraftingStack = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth];
|
||||
}
|
||||
else
|
||||
{
|
||||
neededCraftingStack = recipeItems[i1 + j1 * recipeWidth];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack craftingStackInQuestion = crafting.getStackInRowAndColumn(k, l);
|
||||
|
||||
if (craftingStackInQuestion != null || neededCraftingStack != null)
|
||||
{
|
||||
// If one is null but not the other
|
||||
if (craftingStackInQuestion == null || neededCraftingStack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!neededCraftingStack.matches(craftingStackInQuestion))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getNeededMaterialCount(Item material)
|
||||
{
|
||||
for (OreRecipeElement stack : addedMaterials)
|
||||
{
|
||||
if (stack.matches(new ItemStack(material)))
|
||||
{
|
||||
return stack.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public OreRecipeElement[] getNeededMaterials()
|
||||
{
|
||||
return addedMaterials;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting crafting)
|
||||
{
|
||||
ItemStack itemstack = getRecipeOutput().copy();
|
||||
|
||||
if (strangeFlag)
|
||||
{
|
||||
for (int i = 0; i < crafting.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack1 = crafting.getStackInSlot(i);
|
||||
|
||||
if (itemstack1 != null && itemstack1.hasTagCompound())
|
||||
{
|
||||
itemstack.setTagCompound((NBTTagCompound)itemstack1.getTagCompound().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return recipeOutput;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return recipeWidth * recipeHeight;
|
||||
}
|
||||
|
||||
public AdvancedRecipe func_92100_c()
|
||||
{
|
||||
strangeFlag = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasMaterial(ItemStack stack)
|
||||
{
|
||||
for (OreRecipeElement s : addedMaterials)
|
||||
{
|
||||
if (s.matches(stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class BrickOvenRecipeHandler
|
||||
{
|
||||
private static final BrickOvenRecipeHandler INSTANCE = new BrickOvenRecipeHandler();
|
||||
protected List<IBrickOvenRecipe> recipes = new ArrayList<IBrickOvenRecipe>();
|
||||
|
||||
// private Map experienceList;
|
||||
|
||||
public BrickOvenRecipeHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void addShapedRecipe(ItemStack output, Object... args)
|
||||
{
|
||||
instance().putShapedRecipe(output, args);
|
||||
}
|
||||
|
||||
public BrickOvenShapedRecipe putShapedRecipe(ItemStack result, Object... args)
|
||||
{
|
||||
String s = "";
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
|
||||
if (args[i] instanceof String[])
|
||||
{
|
||||
String[] astring = (String[])args[i++];
|
||||
|
||||
for (int l = 0; l < astring.length; ++l)
|
||||
{
|
||||
String s1 = astring[l];
|
||||
++k;
|
||||
j = s1.length();
|
||||
s = s + s1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (args[i] instanceof String)
|
||||
{
|
||||
String s2 = (String)args[i++];
|
||||
++k;
|
||||
j = s2.length();
|
||||
s = s + s2;
|
||||
}
|
||||
}
|
||||
|
||||
HashMap hashmap;
|
||||
|
||||
for (hashmap = new HashMap(); i < args.length; i += 2)
|
||||
{
|
||||
Character character = (Character)args[i];
|
||||
ItemStack itemstack1 = null;
|
||||
|
||||
if (args[i + 1] instanceof Item)
|
||||
{
|
||||
itemstack1 = new ItemStack((Item)args[i + 1]);
|
||||
}
|
||||
else if (args[i + 1] instanceof Block)
|
||||
{
|
||||
itemstack1 = new ItemStack((Block)args[i + 1], 1, OreDictionary.WILDCARD_VALUE);
|
||||
}
|
||||
else if (args[i + 1] instanceof ItemStack)
|
||||
{
|
||||
itemstack1 = (ItemStack)args[i + 1];
|
||||
}
|
||||
|
||||
hashmap.put(character, itemstack1);
|
||||
}
|
||||
|
||||
ItemStack[] aitemstack = new ItemStack[j * k];
|
||||
|
||||
for (int i1 = 0; i1 < j * k; ++i1)
|
||||
{
|
||||
char c0 = s.charAt(i1);
|
||||
|
||||
if (hashmap.containsKey(Character.valueOf(c0)))
|
||||
{
|
||||
aitemstack[i1] = ((ItemStack)hashmap.get(Character.valueOf(c0))).copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
aitemstack[i1] = null;
|
||||
}
|
||||
}
|
||||
|
||||
BrickOvenShapedRecipe ovenrecipe = new BrickOvenShapedRecipe(j, k, aitemstack, result);
|
||||
recipes.add(ovenrecipe);
|
||||
return ovenrecipe;
|
||||
}
|
||||
|
||||
public static BrickOvenRecipeHandler instance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static void addShapelessRecipe(ItemStack output, Object... args)
|
||||
{
|
||||
instance().putShapelessRecipe(output, args);
|
||||
}
|
||||
|
||||
public BrickOvenShapelessRecipe putShapelessRecipe(ItemStack output, Object... args)
|
||||
{
|
||||
ArrayList arraylist = new ArrayList();
|
||||
Object[] aobject = args;
|
||||
int i = args.length;
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
Object object1 = aobject[j];
|
||||
|
||||
if (object1 instanceof ItemStack)
|
||||
{
|
||||
arraylist.add(((ItemStack)object1).copy());
|
||||
}
|
||||
else if (object1 instanceof Item)
|
||||
{
|
||||
arraylist.add(new ItemStack((Item)object1));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(object1 instanceof Block))
|
||||
{
|
||||
throw new RuntimeException("Invalid shapeless recipe!");
|
||||
}
|
||||
|
||||
arraylist.add(new ItemStack((Block)object1));
|
||||
}
|
||||
}
|
||||
|
||||
BrickOvenShapelessRecipe recipe = new BrickOvenShapelessRecipe(output, arraylist);
|
||||
recipes.add(recipe);
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void addLists(ItemStack output, Object... args)
|
||||
{
|
||||
// putLists(output, args);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void putLists(ItemStack output, Object... args)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ItemStack findMatchingRecipe(TileEntityBrickOven oven)
|
||||
{
|
||||
int i = 0;
|
||||
ItemStack itemstack = null;
|
||||
ItemStack itemstack1 = null;
|
||||
int j;
|
||||
|
||||
for (j = TileEntityBrickOven.INPUTSTART; j < oven.getSizeInventory(); ++j)
|
||||
{
|
||||
ItemStack itemstack2 = oven.getStackInSlot(j);
|
||||
// System.out.println("\nBrickOvenRecipeHandler.findMatchingRecipe(): j = " + j);
|
||||
|
||||
if (itemstack2 != null)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
itemstack = itemstack2;
|
||||
}
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
itemstack1 = itemstack2;
|
||||
}
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
for (IBrickOvenRecipe recipe : recipes)
|
||||
{
|
||||
// IBrickOvenRecipe recipe = (IBrickOvenRecipe)recipes.get(j);
|
||||
|
||||
if (recipe.matches(oven))
|
||||
{
|
||||
return recipe.getCraftingResult(oven);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isInRecipe(ItemStack stack)
|
||||
{
|
||||
for (IBrickOvenRecipe recipe : recipes)
|
||||
{
|
||||
if (recipe.contains(stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List getRecipeList()
|
||||
{
|
||||
return recipes;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,261 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class BrickOvenShapedRecipe implements IBrickOvenRecipe
|
||||
{
|
||||
/**
|
||||
* How many horizontal slots this recipe is wide.
|
||||
*/
|
||||
public final int recipeWidth;
|
||||
/**
|
||||
* How many vertical slots this recipe uses.
|
||||
*/
|
||||
public final int recipeHeight;
|
||||
/**
|
||||
* Is a array of ItemStack that composes the recipe.
|
||||
*/
|
||||
public final ItemStack[] recipeItems;
|
||||
/**
|
||||
* Is the ItemStack that you get when craft the recipe.
|
||||
*/
|
||||
private ItemStack recipeOutput;
|
||||
private boolean strangeField;
|
||||
|
||||
public BrickOvenShapedRecipe(int width, int height, ItemStack[] input, ItemStack output)
|
||||
{
|
||||
recipeWidth = width;
|
||||
recipeHeight = height;
|
||||
recipeItems = input;
|
||||
recipeOutput = output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
@Override
|
||||
public boolean matches(TileEntityBrickOven oven)
|
||||
{
|
||||
for (int i = 0; i <= 3 - recipeWidth; ++i)
|
||||
{
|
||||
for (int j = 0; j <= 3 - recipeHeight; ++j)
|
||||
{
|
||||
if (checkMatch(oven, i, j, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkMatch(oven, i, j, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(TileEntityNetherBrickOven oven)
|
||||
{
|
||||
for (int i = 0; i <= 3 - recipeWidth; ++i)
|
||||
{
|
||||
for (int j = 0; j <= 3 - recipeHeight; ++j)
|
||||
{
|
||||
if (checkMatch(oven, i, j, true))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (checkMatch(oven, i, j, false))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkMatch(TileEntityNetherBrickOven oven, int width, int height, boolean flag4)
|
||||
{
|
||||
for (int k = 0; k < 3; ++k)
|
||||
{
|
||||
for (int l = 0; l < 3; ++l)
|
||||
{
|
||||
int i1 = k - width;
|
||||
int j1 = l - height;
|
||||
ItemStack itemstack = null;
|
||||
|
||||
if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight)
|
||||
{
|
||||
if (flag4)
|
||||
{
|
||||
itemstack = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth];
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = recipeItems[i1 + j1 * recipeWidth];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemstack1 = oven.getStackInRowAndColumn(k, l);
|
||||
|
||||
if (itemstack1 != null || itemstack != null)
|
||||
{
|
||||
if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemstack.getItem() != itemstack1.getItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemstack.getItemDamage() != OreDictionary.WILDCARD_VALUE &&
|
||||
itemstack.getItemDamage() != itemstack1.getItemDamage())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getCraftingResult(TileEntityBrickOven oven)
|
||||
{
|
||||
ItemStack itemstack = getRecipeOutput().copy();
|
||||
|
||||
if (strangeField)
|
||||
{
|
||||
for (int i = 0; i < oven.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack1 = oven.getStackInSlot(i);
|
||||
|
||||
if (itemstack1 != null && itemstack1.hasTagCompound())
|
||||
{
|
||||
itemstack.setTagCompound((NBTTagCompound)itemstack1.getTagCompound().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(TileEntityNetherBrickOven oven)
|
||||
{
|
||||
ItemStack itemstack = getRecipeOutput().copy();
|
||||
|
||||
if (strangeField)
|
||||
{
|
||||
for (int i = 0; i < oven.getSizeInventory(); ++i)
|
||||
{
|
||||
ItemStack itemstack1 = oven.getStackInSlot(i);
|
||||
|
||||
if (itemstack1 != null && itemstack1.hasTagCompound())
|
||||
{
|
||||
itemstack.setTagCompound((NBTTagCompound)itemstack1.getTagCompound().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return recipeWidth * recipeHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ItemStack stack)
|
||||
{
|
||||
for (ItemStack s : recipeItems)
|
||||
{
|
||||
if (s.getItem() == stack.getItem())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return recipeOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the region of a crafting inventory is match for the recipe.
|
||||
*/
|
||||
private boolean checkMatch(TileEntityBrickOven oven, int width, int height, boolean flag4)
|
||||
{
|
||||
for (int k = 0; k < 3; ++k)
|
||||
{
|
||||
for (int l = 0; l < 3; ++l)
|
||||
{
|
||||
int i1 = k - width;
|
||||
int j1 = l - height;
|
||||
ItemStack itemstack = null;
|
||||
|
||||
if (i1 >= 0 && j1 >= 0 && i1 < recipeWidth && j1 < recipeHeight)
|
||||
{
|
||||
if (flag4)
|
||||
{
|
||||
itemstack = recipeItems[recipeWidth - i1 - 1 + j1 * recipeWidth];
|
||||
}
|
||||
else
|
||||
{
|
||||
itemstack = recipeItems[i1 + j1 * recipeWidth];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack itemstack1 = oven.getStackInRowAndColumn(k, l);
|
||||
|
||||
if (itemstack1 != null || itemstack != null)
|
||||
{
|
||||
if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemstack.getItem() != itemstack1.getItem())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (itemstack.getItemDamage() != OreDictionary.WILDCARD_VALUE &&
|
||||
itemstack.getItemDamage() != itemstack1.getItemDamage())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public BrickOvenShapedRecipe func_92100_c()
|
||||
{
|
||||
strangeField = true;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class BrickOvenShapelessRecipe implements IBrickOvenRecipe
|
||||
{
|
||||
/**
|
||||
* Is a List of ItemStack that composes the recipe.
|
||||
*/
|
||||
public final List<ItemStack> recipeItems;
|
||||
/**
|
||||
* Is the ItemStack that you get when craft the recipe.
|
||||
*/
|
||||
private final ItemStack recipeOutput;
|
||||
|
||||
public BrickOvenShapelessRecipe(ItemStack output, List<ItemStack> input)
|
||||
{
|
||||
recipeOutput = output;
|
||||
recipeItems = input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
@Override
|
||||
public boolean matches(TileEntityBrickOven oven)
|
||||
{
|
||||
ArrayList<ItemStack> arraylist = new ArrayList<ItemStack>(recipeItems);
|
||||
|
||||
for (int col = 0; col < 3; ++col)
|
||||
{
|
||||
for (int row = 0; row < 3; ++row)
|
||||
{
|
||||
ItemStack itemstack = oven.getStackInRowAndColumn(row, col);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
boolean flag = false;
|
||||
Iterator iterator = arraylist.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ItemStack itemstack1 = (ItemStack)iterator.next();
|
||||
|
||||
if (itemstack.getItem() == itemstack1.getItem() &&
|
||||
(itemstack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemstack
|
||||
.getItemDamage() == itemstack1
|
||||
.getItemDamage()))
|
||||
{
|
||||
flag = true;
|
||||
arraylist.remove(itemstack1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arraylist.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(TileEntityNetherBrickOven oven)
|
||||
{
|
||||
ArrayList<ItemStack> arraylist = new ArrayList<ItemStack>(recipeItems);
|
||||
|
||||
for (int col = 0; col < 3; ++col)
|
||||
{
|
||||
for (int row = 0; row < 3; ++row)
|
||||
{
|
||||
ItemStack itemstack = oven.getStackInRowAndColumn(row, col);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
boolean flag = false;
|
||||
Iterator iterator = arraylist.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
ItemStack itemstack1 = (ItemStack)iterator.next();
|
||||
|
||||
if (itemstack.getItem() == itemstack1.getItem() &&
|
||||
(itemstack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemstack
|
||||
.getItemDamage() == itemstack1
|
||||
.getItemDamage()))
|
||||
{
|
||||
flag = true;
|
||||
arraylist.remove(itemstack1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arraylist.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
@Override
|
||||
public ItemStack getCraftingResult(TileEntityBrickOven oven)
|
||||
{
|
||||
return recipeOutput.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(TileEntityNetherBrickOven oven)
|
||||
{
|
||||
return recipeOutput.copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
{
|
||||
return recipeItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ItemStack stack)
|
||||
{
|
||||
for (ItemStack s : recipeItems)
|
||||
{
|
||||
if (s.getItem() == stack.getItem())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return recipeOutput;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class CampfirePanRecipes
|
||||
{
|
||||
private static final CampfirePanRecipes SMELTINGBASE = new CampfirePanRecipes();
|
||||
|
||||
private Map smeltingList = new HashMap();
|
||||
private Map experienceList = new HashMap();
|
||||
|
||||
private CampfirePanRecipes()
|
||||
{
|
||||
// nothing here
|
||||
}
|
||||
|
||||
public static void addRecipe(Item input, ItemStack output, float experience)
|
||||
{
|
||||
smelting().addLists(input, output, experience);
|
||||
}
|
||||
|
||||
public void addLists(Item input, ItemStack itemStack, float experience)
|
||||
{
|
||||
putLists(new ItemStack(input, 1, OreDictionary.WILDCARD_VALUE), itemStack, experience);
|
||||
}
|
||||
|
||||
public static CampfirePanRecipes smelting()
|
||||
{
|
||||
return SMELTINGBASE;
|
||||
}
|
||||
|
||||
public void putLists(ItemStack itemStack, ItemStack itemStack2, float experience)
|
||||
{
|
||||
smeltingList.put(itemStack, itemStack2);
|
||||
experienceList.put(itemStack2, Float.valueOf(experience));
|
||||
}
|
||||
|
||||
public static void addRecipe(Block input, ItemStack output, float experience)
|
||||
{
|
||||
smelting().addLists(Item.getItemFromBlock(input), output, experience);
|
||||
}
|
||||
|
||||
public static void addRecipe(ItemStack input, ItemStack output, float experience)
|
||||
{
|
||||
smelting().putLists(input, output, experience);
|
||||
}
|
||||
|
||||
public ItemStack getSmeltingResult(ItemStack stack)
|
||||
{
|
||||
Iterator iterator = smeltingList.entrySet().iterator();
|
||||
Entry entry;
|
||||
|
||||
do
|
||||
{
|
||||
if (!iterator.hasNext())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
entry = (Entry)iterator.next();
|
||||
} while (!canBeSmelted(stack, (ItemStack)entry.getKey()));
|
||||
|
||||
return (ItemStack)entry.getValue();
|
||||
}
|
||||
|
||||
private boolean canBeSmelted(ItemStack stack, ItemStack stack2)
|
||||
{
|
||||
return stack2.getItem() == stack.getItem()
|
||||
&& (stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE || stack2.getItemDamage() == stack
|
||||
.getItemDamage());
|
||||
}
|
||||
|
||||
public float giveExperience(ItemStack stack)
|
||||
{
|
||||
Iterator iterator = experienceList.entrySet().iterator();
|
||||
Entry entry;
|
||||
|
||||
do
|
||||
{
|
||||
if (!iterator.hasNext())
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
entry = (Entry)iterator.next();
|
||||
} while (!canBeSmelted(stack, (ItemStack)entry.getKey()));
|
||||
|
||||
if (stack.getItem().getSmeltingExperience(stack) != -1)
|
||||
{
|
||||
return stack.getItem().getSmeltingExperience(stack);
|
||||
}
|
||||
|
||||
return (Float)entry.getValue();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class CampfireRecipes
|
||||
{
|
||||
private static final CampfireRecipes SMELTINGBASE = new CampfireRecipes();
|
||||
|
||||
private Map smeltingList = new HashMap();
|
||||
private Map experienceList = new HashMap();
|
||||
|
||||
private CampfireRecipes()
|
||||
{
|
||||
// nothing here
|
||||
}
|
||||
|
||||
public static void addRecipe(Item input, ItemStack output, float experience)
|
||||
{
|
||||
smelting().addLists(input, output, experience);
|
||||
}
|
||||
|
||||
public void addLists(Item input, ItemStack itemStack, float experience)
|
||||
{
|
||||
putLists(new ItemStack(input, 1, OreDictionary.WILDCARD_VALUE), itemStack, experience);
|
||||
}
|
||||
|
||||
public static CampfireRecipes smelting()
|
||||
{
|
||||
return SMELTINGBASE;
|
||||
}
|
||||
|
||||
public void putLists(ItemStack itemStack, ItemStack itemStack2, float experience)
|
||||
{
|
||||
smeltingList.put(itemStack, itemStack2);
|
||||
experienceList.put(itemStack2, experience);
|
||||
}
|
||||
|
||||
public static void addRecipe(Block input, ItemStack output, float experience)
|
||||
{
|
||||
smelting().addLists(Item.getItemFromBlock(input), output, experience);
|
||||
}
|
||||
|
||||
public static void addRecipe(ItemStack input, ItemStack output, float experience)
|
||||
{
|
||||
smelting().putLists(input, output, experience);
|
||||
}
|
||||
|
||||
public ItemStack getSmeltingResult(ItemStack stack)
|
||||
{
|
||||
Iterator iterator = smeltingList.entrySet().iterator();
|
||||
Entry entry;
|
||||
|
||||
do
|
||||
{
|
||||
if (!iterator.hasNext())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
entry = (Entry)iterator.next();
|
||||
} while (!canBeSmelted(stack, (ItemStack)entry.getKey()));
|
||||
|
||||
return (ItemStack)entry.getValue();
|
||||
}
|
||||
|
||||
private boolean canBeSmelted(ItemStack stack, ItemStack stack2)
|
||||
{
|
||||
return stack2.getItem() == stack.getItem()
|
||||
&& (stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE || stack2.getItemDamage() == stack
|
||||
.getItemDamage());
|
||||
}
|
||||
|
||||
public float giveExperience(ItemStack stack)
|
||||
{
|
||||
Iterator iterator = experienceList.entrySet().iterator();
|
||||
Entry entry;
|
||||
|
||||
do
|
||||
{
|
||||
if (!iterator.hasNext())
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
entry = (Entry)iterator.next();
|
||||
} while (!canBeSmelted(stack, (ItemStack)entry.getKey()));
|
||||
|
||||
if (stack.getItem().getSmeltingExperience(stack) != -1)
|
||||
{
|
||||
return stack.getItem().getSmeltingExperience(stack);
|
||||
}
|
||||
|
||||
return ((Float)entry.getValue()).floatValue();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package net.einsteinsci.betterbeginnings.register.recipe;
|
||||
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityBrickOven;
|
||||
import net.einsteinsci.betterbeginnings.tileentity.TileEntityNetherBrickOven;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IBrickOvenRecipe
|
||||
{
|
||||
/**
|
||||
* Used to check if a recipe matches current crafting inventory
|
||||
*/
|
||||
boolean matches(TileEntityBrickOven inv);
|
||||
|
||||
boolean matches(TileEntityNetherBrickOven inv);
|
||||
|
||||
/**
|
||||
* Returns an Item that is the result of this recipe
|
||||
*/
|
||||
ItemStack getCraftingResult(TileEntityBrickOven inv);
|
||||
|
||||
ItemStack getCraftingResult(TileEntityNetherBrickOven inv);
|
||||
|
||||
/**
|
||||
* Returns the size of the recipe area
|
||||
*/
|
||||
int getRecipeSize();
|
||||
|
||||
boolean contains(ItemStack stack);
|
||||
|
||||
ItemStack getRecipeOutput();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue