This commit is contained in:
Taylor Shuler 2014-08-01 11:13:29 +00:00
commit e467ac38e3
14 changed files with 515 additions and 592 deletions

11
.gitattributes vendored Normal file
View File

@ -0,0 +1,11 @@
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
# Explicitly declare text files we want to always be normalized and converted to native line endings on checkout.
*.md text
*.info text
*.txt text
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

23
.gitignore vendored
View File

@ -1,14 +1,19 @@
build/ # Ignore Gradle cache files & directories
.classpath
.project
.gradle/
eclipse/
bin/ bin/
repo/ build/
/run/ ## Eclipse
eclipse/
.classpath
.gradle/
.project
.settings/ .settings/
#IDEA files from Gradle ## Idea
.idea/ .idea
/*.iml /*.iml
/*.ipr /*.ipr
/*.iws /*.iws
# Ignore OS cache files & directories
*.DS_Store
_MACOSX
Thumbs.db

View File

@ -1,196 +1,195 @@
// This sets us up for building a forge project - you need all of these // This sets us up for building a forge project - you need all of these
buildscript { buildscript {
repositories { repositories {
mavenCentral() mavenCentral()
maven { maven {
name = "forge" name = "forge"
url = "http://files.minecraftforge.net/maven" url = "http://files.minecraftforge.net/maven"
} }
maven { maven {
name = "sonatype" name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/" url = "https://oss.sonatype.org/content/repositories/snapshots/"
} }
} }
dependencies { dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
} }
} }
// Apply the forge plugin - this adds all the magic for automatically obfuscating, deobfuscating etc // Apply the forge plugin - this adds all the magic for automatically obfuscating, deobfuscating etc
apply plugin: 'forge' apply plugin: 'forge'
// This is a simple flatdir repository for "uploadArchives" when you don't have a remote repo to target // This is a simple flatdir repository for "uploadArchives" when you don't have a remote repo to target
repositories { repositories {
flatDir { flatDir {
name "fileRepo" name "fileRepo"
dirs "repo" dirs "repo"
} }
} }
// IronChest uses git tagging to mark major versions. This sets up the project version to that version data
def versionInfo = getGitVersion() // IronChest uses git tagging to mark major versions. This sets up the project version to that version data
version = "${versionInfo['IronChest.version']}" def versionInfo = getGitVersion()
version = "${versionInfo['IronChest.version']}"
// This is our group. I'm cpw.mods
group= "cpw.mods" // http://maven.apache.org/guides/mini/guide-naming-conventions.html // This is our group. I'm cpw.mods
// This is our actual project within the group. Note: FML has "fml" here. But this is ironchest. group= "cpw.mods" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ironchest" // This is our actual project within the group. Note: FML has "fml" here. But this is ironchest.
archivesBaseName = "ironchest"
// Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here
minecraft { // Setup the forge minecraft plugin data. Specify the preferred forge/minecraft version here
version = "1.7.10-10.13.0.1150" minecraft {
} version = "1.7.10-10.13.0.1150"
runDir = "eclipse/assets"
// This wrangles the resources for the jar files- stuff like textures and languages }
processResources
{ // This wrangles the resources for the jar files- stuff like textures and languages
// we're omitting the .xcf files - they're development only processResources {
exclude '**/*.xcf' // we're omitting the .xcf files - they're development only
// we only want to do search/replace stuff in mcmod.info, nothing else exclude '**/*.xcf'
from(sourceSets.main.resources.srcDirs) { // we only want to do search/replace stuff in mcmod.info, nothing else
include 'mcmod.info' from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version // 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) { // copy everything else, thats not the mcmod.info
exclude 'mcmod.info' from(sourceSets.main.resources.srcDirs) {
} exclude 'mcmod.info'
}
// generate version.properties file from the git version data earlier
doLast { // generate version.properties file from the git version data earlier
def propsFile = new File(destinationDir, 'version.properties') doLast {
def properties = new Properties() def propsFile = new File(destinationDir, 'version.properties')
properties.putAll(versionInfo) def properties = new Properties()
properties['IronChest.build.mcversion'] = project.minecraft.version properties.putAll(versionInfo)
properties.store(propsFile.newWriter(), null) properties['IronChest.build.mcversion'] = project.minecraft.version
} properties.store(propsFile.newWriter(), null)
} }
}
// this sets our output jar to have a 'tag' of 'universal' on it
// It also adds the minecraft version in a custom version name // this sets our output jar to have a 'tag' of 'universal' on it
// The result is files named <projectname>-<mcversion>-<version>-universal.jar // It also adds the minecraft version in a custom version name
jar { // The result is files named <projectname>-<mcversion>-<version>-universal.jar
classifier = 'universal' jar {
version = "${project.minecraft.version}-${project.version}" classifier = 'universal'
version = "${project.minecraft.version}-${project.version}"
} }
println "FISHBUM ${jar.version}" println "FISHBUM ${jar.version}"
// Add in a source jar for people, should they desire to download such a thing // Add in a source jar for people, should they desire to download such a thing
task sourceJar(type: Jar) { task sourceJar(type: Jar) {
from sourceSets.main.allSource from sourceSets.main.allSource
classifier = 'src' classifier = 'src'
version = "${project.minecraft.version}-${project.version}" version = "${project.minecraft.version}-${project.version}"
} }
// Add in an mcp named jar, for those who wish to run in a development environment (assuming mcp naming matches) // Add in an mcp named jar, for those who wish to run in a development environment (assuming mcp naming matches)
task deobfJar(type: Jar) { task deobfJar(type: Jar) {
from sourceSets.main.output from sourceSets.main.output
classifier = 'deobf' classifier = 'deobf'
version = "${project.minecraft.version}-${project.version}" version = "${project.minecraft.version}-${project.version}"
} }
// Tell the artifact system about our extra jars // Tell the artifact system about our extra jars
artifacts { artifacts {
archives sourceJar, deobfJar archives sourceJar, deobfJar
} }
// Configure an upload task. this is setup for uploading to files.minecraftforge.net. There are other examples around // Configure an upload task. this is setup for uploading to files.minecraftforge.net. There are other examples around
uploadArchives { uploadArchives {
dependsOn 'reobf' dependsOn 'reobf'
repositories { repositories {
if (project.hasProperty("filesmaven")) { if (project.hasProperty("filesmaven")) {
logger.info('Publishing to files server') logger.info('Publishing to files server')
mavenDeployer { mavenDeployer {
configuration = configurations.deployJars configuration = configurations.deployJars
repository(url: project.filesmaven.url) { repository(url: project.filesmaven.url) {
authentication(userName: project.filesmaven.username, privateKey: project.filesmaven.key) authentication(userName: project.filesmaven.username, privateKey: project.filesmaven.key)
} }
// This is just the pom data for the maven repo // This is just the pom data for the maven repo
pom { pom {
groupId = project.group groupId = project.group
// Force the maven upload to use the <mcversion>-<version> syntax preferred at files // Force the maven upload to use the <mcversion>-<version> syntax preferred at files
version = "${project.minecraft.version}-${project.version}" version = "${project.minecraft.version}-${project.version}"
artifactId = project.archivesBaseName artifactId = project.archivesBaseName
project { project {
name project.archivesBaseName name project.archivesBaseName
packaging 'jar' packaging 'jar'
description 'IronChest' description 'IronChest'
url 'https://github.com/cpw/IronChest' url 'https://github.com/cpw/IronChest'
scm { scm {
url 'https://github.com/progwml6/IronChest' url 'https://github.com/progwml6/IronChest'
connection 'scm:git:git://github.com/progwml6/IronChest.git' connection 'scm:git:git://github.com/progwml6/IronChest.git'
developerConnection 'scm:git:git@github.com:progwml6/IronChest.git' developerConnection 'scm:git:git@github.com:progwml6/IronChest.git'
} }
issueManagement { issueManagement {
system 'github' system 'github'
url 'https://github.com/progwml6/IronChest/issues' url 'https://github.com/progwml6/IronChest/issues'
} }
licenses { licenses {
license { license {
name 'GNU Public License (GPL), Version 3.0' name 'GNU Public License (GPL), Version 3.0'
url 'http://www.gnu.org/licenses/gpl-3.0.txt' url 'http://www.gnu.org/licenses/gpl-3.0.txt'
distribution 'repo' distribution 'repo'
} }
} }
developers { developers {
developer { developer {
id 'cpw' id 'cpw'
name 'cpw' name 'cpw'
roles { role 'developer' } roles { role 'developer' }
} }
} }
} }
} }
} }
} else { } else {
logger.info('Publishing to repo folder') logger.info('Publishing to repo folder')
mavenDeployer { mavenDeployer {
pom.version = "${project.minecraft.version}-${project.version}" pom.version = "${project.minecraft.version}-${project.version}"
repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath()) repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath())
} }
} }
} }
} }
// This is a special task for pulling the version information from git and the environment (for BUILD_NUMBER) // This is a special task for pulling the version information from git and the environment (for BUILD_NUMBER)
def getGitVersion() def getGitVersion() {
{ def out = [:]
def out = [:]
// call git command.
// call git command. def outStream = new ByteArrayOutputStream()
def outStream = new ByteArrayOutputStream() def result = exec {
def result = exec { executable = 'git'
executable = 'git' args = [ 'describe', '--long', "--match=[^(jenkins)]*"]
args = [ 'describe', '--long', "--match=[^(jenkins)]*"] standardOutput = outStream
standardOutput = outStream }
}
def fullVersion = outStream.toString().trim()
def fullVersion = outStream.toString().trim() def matcher = fullVersion =~ /(\d+).(\d+)-(\d+)-(.*)/
def matcher = fullVersion =~ /(\d+).(\d+)-(\d+)-(.*)/
def maj = matcher[0][1]
def maj = matcher[0][1] def min = matcher[0][2]
def min = matcher[0][2] def rev = matcher[0][3]
def rev = matcher[0][3] def bn = System.getenv("BUILD_NUMBER") ?: "1"
def bn = System.getenv("BUILD_NUMBER") ?: "1"
out['IronChest.build.major.number'] = maj.toString()
out['IronChest.build.major.number'] = maj.toString() out['IronChest.build.minor.number'] = min.toString()
out['IronChest.build.minor.number'] = min.toString() out['IronChest.build.revision.number'] = rev.toString()
out['IronChest.build.revision.number'] = rev.toString() out['IronChest.build.githash'] = matcher[0][4].toString()
out['IronChest.build.githash'] = matcher[0][4].toString() out['IronChest.build.number' ] = bn.toString()
out['IronChest.build.number' ] = bn.toString() out['IronChest.version' ] = "${maj}.${min}.${rev}.${bn}".toString()
out['IronChest.version' ] = "${maj}.${min}.${rev}.${bn}".toString()
return out
return out }
}

180
gradlew.bat vendored
View File

@ -1,90 +1,90 @@
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@rem @rem
@rem ########################################################################## @rem ##########################################################################
@rem Set local scope for the variables with windows NT shell @rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal 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. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS= set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto init
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:findJavaFromJavaHome :findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto init
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:init :init
@rem Get command-line arguments, handling Windowz variants @rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args :win9xME_args
@rem Slurp the command line arguments. @rem Slurp the command line arguments.
set CMD_LINE_ARGS= set CMD_LINE_ARGS=
set _SKIP=2 set _SKIP=2
:win9xME_args_slurp :win9xME_args_slurp
if "x%~1" == "x" goto execute if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%* set CMD_LINE_ARGS=%*
goto execute goto execute
:4NT_args :4NT_args
@rem Get arguments from the 4NT Shell from JP Software @rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$ set CMD_LINE_ARGS=%$
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if "%ERRORLEVEL%"=="0" goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1 exit /b 1
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal
:omega :omega

View File

@ -14,11 +14,10 @@ import static net.minecraftforge.common.util.ForgeDirection.DOWN;
import static net.minecraftforge.common.util.ForgeDirection.UP; import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import com.google.common.collect.Lists;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -27,6 +26,7 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
@ -34,20 +34,20 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import com.google.common.collect.Lists;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class BlockIronChest extends BlockContainer { public class BlockIronChest extends BlockContainer {
private Random random; private Random random;
@SideOnly(Side.CLIENT)
private IIcon[][] icons;
public BlockIronChest() public BlockIronChest()
{ {
super(Material.iron); super(Material.iron);
@ -91,8 +91,8 @@ public class BlockIronChest extends BlockContainer {
return IronChestType.makeEntity(metadata); return IronChestType.makeEntity(metadata);
} }
@SideOnly(Side.CLIENT)
@Override @Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int i, int j) public IIcon getIcon(int i, int j)
{ {
if (j < IronChestType.values().length) if (j < IronChestType.values().length)
@ -112,28 +112,69 @@ public class BlockIronChest extends BlockContainer {
items.add(stack); items.add(stack);
return items; return items;
} }
@Override @Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3) public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
{ {
TileEntity te = world.getTileEntity(i, j, k); if (world.isRemote)
{
return true;
}
else
{
IInventory iinventory = chestInventory(world, i, j, k);
if (te == null || !(te instanceof TileEntityIronChest)) if (iinventory != null)
{ {
return true; player.openGui(IronChest.instance, ((TileEntityIronChest) world.getTileEntity(i, j, k)).getType().ordinal(), world, i, j, k);
} }
if (world.isSideSolid(i, j + 1, k, ForgeDirection.DOWN)) return true;
{ }
return true; }
}
if (world.isRemote) public IInventory chestInventory(World world, int i, int j, int k)
{ {
return true; TileEntity chest = (TileEntityIronChest)world.getTileEntity(i, j, k);
}
player.openGui(IronChest.instance, ((TileEntityIronChest) te).getType().ordinal(), world, i, j, k); if (chest == null
return true; || world.isSideSolid(i, j + 1, k, DOWN)
|| isOcelotMounted(world, i, j, k)
|| world.getBlock(i - 1, j, k) == this && (world.isSideSolid(i - 1, j + 1, k, DOWN)
|| isOcelotMounted(world, i - 1, j, k))
|| world.getBlock(i + 1, j, k) == this && (world.isSideSolid(i + 1, j + 1, k, DOWN)
|| isOcelotMounted(world, i + 1, j, k))
|| world.getBlock(i, j, k - 1) == this && (world.isSideSolid(i, j + 1, k - 1, DOWN)
|| isOcelotMounted(world, i, j, k - 1))
|| world.getBlock(i, j, k + 1) == this && (world.isSideSolid(i, j + 1, k + 1, DOWN)
|| isOcelotMounted(world, i, j, k + 1)))
{
return null;
}
else
{
return (IInventory)chest;
}
}
private static boolean isOcelotMounted(World world, int i, int j, int k)
{
Iterator iterator = world.getEntitiesWithinAABB(EntityOcelot.class, AxisAlignedBB.getBoundingBox((double)i, (double)(j + 1), (double)k, (double)(i + 1), (double)(j + 2), (double)(k + 1))).iterator();
EntityOcelot entityocelot;
do
{
if (!iterator.hasNext())
{
return false;
}
Entity entity = (Entity)iterator.next();
entityocelot = (EntityOcelot)entity;
}
while (!entityocelot.isSitting());
return true;
} }
@Override @Override
@ -228,7 +269,6 @@ public class BlockIronChest extends BlockContainer {
} }
@Override @Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{ {
@ -283,11 +323,10 @@ public class BlockIronChest extends BlockContainer {
} }
} }
private static final ForgeDirection[] validRotationAxes = new ForgeDirection[] { UP, DOWN };
@Override @Override
public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z) public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z)
{ {
return validRotationAxes; return new ForgeDirection[] { UP, DOWN };
} }
@Override @Override

View File

@ -10,13 +10,13 @@
******************************************************************************/ ******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import invtweaks.api.container.ChestContainer;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import invtweaks.api.container.ChestContainer;
@ChestContainer(isLargeChest = true) @ChestContainer(isLargeChest = true)
public class ContainerIronChest extends Container { public class ContainerIronChest extends Container {
@ -85,13 +85,13 @@ public class ContainerIronChest extends Container {
protected void layoutContainer(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize) protected void layoutContainer(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize)
{ {
if (type == IronChestType.DIRTCHEST9000) { if (type == IronChestType.DIRTCHEST9000) {
addSlotToContainer(type.makeSlot(chestInventory, 0, 12 + 4 * 18, 8 + 2 * 18)); addSlotToContainer(new Slot(chestInventory, 0, 12 + 4 * 18, 8 + 2 * 18));
} else { } else {
for (int chestRow = 0; chestRow < type.getRowCount(); chestRow++) for (int chestRow = 0; chestRow < type.getRowCount(); chestRow++)
{ {
for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++) for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++)
{ {
addSlotToContainer(type.makeSlot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18)); addSlotToContainer(new Slot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18));
} }
} }
} }

View File

@ -12,14 +12,15 @@ package cpw.mods.ironchest;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
@ -27,12 +28,13 @@ import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:Forge@[10.10,);required-after:FML@[7.2,)") @Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:Forge@[10.10,);required-after:FML@[7.2,)")
public class IronChest { public class IronChest {
public static BlockIronChest ironChestBlock; public static BlockIronChest ironChestBlock;
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy") @SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
public static CommonProxy proxy; public static CommonProxy proxy;
@Instance("IronChest") @Instance("IronChest")
public static IronChest instance; public static IronChest instance;
public static boolean CACHE_RENDER = true; public static boolean CACHE_RENDER = true;
public static boolean OCELOTS_SITONCHESTS = true;
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent event) public void preInit(FMLPreInitializationEvent event)
@ -45,7 +47,6 @@ public class IronChest {
cfg.load(); cfg.load();
ChestChangerType.buildItems(cfg); ChestChangerType.buildItems(cfg);
CACHE_RENDER = cfg.get(Configuration.CATEGORY_GENERAL, "cacheRenderingInformation", true).getBoolean(true); CACHE_RENDER = cfg.get(Configuration.CATEGORY_GENERAL, "cacheRenderingInformation", true).getBoolean(true);
OCELOTS_SITONCHESTS = cfg.get(Configuration.CATEGORY_GENERAL, "ocelotsSitOnChests", true).getBoolean(true);
} }
catch (Exception e) catch (Exception e)
{ {
@ -73,16 +74,6 @@ public class IronChest {
ChestChangerType.generateRecipes(); ChestChangerType.generateRecipes();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
proxy.registerRenderInformation(); proxy.registerRenderInformation();
// if (OCELOTS_SITONCHESTS)
// {
// MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
// }
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@EventHandler
public void modsLoaded(FMLPostInitializationEvent evt)
{
}
} }

View File

@ -1,22 +0,0 @@
package cpw.mods.ironchest;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.world.World;
public class IronChestAIOcelotSit extends EntityAIOcelotSit {
public IronChestAIOcelotSit(EntityOcelot par1EntityOcelot, float par2)
{
super(par1EntityOcelot, par2);
}
/* @Override
protected boolean func_151486_a(World world, int x, int y, int z)
{
if (world.getBlock(x, y, z) == IronChest.ironChestBlock)
{
return true;
}
return super.func_151486_a(world, x, y, z);
}
*/}

View File

@ -13,11 +13,10 @@ package cpw.mods.ironchest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagByte;
@ -246,11 +245,6 @@ public enum IronChestType {
private static String[] sideNames = { "top", "front", "side" }; private static String[] sideNames = { "top", "front", "side" };
private static int[] sideMapping = { 0, 0, 2, 1, 2, 2, 2 }; private static int[] sideMapping = { 0, 0, 2, 1, 2, 2, 2 };
public Slot makeSlot(IInventory chestInventory, int index, int x, int y)
{
return new ValidatingSlot(chestInventory, index, x, y, this);
}
public boolean acceptsStack(ItemStack itemstack) public boolean acceptsStack(ItemStack itemstack)
{ {
return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter; return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter;

View File

@ -1,33 +0,0 @@
package cpw.mods.ironchest;
import net.minecraft.item.ItemStack;
public class MappableItemStackWrapper {
private ItemStack wrap;
public MappableItemStackWrapper(ItemStack toWrap)
{
wrap = toWrap;
}
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof MappableItemStackWrapper)) return false;
MappableItemStackWrapper isw = (MappableItemStackWrapper) obj;
if (wrap.getHasSubtypes())
{
return isw.wrap.isItemEqual(wrap);
}
else
{
return isw.wrap == wrap;
}
}
@Override
public int hashCode()
{
return System.identityHashCode(wrap);
}
}

View File

@ -1,30 +0,0 @@
package cpw.mods.ironchest;
import java.util.List;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraftforge.event.entity.living.LivingEvent;
public class OcelotsSitOnChestsHandler {
@SubscribeEvent
public void changeSittingTaskForOcelots(LivingEvent.LivingUpdateEvent evt)
{
if (evt.entityLiving.ticksExisted < 5 && evt.entityLiving instanceof EntityOcelot)
{
EntityOcelot ocelot = (EntityOcelot) evt.entityLiving;
@SuppressWarnings("unchecked")
List<EntityAITasks.EntityAITaskEntry> tasks = ocelot.tasks.taskEntries;
for (int i = 0; i < tasks.size(); i++)
{
EntityAITasks.EntityAITaskEntry task = tasks.get(i);
if (task.priority == 6 && (task.action instanceof EntityAIOcelotSit) && !(task.action instanceof IronChestAIOcelotSit))
{
task.action = new IronChestAIOcelotSit(ocelot, 0.4F);
}
}
}
}
}

View File

@ -1,21 +0,0 @@
package cpw.mods.ironchest;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ValidatingSlot extends Slot {
private IronChestType type;
public ValidatingSlot(IInventory par1iInventory, int par2, int par3, int par4, IronChestType type)
{
super(par1iInventory, par2, par3, par4);
this.type = type;
}
@Override
public boolean isItemValid(ItemStack par1ItemStack)
{
return type.acceptsStack(par1ItemStack);
}
}

View File

@ -9,12 +9,7 @@ package cpw.mods.ironchest;
import java.util.Properties; import java.util.Properties;
public class Version { public class Version {
private static String major; private static String major, minor, rev, build, mcversion;
private static String minor;
private static String rev;
private static String build;
@SuppressWarnings("unused")
private static String mcversion;
static void init(Properties properties) static void init(Properties properties)
{ {

View File

@ -18,11 +18,11 @@ import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef; import static org.lwjgl.opengl.GL11.glRotatef;
import static org.lwjgl.opengl.GL11.glScalef; import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslatef; import static org.lwjgl.opengl.GL11.glTranslatef;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import net.minecraft.client.model.ModelChest; import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -30,152 +30,147 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.primitives.SignedBytes; import com.google.common.primitives.SignedBytes;
import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.MappableItemStackWrapper;
import cpw.mods.ironchest.TileEntityIronChest; import cpw.mods.ironchest.TileEntityIronChest;
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
@SuppressWarnings("unused") private ModelChest model;
private static Map<MappableItemStackWrapper, Integer> renderList = new HashMap<MappableItemStackWrapper, Integer>();
private static Map<IronChestType, ResourceLocation> locations; private static Map<IronChestType, ResourceLocation> locations;
static {
Builder<IronChestType, ResourceLocation> builder = ImmutableMap.<IronChestType,ResourceLocation>builder();
for (IronChestType typ : IronChestType.values()) {
builder.put(typ, new ResourceLocation("ironchest","textures/model/"+typ.getModelTexture()));
}
locations = builder.build();
}
private Random random;
@SuppressWarnings("unused") static {
private RenderBlocks renderBlocks; Builder<IronChestType, ResourceLocation> builder = ImmutableMap.<IronChestType,ResourceLocation>builder();
for (IronChestType typ : IronChestType.values()) {
builder.put(typ, new ResourceLocation("ironchest","textures/model/"+typ.getModelTexture()));
}
locations = builder.build();
}
private RenderItem itemRenderer; private Random random;
private RenderItem itemRenderer;
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F }, private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F },
{ 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, }; { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, };
public TileEntityIronChestRenderer() public TileEntityIronChestRenderer()
{ {
model = new ModelChest(); model = new ModelChest();
random = new Random(); random = new Random();
renderBlocks = new RenderBlocks(); itemRenderer = new RenderItem() {
itemRenderer = new RenderItem() { @Override
@Override public byte getMiniBlockCount(ItemStack stack, byte original) {
public byte getMiniBlockCount(ItemStack stack, byte original) { return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1);
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 15) + 1); }
} @Override
@Override public byte getMiniItemCount(ItemStack stack, byte original) {
public byte getMiniItemCount(ItemStack stack, byte original) { return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1);
return SignedBytes.saturatedCast(Math.min(stack.stackSize / 32, 7) + 1); }
} @Override
@Override public boolean shouldBob() {
public boolean shouldBob() { return false;
return false; }
} @Override
@Override public boolean shouldSpreadItems() {
public boolean shouldSpreadItems() { return false;
return false; }
} };
}; itemRenderer.setRenderManager(RenderManager.instance);
itemRenderer.setRenderManager(RenderManager.instance); }
}
public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) { public void render(TileEntityIronChest tile, double x, double y, double z, float partialTick) {
if (tile == null) { if (tile == null) {
return; return;
} }
int facing = 3; int facing = 3;
IronChestType type = tile.getType(); IronChestType type = tile.getType();
if (tile != null && tile.hasWorldObj()) { if (tile != null && tile.hasWorldObj()) {
facing = tile.getFacing(); facing = tile.getFacing();
type = tile.getType(); type = tile.getType();
int typ = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord); int typ = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
type = IronChestType.values()[typ]; type = IronChestType.values()[typ];
} }
bindTexture(locations.get(type)); bindTexture(locations.get(type));
glPushMatrix(); glPushMatrix();
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */); glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
glColor4f(1.0F, 1.0F, 1.0F, 1.0F); glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F); glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
glScalef(1.0F, -1F, -1F); glScalef(1.0F, -1F, -1F);
glTranslatef(0.5F, 0.5F, 0.5F); glTranslatef(0.5F, 0.5F, 0.5F);
int k = 0; int k = 0;
if (facing == 2) { if (facing == 2) {
k = 180; k = 180;
} }
if (facing == 3) { if (facing == 3) {
k = 0; k = 0;
} }
if (facing == 4) { if (facing == 4) {
k = 90; k = 90;
} }
if (facing == 5) { if (facing == 5) {
k = -90; k = -90;
} }
glRotatef(k, 0.0F, 1.0F, 0.0F); glRotatef(k, 0.0F, 1.0F, 0.0F);
glTranslatef(-0.5F, -0.5F, -0.5F); glTranslatef(-0.5F, -0.5F, -0.5F);
float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick; float lidangle = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTick;
lidangle = 1.0F - lidangle; lidangle = 1.0F - lidangle;
lidangle = 1.0F - lidangle * lidangle * lidangle; lidangle = 1.0F - lidangle * lidangle * lidangle;
model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F); model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F);
// Render the chest itself // Render the chest itself
model.renderAll(); model.renderAll();
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */); glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
glPopMatrix(); glPopMatrix();
glColor4f(1.0F, 1.0F, 1.0F, 1.0F); glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
if (type.isTransparent() && tile.getDistanceFrom(this.field_147501_a.field_147560_j, this.field_147501_a.field_147561_k, this.field_147501_a.field_147558_l) < 128d) { if (type.isTransparent() && tile.getDistanceFrom(this.field_147501_a.field_147560_j, this.field_147501_a.field_147561_k, this.field_147501_a.field_147558_l) < 128d) {
random.setSeed(254L); random.setSeed(254L);
float shiftX; float shiftX;
float shiftY; float shiftY;
float shiftZ; float shiftZ;
int shift = 0; int shift = 0;
float blockScale = 0.70F; float blockScale = 0.70F;
float timeD = (float) (360.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL); float timeD = (float) (360.0 * (double) (System.currentTimeMillis() & 0x3FFFL) / (double) 0x3FFFL);
if (tile.getTopItemStacks()[1] == null) { if (tile.getTopItemStacks()[1] == null) {
shift = 8; shift = 8;
blockScale = 0.85F; blockScale = 0.85F;
} }
glPushMatrix(); glPushMatrix();
glDisable(2896 /* GL_LIGHTING */); glDisable(2896 /* GL_LIGHTING */);
glTranslatef((float) x, (float) y, (float) z); glTranslatef((float) x, (float) y, (float) z);
EntityItem customitem = new EntityItem(field_147501_a.field_147550_f); EntityItem customitem = new EntityItem(field_147501_a.field_147550_f);
customitem.hoverStart = 0f; customitem.hoverStart = 0f;
for (ItemStack item : tile.getTopItemStacks()) { for (ItemStack item : tile.getTopItemStacks()) {
if (shift > shifts.length) { if (shift > shifts.length) {
break; break;
} }
if (item == null) { if (item == null) {
shift++; shift++;
continue; continue;
} }
shiftX = shifts[shift][0]; shiftX = shifts[shift][0];
shiftY = shifts[shift][1]; shiftY = shifts[shift][1];
shiftZ = shifts[shift][2]; shiftZ = shifts[shift][2];
shift++; shift++;
glPushMatrix(); glPushMatrix();
glTranslatef(shiftX, shiftY, shiftZ); glTranslatef(shiftX, shiftY, shiftZ);
glRotatef(timeD, 0.0F, 1.0F, 0.0F); glRotatef(timeD, 0.0F, 1.0F, 0.0F);
glScalef(blockScale, blockScale, blockScale); glScalef(blockScale, blockScale, blockScale);
customitem.setEntityItemStack(item); customitem.setEntityItemStack(item);
itemRenderer.doRender(customitem, 0, 0, 0, 0, 0); itemRenderer.doRender(customitem, 0, 0, 0, 0, 0);
glPopMatrix(); glPopMatrix();
} }
glEnable(2896 /* GL_LIGHTING */); glEnable(2896 /* GL_LIGHTING */);
glPopMatrix(); glPopMatrix();
glColor4f(1.0F, 1.0F, 1.0F, 1.0F); glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
} }
} }
@Override @Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTick)
{ {
render((TileEntityIronChest) tileentity, x, y, z, partialTick); render((TileEntityIronChest) tileentity, x, y, z, partialTick);
} }
private ModelChest model;
} }