Compare commits

..
1 Commits
Author SHA1 Message Date
cpw c3eed2f0da Fix up release jsons to clean up extraneous netty references 2016-05-11 11:20:43 -04:00
225 changed files with 1269 additions and 10873 deletions

No files matched your search

+1 -2
View File
@@ -4,7 +4,6 @@
*.java text eol=lf
*.gradle text eol=crlf
*.png binary
*.gif binary
*.exe binary
*.dll binary
*.jar binary
@@ -12,4 +11,4 @@
*.zip binary
*.pyd binary
*.cfg text eol=lf
*.py text eol=lf
*.py text eol=lf
+5 -7
View File
@@ -26,11 +26,11 @@ apply plugin: "net.minecraftforge.gradle.patcher"
apply plugin: "net.minecraftforge.gradle.launch4j"
minecraft {
version = "1.8.9"
mappings = 'stable_20'
//mappings = "snapshot_nodoc_20151122"
version = "1.8.8"
//mappings = 'stable_16'
mappings = "snapshot_nodoc_20151122"
workspaceDir = "projects"
versionJson = "jsons/1.8.9-dev.json"
versionJson = "jsons/1.8.8-dev.json"
buildUserdev = true
buildInstaller = true
installerVersion = "1.4"
@@ -61,12 +61,11 @@ group = 'net.minecraftforge'
version = getVersionFromJava(file("src/main/java/net/minecraftforge/common/ForgeVersion.java"))
extractForgeSources { exclude "**/SideOnly.java", "**/Side.java" }
extractForgeResources { exclude "**/log4j2.xml" }
genGradleProjects { addTestCompileDep "junit:junit:4.12" }
processJson {
releaseJson = "jsons/1.8.9-rel.json"
releaseJson = "jsons/1.8.8-rel.json"
addReplacements([
"@minecraft_version@": project.minecraft.version,
"@version@": project.version,
@@ -157,7 +156,6 @@ task signUniversal(type: SignJar, dependsOn: 'outputJar') {
}
uploadArchives.dependsOn signUniversal
build.dependsOn signUniversal
installer.dependsOn signUniversal
// MDK package
-95
View File
@@ -1,95 +0,0 @@
{
"id": "@minecraft_version@-@project@@version@",
"time": "@timestamp@",
"releaseTime": "1960-01-01T00:00:00-0700",
"type": "release",
"inheritsFrom": "1.8.9",
"minecraftArguments": "--version FML_DEV --tweakClass net.minecraftforge.fml.common.launcher.FMLTweaker",
"libraries": [
{
"name": "net.minecraft:launchwrapper:1.12"
},
{
"name": "jline:jline:2.13",
"children": ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "com.google.code.findbugs:jsr305:1.3.9",
"children": ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm-debug-all:5.0.3",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "com.typesafe.akka:akka-actor_2.11:2.3.3",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "com.typesafe:config:1.2.1",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "org.scala-lang:scala-actors-migration_2.11:1.1.0",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "org.scala-lang:scala-compiler:2.11.1",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "org.scala-lang:scala-library:2.11.1",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "org.scala-lang.modules:scala-parser-combinators_2.11:1.0.1",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "org.scala-lang:scala-reflect:2.11.1",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "org.scala-lang.modules:scala-swing_2.11:1.0.1",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "org.scala-lang.modules:scala-xml_2.11:1.0.2",
"children" : ["sources"],
"url" : "http://repo.maven.apache.org/maven2"
},
{
"name": "lzma:lzma:0.0.1"
},
{
"name": "java3d:vecmath:1.5.2"
},
{
"name": "net.sf.trove4j:trove4j:3.0.3"
}
],
"mainClass": "net.minecraft.launchwrapper.Launch",
"minimumLauncherVersion": 14,
"assets": "1.8"
}
-141
View File
@@ -1,141 +0,0 @@
{
"install": {
"profileName": "@project@",
"target":"@minecraft_version@-@project@@version@",
"path":"@artifact@",
"version":"@project@ @version@",
"filePath":"@universal_jar@",
"welcome":"Welcome to the simple @project@ installer.",
"minecraft":"@minecraft_version@",
"mirrorList" : "http://files.minecraftforge.net/mirror-brand.list",
"logo":"/big_logo.png"
},
"versionInfo": {
"id": "@minecraft_version@-@project@@version@",
"time": "@timestamp@",
"releaseTime": "1960-01-01T00:00:00-0700",
"type": "release",
"minecraftArguments": "--username ${auth_player_name} --version ${version_name} --gameDir ${game_directory} --assetsDir ${assets_root} --assetIndex ${assets_index_name} --uuid ${auth_uuid} --accessToken ${auth_access_token} --userProperties ${user_properties} --userType ${user_type} --tweakClass net.minecraftforge.fml.common.launcher.FMLTweaker",
"mainClass": "net.minecraft.launchwrapper.Launch",
"minimumLauncherVersion": 14,
"assets": "1.8",
"inheritsFrom": "1.8.9",
"jar": "1.8.9",
"libraries": [
{
"name": "@artifact@",
"url": "http://files.minecraftforge.net/maven/"
},
{
"name": "net.minecraft:launchwrapper:1.12",
"serverreq":true
},
{
"name": "org.ow2.asm:asm-all:5.0.3",
"serverreq":true
},
{
"name": "jline:jline:2.13",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "2d9530d0a25daffaffda7c35037b046b627bb171" ],
"serverreq":true,
"clientreq":false
},
{
"name": "com.typesafe.akka:akka-actor_2.11:2.3.3",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "ed62e9fc709ca0f2ff1a3220daa8b70a2870078e", "25a86ccfdb6f6dfe08971f4825d0a01be83a6f2e" ],
"serverreq":true,
"clientreq":true
},
{
"name": "com.typesafe:config:1.2.1",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "f771f71fdae3df231bcd54d5ca2d57f0bf93f467", "7d7bc36df0989d72f2d5d057309675777acc528b" ],
"serverreq":true,
"clientreq":true
},
{
"name": "org.scala-lang:scala-actors-migration_2.11:1.1.0",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "dfa8bc42b181d5b9f1a5dd147f8ae308b893eb6f", "8c9aaeeb68487ca519411a14068e1b4d69739207" ],
"serverreq":true,
"clientreq":true
},
{
"name": "org.scala-lang:scala-compiler:2.11.1",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "56ea2e6c025e0821f28d73ca271218b8dd04926a", "1444992390544ba3780867a13ff696a89d7d1639" ],
"serverreq":true,
"clientreq":true
},
{
"name": "org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "87213338cd5a153a7712cb574c0ddd2edfee0386", "0b4c1bf8d48993f138d6e10c0c144e50acfff581" ],
"serverreq":true,
"clientreq":true
},
{
"name": "org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "1f7371605d4ba42aa26d3443440c0083c587b4e9", "1ea655dda4504ae0a367327e2340cd3beaee6c73" ],
"serverreq":true,
"clientreq":true
},
{
"name": "org.scala-lang:scala-library:2.11.1",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "0e11da23da3eabab9f4777b9220e60d44c1aab6a", "1e4df76e835201c6eabd43adca89ab11f225f134" ],
"serverreq":true,
"clientreq":true
},
{
"name": "org.scala-lang:scala-parser-combinators_2.11:1.0.1",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "f05d7345bf5a58924f2837c6c1f4d73a938e1ff0", "a1cbbcbde1dcc614f4253ed1aa0b320bc78d8f1d" ],
"serverreq":true,
"clientreq":true
},
{
"name": "org.scala-lang:scala-reflect:2.11.1",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "6580347e61cc7f8e802941e7fde40fa83b8badeb", "91ce0f0be20f4a536321724b4b3bbc6530ddcd88" ],
"serverreq":true,
"clientreq":true
},
{
"name": "org.scala-lang:scala-swing_2.11:1.0.1",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "b1cdd92bd47b1e1837139c1c53020e86bb9112ae", "d77152691dcf5bbdb00529af37aa7d3d887b3e63" ],
"serverreq":true,
"clientreq":true
},
{
"name": "org.scala-lang:scala-xml_2.11:1.0.2",
"url" : "http://files.minecraftforge.net/maven/",
"checksums" : [ "7a80ec00aec122fba7cd4e0d4cdd87ff7e4cb6d0", "62736b01689d56b6d09a0164b7ef9da2b0b9633d" ],
"serverreq":true,
"clientreq":true
},
{
"name": "lzma:lzma:0.0.1",
"serverreq":true
},
{
"name": "net.sf.jopt-simple:jopt-simple:4.6",
"serverreq":true
},
{
"name": "java3d:vecmath:1.5.2",
"clientreq":true,
"serverreq":true
},
{
"name": "net.sf.trove4j:trove4j:3.0.3",
"clientreq":true,
"serverreq":true
}
]
}
}
-244
View File
@@ -1,244 +0,0 @@
{
"id": "1.8.9",
"time": "2015-12-03T12:24:39+03:00",
"releaseTime": "2015-12-03T12:24:39+03:00",
"type": "release",
"minecraftArguments": "--username ${auth_player_name} --version ${version_name} --gameDir ${game_directory} --assetsDir ${assets_root} --assetIndex ${assets_index_name} --uuid ${auth_uuid} --accessToken ${auth_access_token} --userProperties ${user_properties} --userType ${user_type}",
"libraries": [
{
"name": "oshi-project:oshi-core:1.1"
},
{
"name": "net.java.dev.jna:jna:3.4.0"
},
{
"name": "net.java.dev.jna:platform:3.4.0"
},
{
"name": "com.ibm.icu:icu4j-core-mojang:51.2"
},
{
"name": "net.sf.jopt-simple:jopt-simple:4.6"
},
{
"name": "com.paulscode:codecjorbis:20101023"
},
{
"name": "com.paulscode:codecwav:20101023"
},
{
"name": "com.paulscode:libraryjavasound:20101123"
},
{
"name": "com.paulscode:librarylwjglopenal:20100824"
},
{
"name": "com.paulscode:soundsystem:20120107"
},
{
"name": "io.netty:netty-all:4.0.23.Final"
},
{
"name": "com.google.guava:guava:17.0"
},
{
"name": "org.apache.commons:commons-lang3:3.3.2"
},
{
"name": "commons-io:commons-io:2.4"
},
{
"name": "commons-codec:commons-codec:1.9"
},
{
"name": "net.java.jinput:jinput:2.0.5"
},
{
"name": "net.java.jutils:jutils:1.0.0"
},
{
"name": "com.google.code.gson:gson:2.2.4"
},
{
"name": "com.mojang:authlib:1.5.21"
},
{
"name": "com.mojang:realms:1.7.48"
},
{
"name": "org.apache.commons:commons-compress:1.8.1"
},
{
"name": "org.apache.httpcomponents:httpclient:4.3.3"
},
{
"name": "commons-logging:commons-logging:1.1.3"
},
{
"name": "org.apache.httpcomponents:httpcore:4.3.2"
},
{
"name": "org.apache.logging.log4j:log4j-api:2.0-beta9"
},
{
"name": "org.apache.logging.log4j:log4j-core:2.0-beta9"
},
{
"name": "org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209",
"rules": [
{
"action": "allow"
},
{
"action": "disallow",
"os": {
"name": "osx"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl_util:2.9.4-nightly-20150209",
"rules": [
{
"action": "allow"
},
{
"action": "disallow",
"os": {
"name": "osx"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.4-nightly-20150209",
"rules": [
{
"action": "allow"
},
{
"action": "disallow",
"os": {
"name": "osx"
}
}
],
"natives": {
"linux": "natives-linux",
"windows": "natives-windows",
"osx": "natives-osx"
},
"extract": {
"exclude": [
"META-INF/"
]
}
},
{
"name": "org.lwjgl.lwjgl:lwjgl:2.9.2-nightly-20140822",
"rules": [
{
"action": "allow",
"os": {
"name": "osx"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl_util:2.9.2-nightly-20140822",
"rules": [
{
"action": "allow",
"os": {
"name": "osx"
}
}
]
},
{
"name": "org.lwjgl.lwjgl:lwjgl-platform:2.9.2-nightly-20140822",
"rules": [
{
"action": "allow",
"os": {
"name": "osx"
}
}
],
"natives": {
"linux": "natives-linux",
"windows": "natives-windows",
"osx": "natives-osx"
},
"extract": {
"exclude": [
"META-INF/"
]
}
},
{
"name": "net.java.jinput:jinput-platform:2.0.5",
"natives": {
"linux": "natives-linux",
"windows": "natives-windows",
"osx": "natives-osx"
},
"extract": {
"exclude": [
"META-INF/"
]
}
},
{
"name": "tv.twitch:twitch:6.5"
},
{
"name": "tv.twitch:twitch-platform:6.5",
"rules": [
{
"action": "allow"
},
{
"action": "disallow",
"os": {
"name": "linux"
}
}
],
"natives": {
"linux": "natives-linux",
"windows": "natives-windows-${arch}",
"osx": "natives-osx"
},
"extract": {
"exclude": [
"META-INF/"
]
}
},
{
"name": "tv.twitch:twitch-external-platform:4.5",
"rules": [
{
"action": "allow",
"os": {
"name": "windows"
}
}
],
"natives": {
"windows": "natives-windows-${arch}"
},
"extract": {
"exclude": [
"META-INF/"
]
}
}
],
"mainClass": "net.minecraft.client.main.Main",
"minimumLauncherVersion": 14,
"assets": "1.8"
}
@@ -188,7 +188,7 @@
}
protected ItemStack func_180643_i(IBlockState p_180643_1_)
@@ -1010,6 +1030,1147 @@
@@ -1010,6 +1030,1065 @@
return "Block{" + field_149771_c.func_177774_c(this) + "}";
}
@@ -1214,43 +1214,10 @@
+ */
+ public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos)
+ {
+ return state;
+ return func_176221_a(state, world, pos);
+ }
+
+ /**
+ * Called when the entity is inside this block, may be used to determined if the entity can breathing,
+ * display material overlays, or if the entity can swim inside a block.
+ *
+ * @param world that is being tested.
+ * @param blockpos position thats being tested.
+ * @param iblockstate state at world/blockpos
+ * @param entity that is being tested.
+ * @param yToTest, primarily for testingHead, which sends the the eye level of the entity, other wise it sends a y that can be tested vs liquid height.
+ * @param materialIn to test for.
+ * @param testingHead when true, its testing the entities head for vision, breathing ect... otherwise its testing the body, for swimming and movement adjustment.
+ * @return null for default behavior, true if the entity is within the material, false if it was not.
+ */
+ public Boolean isEntityInsideMaterial(World world, BlockPos blockpos, IBlockState iblockstate, Entity entity, double yToTest, Material materialIn, boolean testingHead)
+ {
+ return null;
+ }
+
+ /**
+ * Called when boats or fishing hooks are inside the block to check if they are inside
+ * the material requested.
+ *
+ * @param world world that is being tested.
+ * @param pos block thats being tested.
+ * @param boundingBox box to test, generally the bounds of an entity that are besting tested.
+ * @param materialIn to check for.
+ * @return null for default behavior, true if the box is within the material, false if it was not.
+ */
+ public Boolean isAABBInsideMaterial(World world, BlockPos pos, AxisAlignedBB boundingBox, Material materialIn)
+ {
+ return null;
+ }
+
+ /**
+ * Queries if this block should render in a given layer.
+ * ISmartBlockModel can use MinecraftForgeClient.getRenderLayer to alter their model based on layer
+ */
@@ -1282,55 +1249,6 @@
+ return capturedDrops.get();
+ }
+ }
+
+ private ResourceLocation registryName = null;
+ /**
+ * Sets a unique name for this Block. This should be used for uniquely identify the instance of the Block.
+ * This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does.
+ * Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items.
+ *
+ * The supplied name will be prefixed with the currently active mod's modId.
+ * If the supplied name already has a prefix that is different, it will be used and a warning will be logged.
+ *
+ * If a name already exists, or this Block is already registered in a registry, then an IllegalStateException is thrown.
+ *
+ * Returns 'this' to allow for chaining.
+ *
+ * @param name Unique registry name
+ * @return This instance
+ */
+ public final Block setRegistryName(String name)
+ {
+ if (getRegistryName() != null)
+ throw new IllegalStateException("Attempted to set registry name on block with exisiting registry name! New: " + name + " Old: " + getRegistryName());
+ int index = name.lastIndexOf(':');
+ String oldPrefix = index == -1 ? "" : name.substring(0, index);
+ name = index == -1 ? name : name.substring(index + 1);
+ net.minecraftforge.fml.common.ModContainer mc = net.minecraftforge.fml.common.Loader.instance().activeModContainer();
+ String prefix = mc == null ? "minecraft" : mc.getModId();
+ if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
+ {
+ net.minecraftforge.fml.common.FMLLog.bigWarning("Dangerous alternative prefix %s for name %s, invalid registry invocation/invalid name?", oldPrefix, name);
+ prefix = oldPrefix;
+ }
+ this.registryName = new ResourceLocation(prefix, name);
+ return this;
+ }
+ public final Block setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); }
+ public final Block setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); }
+
+ /**
+ * A unique identifier for this block, if this block is registered in the game registry it will return that name.
+ * Otherwise it will return the name set in setRegistryName().
+ * If neither are valid null is returned.
+ *
+ * @return Unique identifier or null.
+ */
+ public final String getRegistryName()
+ {
+ if (delegate.getResourceName() != null) return delegate.getResourceName().toString();
+ return registryName != null ? registryName.toString() : null;
+ }
+ /* ========================================= FORGE END ======================================*/
+
public static void func_149671_p()
@@ -1,54 +0,0 @@
--- ../src-base/minecraft/net/minecraft/block/BlockBanner.java
+++ ../src-work/minecraft/net/minecraft/block/BlockBanner.java
@@ -85,22 +85,7 @@
public void func_180653_a(World p_180653_1_, BlockPos p_180653_2_, IBlockState p_180653_3_, float p_180653_4_, int p_180653_5_)
{
- TileEntity tileentity = p_180653_1_.func_175625_s(p_180653_2_);
-
- if (tileentity instanceof TileEntityBanner)
{
- ItemStack itemstack = new ItemStack(Items.field_179564_cE, 1, ((TileEntityBanner)tileentity).func_175115_b());
- NBTTagCompound nbttagcompound = new NBTTagCompound();
- tileentity.func_145841_b(nbttagcompound);
- nbttagcompound.func_82580_o("x");
- nbttagcompound.func_82580_o("y");
- nbttagcompound.func_82580_o("z");
- nbttagcompound.func_82580_o("id");
- itemstack.func_77983_a("BlockEntityTag", nbttagcompound);
- func_180635_a(p_180653_1_, p_180653_2_, itemstack);
- }
- else
- {
super.func_180653_a(p_180653_1_, p_180653_2_, p_180653_3_, p_180653_4_, p_180653_5_);
}
}
@@ -133,6 +118,28 @@
}
}
+ @Override
+ public java.util.List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
+ {
+ TileEntity te = world.func_175625_s(pos);
+
+ java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
+ if (te instanceof TileEntityBanner)
+ {
+ TileEntityBanner banner = (TileEntityBanner)te;
+ ItemStack item = new ItemStack(Items.field_179564_cE, 1, banner.func_175115_b());
+ NBTTagCompound nbt = new NBTTagCompound();
+ TileEntityBanner.func_181020_a(nbt, banner.func_175115_b(), banner.func_181021_d());
+ item.func_77983_a("BlockEntityTag", nbt);
+ ret.add(item);
+ }
+ else
+ {
+ ret.add(new ItemStack(Items.field_179564_cE, 1, 0));
+ }
+ return ret;
+ }
+
public static class BlockBannerHanging extends BlockBanner
{
public BlockBannerHanging()
@@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/block/BlockDropper.java
+++ ../src-work/minecraft/net/minecraft/block/BlockDropper.java
@@ -43,7 +43,7 @@
{
ItemStack itemstack = tileentitydispenser.func_70301_a(i);
- if (itemstack != null)
+ if (itemstack != null && net.minecraftforge.items.VanillaInventoryCodeHooks.dropperInsertHook(p_176439_1_, p_176439_2_, tileentitydispenser, i, itemstack))
{
EnumFacing enumfacing = (EnumFacing)p_176439_1_.func_180495_p(p_176439_2_).func_177229_b(field_176441_a);
BlockPos blockpos = p_176439_2_.func_177972_a(enumfacing);
@@ -9,7 +9,7 @@
}
protected BlockRailBase(boolean p_i45389_1_)
@@ -175,6 +175,98 @@
@@ -175,6 +175,81 @@
public abstract IProperty<BlockRailBase.EnumRailDirection> func_176560_l();
@@ -18,7 +18,7 @@
+ * Return true if the rail can make corners.
+ * Used by placement logic.
+ * @param world The world.
+ * @param pos Block's position in world
+ * @param pod Block's position in world
+ * @return True if the rail can make corners.
+ */
+ public boolean isFlexibleRail(IBlockAccess world, BlockPos pos)
@@ -30,7 +30,7 @@
+ * Returns true if the rail can make up and down slopes.
+ * Used by placement logic.
+ * @param world The world.
+ * @param pos Block's position in world
+ * @param pod Block's position in world
+ * @return True if the rail can make slopes.
+ */
+ public boolean canMakeSlopes(IBlockAccess world, BlockPos pos)
@@ -39,27 +39,10 @@
+ }
+
+ /**
+ * Return the rail's direction.
+ * Can be used to make the cart think the rail is a different shape,
+ * for example when making diamond junctions or switches.
+ * The cart parameter will often be null unless it it called from EntityMinecart.
+ *
+ * @param world The world.
+ * @param pos Block's position in world
+ * @param state The BlockState
+ * @param cart The cart asking for the metadata, null if it is not called by EntityMinecart.
+ * @return The direction.
+ */
+ public EnumRailDirection getRailDirection(IBlockAccess world, BlockPos pos, IBlockState state, @javax.annotation.Nullable net.minecraft.entity.item.EntityMinecart cart)
+ {
+ return state.func_177229_b(func_176560_l());
+ }
+
+ /**
+ * Returns the max speed of the rail at the specified position.
+ * @param world The world.
+ * @param cart The cart on the rail, may be null.
+ * @param pos Block's position in world
+ * @param pod Block's position in world
+ * @return The max speed of the current rail.
+ */
+ public float getRailMaxSpeed(World world, net.minecraft.entity.item.EntityMinecart cart, BlockPos pos)
@@ -72,7 +55,7 @@
+ * It is called once per update tick that the minecart is on the rail.
+ * @param world The world.
+ * @param cart The cart on the rail.
+ * @param pos Block's position in world
+ * @param pod Block's position in world
+ */
+ public void onMinecartPass(World world, net.minecraft.entity.item.EntityMinecart cart, BlockPos pos)
+ {
@@ -108,7 +91,7 @@
public static enum EnumRailDirection implements IStringSerializable
{
NORTH_SOUTH(0, "north_south"),
@@ -245,6 +337,7 @@
@@ -245,6 +320,7 @@
private IBlockState field_180366_e;
private final boolean field_150656_f;
private final List<BlockPos> field_150657_g = Lists.<BlockPos>newArrayList();
@@ -116,19 +99,17 @@
public Rail(World p_i45739_2_, BlockPos p_i45739_3_, IBlockState p_i45739_4_)
{
@@ -252,8 +345,9 @@
this.field_180367_c = p_i45739_3_;
@@ -253,7 +329,8 @@
this.field_180366_e = p_i45739_4_;
this.field_180365_d = (BlockRailBase)p_i45739_4_.func_177230_c();
- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)p_i45739_4_.func_177229_b(BlockRailBase.this.func_176560_l());
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)p_i45739_4_.func_177229_b(BlockRailBase.this.func_176560_l());
- this.field_150656_f = this.field_180365_d.field_150053_a;
+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = field_180365_d.getRailDirection(p_i45739_2_, p_i45739_3_, p_i45739_4_, null);
+ this.field_150656_f = !this.field_180365_d.isFlexibleRail(p_i45739_2_, p_i45739_3_);
+ canMakeSlopes = this.field_180365_d.canMakeSlopes(p_i45739_2_, p_i45739_3_);
this.func_180360_a(blockrailbase$enumraildirection);
}
@@ -439,7 +533,7 @@
@@ -439,7 +516,7 @@
}
}
@@ -137,7 +118,7 @@
{
if (BlockRailBase.func_176562_d(this.field_150660_b, blockpos.func_177984_a()))
{
@@ -452,7 +546,7 @@
@@ -452,7 +529,7 @@
}
}
@@ -146,7 +127,7 @@
{
if (BlockRailBase.func_176562_d(this.field_150660_b, blockpos3.func_177984_a()))
{
@@ -595,7 +689,7 @@
@@ -595,7 +672,7 @@
}
}
@@ -155,7 +136,7 @@
{
if (BlockRailBase.func_176562_d(this.field_150660_b, blockpos.func_177984_a()))
{
@@ -608,7 +702,7 @@
@@ -608,7 +685,7 @@
}
}
@@ -170,7 +170,7 @@
int i = itemstack != null ? itemstack.field_77994_a : 0;
+
+ boolean result = !net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_71439_g, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, this.field_71441_e, blockpos, this.field_71476_x.field_178784_b, this.field_71476_x.field_72307_f).isCanceled();
+ boolean result = !net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_71439_g, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, this.field_71441_e, blockpos, this.field_71476_x.field_178784_b).isCanceled();
+ if (result) { //Forge: Kept separate to simplify patch
if (this.field_71442_b.func_178890_a(this.field_71439_g, this.field_71441_e, itemstack, blockpos, this.field_71476_x.field_178784_b, this.field_71476_x.field_72307_f))
{
@@ -186,7 +186,7 @@
ItemStack itemstack1 = this.field_71439_g.field_71071_by.func_70448_g();
- if (itemstack1 != null && this.field_71442_b.func_78769_a(this.field_71439_g, this.field_71441_e, itemstack1))
+ boolean result = !net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_71439_g, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_AIR, field_71441_e, null, null, null).isCanceled();
+ boolean result = !net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_71439_g, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_AIR, field_71441_e, null, null).isCanceled();
+ if (result && itemstack1 != null && this.field_71442_b.func_78769_a(this.field_71439_g, this.field_71441_e, itemstack1))
{
this.field_71460_t.field_78516_c.func_78445_c();
@@ -8,7 +8,7 @@
+ {
+ for (int y = 0; y < height; y++)
+ {
+ if (!func_175162_d(pos.func_177982_a(0, y, 0))) return false;
+ if (func_175162_d(pos.func_177982_a(0, y, 0))) return false;
+ }
+ return true;
+ }
@@ -21,9 +21,9 @@
double d1 = p_145771_5_ - (double)blockpos.func_177952_p();
- if (!this.func_175162_d(blockpos))
+ int entHeight = Math.max((int)Math.ceil(this.field_70131_O), 1);
+ int entHeight = Math.max(Math.round(this.field_70131_O), 1);
+
+ boolean inTranslucentBlock = !this.isHeadspaceFree(blockpos, entHeight);
+ boolean inTranslucentBlock = this.isHeadspaceFree(blockpos, entHeight);
+
+ if (inTranslucentBlock)
{
@@ -31,40 +31,31 @@
double d2 = 9999.0D;
- if (this.func_175162_d(blockpos.func_177976_e()) && d0 < d2)
+ if (this.isHeadspaceFree(blockpos.func_177976_e(), entHeight) && d0 < d2)
+ if (!this.isHeadspaceFree(blockpos.func_177976_e(), entHeight) && d0 < d2)
{
d2 = d0;
i = 0;
}
- if (this.func_175162_d(blockpos.func_177974_f()) && 1.0D - d0 < d2)
+ if (this.isHeadspaceFree(blockpos.func_177974_f(), entHeight) && 1.0D - d0 < d2)
+ if (!this.isHeadspaceFree(blockpos.func_177974_f(), entHeight) && 1.0D - d0 < d2)
{
d2 = 1.0D - d0;
i = 1;
}
- if (this.func_175162_d(blockpos.func_177978_c()) && d1 < d2)
+ if (this.isHeadspaceFree(blockpos.func_177978_c(), entHeight) && d1 < d2)
+ if (!this.isHeadspaceFree(blockpos.func_177978_c(), entHeight) && d1 < d2)
{
d2 = d1;
i = 4;
}
- if (this.func_175162_d(blockpos.func_177968_d()) && 1.0D - d1 < d2)
+ if (this.isHeadspaceFree(blockpos.func_177968_d(), entHeight) && 1.0D - d1 < d2)
+ if (!this.isHeadspaceFree(blockpos.func_177968_d(), entHeight) && 1.0D - d1 < d2)
{
d2 = 1.0D - d1;
i = 5;
@@ -415,7 +428,7 @@
private boolean func_175162_d(BlockPos p_175162_1_)
{
- return !this.field_70170_p.func_180495_p(p_175162_1_).func_177230_c().func_149721_r() && !this.field_70170_p.func_180495_p(p_175162_1_.func_177984_a()).func_177230_c().func_149721_r();
+ return !this.field_70170_p.func_180495_p(p_175162_1_).func_177230_c().func_149721_r();
}
public void func_70031_b(boolean p_70031_1_)
@@ -448,6 +461,12 @@
public void func_85030_a(String p_85030_1_, float p_85030_2_, float p_85030_3_)
@@ -1,16 +1,18 @@
--- ../src-base/minecraft/net/minecraft/client/gui/GuiMainMenu.java
+++ ../src-work/minecraft/net/minecraft/client/gui/GuiMainMenu.java
@@ -223,7 +223,8 @@
{
@@ -197,6 +197,11 @@
this.field_146292_n.add(new GuiButton(1, this.field_146294_l / 2 - 100, p_73969_1_, I18n.func_135052_a("menu.singleplayer", new Object[0])));
this.field_146292_n.add(new GuiButton(2, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 1, I18n.func_135052_a("menu.multiplayer", new Object[0])));
- this.field_146292_n.add(this.field_175372_K = new GuiButton(14, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 2, I18n.func_135052_a("menu.online", new Object[0])));
+ this.field_146292_n.add(this.field_175372_K = new GuiButton(14, this.field_146294_l / 2 + 2, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.func_135052_a("menu.online", new Object[0]).replace("Minecraft", "").trim()));
+ this.field_146292_n.add(new GuiButton(6, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 2, 98, 20, I18n.func_135052_a("fml.menu.mods")));
this.field_146292_n.add(this.field_175372_K = new GuiButton(14, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 2, I18n.func_135052_a("menu.online", new Object[0])));
+ GuiButton fmlModButton = new GuiButton(6, this.field_146294_l / 2 - 100, p_73969_1_ + p_73969_2_ * 2, I18n.func_135052_a("fml.menu.mods"));
+ fmlModButton.field_146128_h = this.field_146294_l / 2 + 2;
+ field_175372_K.field_146120_f = 98;
+ fmlModButton.field_146120_f = 98;
+ this.field_146292_n.add(fmlModButton);
}
private void func_73972_b(int p_73972_1_, int p_73972_2_)
@@ -271,6 +272,11 @@
@@ -244,6 +249,11 @@
this.field_146297_k.func_71400_g();
}
@@ -22,7 +24,7 @@
if (p_146284_1_.field_146127_k == 11)
{
this.field_146297_k.func_71371_a("Demo_World", "Demo_World", DemoWorldServer.field_73071_a);
@@ -516,7 +522,16 @@
@@ -489,7 +499,16 @@
s = s + " Demo";
}
@@ -10,22 +10,37 @@
}
protected void func_146279_a(String p_146279_1_, int p_146279_2_, int p_146279_3_)
@@ -153,7 +154,13 @@
@@ -153,6 +154,11 @@
protected void func_146283_a(List<String> p_146283_1_, int p_146283_2_, int p_146283_3_)
{
- if (!p_146283_1_.isEmpty())
+ drawHoveringText(p_146283_1_, p_146283_2_, p_146283_3_, field_146289_q);
+ }
+
+ protected void drawHoveringText(List<String> p_146283_1_, int p_146283_2_, int p_146283_3_, FontRenderer font)
+ {
+ net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(p_146283_1_, p_146283_2_, p_146283_3_, field_146294_l, field_146295_m, -1, font);
+ if (false && !p_146283_1_.isEmpty())
if (!p_146283_1_.isEmpty())
{
GlStateManager.func_179101_C();
RenderHelper.func_74518_a();
@@ -436,6 +443,7 @@
@@ -163,7 +169,7 @@
for (String s : p_146283_1_)
{
- int j = this.field_146289_q.func_78256_a(s);
+ int j = font.func_78256_a(s);
if (j > i)
{
@@ -208,7 +214,7 @@
for (int k1 = 0; k1 < p_146283_1_.size(); ++k1)
{
String s1 = (String)p_146283_1_.get(k1);
- this.field_146289_q.func_175063_a(s1, (float)l1, (float)i2, -1);
+ font.func_175063_a(s1, (float)l1, (float)i2, -1);
if (k1 == 0)
{
@@ -436,6 +442,7 @@
{
this.field_146297_k.field_71456_v.func_146158_b().func_146239_a(p_175281_1_);
}
@@ -33,7 +48,7 @@
this.field_146297_k.field_71439_g.func_71165_d(p_175281_1_);
}
@@ -450,9 +458,15 @@
@@ -450,9 +457,15 @@
if (guibutton.func_146116_c(this.field_146297_k, p_73864_1_, p_73864_2_))
{
@@ -49,7 +64,7 @@
}
}
}
@@ -482,8 +496,12 @@
@@ -482,8 +495,12 @@
this.field_146289_q = p_146280_1_.field_71466_p;
this.field_146294_l = p_146280_2_;
this.field_146295_m = p_146280_3_;
@@ -61,8 +76,8 @@
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent.Post(this, this.field_146292_n));
}
public void func_183500_a(int p_183500_1_, int p_183500_2_)
@@ -502,7 +520,9 @@
public void func_73866_w_()
@@ -496,7 +513,9 @@
{
while (Mouse.next())
{
@@ -72,7 +87,7 @@
}
}
@@ -510,7 +530,9 @@
@@ -504,7 +523,9 @@
{
while (Keyboard.next())
{
@@ -82,11 +97,3 @@
}
}
}
@@ -570,6 +592,7 @@
public void func_146276_q_()
{
this.func_146270_b(0);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.BackgroundDrawnEvent(this));
}
public void func_146270_b(int p_146270_1_)
@@ -1,10 +0,0 @@
--- ../src-base/minecraft/net/minecraft/client/gui/GuiUtilRenderComponents.java
+++ ../src-work/minecraft/net/minecraft/client/gui/GuiUtilRenderComponents.java
@@ -73,6 +73,7 @@
s3 = s4;
}
+ s3 = FontRenderer.func_78282_e(s2) + s3; //Forge: Fix chat formatting not surviving line wrapping.
ChatComponentText chatcomponenttext2 = new ChatComponentText(s3);
chatcomponenttext2.func_150255_a(ichatcomponent1.func_150256_b().func_150232_l());
list1.add(j + 1, chatcomponenttext2);
@@ -30,15 +30,7 @@
this.func_175175_a(i, j, textureatlassprite, 16, 16);
GlStateManager.func_179145_e();
flag1 = true;
@@ -326,6 +328,7 @@
int j = this.field_147003_i;
int k = this.field_147009_r;
boolean flag1 = p_73864_1_ < j || p_73864_2_ < k || p_73864_1_ >= j + this.field_146999_f || p_73864_2_ >= k + this.field_147000_g;
+ if (slot != null) flag1 = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
int l = -1;
if (slot != null)
@@ -463,10 +466,12 @@
@@ -463,6 +465,7 @@
protected void func_146286_b(int p_146286_1_, int p_146286_2_, int p_146286_3_)
{
@@ -46,12 +38,7 @@
Slot slot = this.func_146975_c(p_146286_1_, p_146286_2_);
int i = this.field_147003_i;
int j = this.field_147009_r;
boolean flag = p_146286_1_ < i || p_146286_2_ < j || p_146286_1_ >= i + this.field_146999_f || p_146286_2_ >= j + this.field_147000_g;
+ if (slot != null) flag = false; // Forge, prevent dropping of items through slots outside of GUI boundaries
int k = -1;
if (slot != null)
@@ -685,4 +690,16 @@
@@ -685,4 +688,16 @@
this.field_146297_k.field_71439_g.func_71053_j();
}
}
@@ -1,14 +1,6 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/EntityRenderer.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/EntityRenderer.java
@@ -200,6 +200,7 @@
{
this.func_175069_a(new ResourceLocation("shaders/post/invert.json"));
}
+ else net.minecraftforge.client.ForgeHooksClient.loadEntityShader(p_175066_1_, this);
}
}
@@ -419,7 +420,7 @@
@@ -419,7 +419,7 @@
if (d3 < d2 || d2 == 0.0D)
{
@@ -17,16 +9,7 @@
{
if (d2 == 0.0D)
{
@@ -512,7 +513,7 @@
f = f * 60.0F / 70.0F;
}
- return f;
+ return net.minecraftforge.client.ForgeHooksClient.getFOVModifier(this, entity, block, p_78481_1_, f);
}
}
@@ -576,14 +577,8 @@
@@ -576,14 +576,8 @@
{
BlockPos blockpos = new BlockPos(entity);
IBlockState iblockstate = this.field_78531_r.field_71441_e.func_180495_p(blockpos);
@@ -42,7 +25,7 @@
GlStateManager.func_179114_b(entity.field_70126_B + (entity.field_70177_z - entity.field_70126_B) * p_78467_1_ + 180.0F, 0.0F, -1.0F, 0.0F);
GlStateManager.func_179114_b(entity.field_70127_C + (entity.field_70125_A - entity.field_70127_C) * p_78467_1_, -1.0F, 0.0F, 0.0F);
}
@@ -650,17 +645,20 @@
@@ -650,17 +644,20 @@
if (!this.field_78531_r.field_71474_y.field_74325_U)
{
@@ -70,7 +53,7 @@
}
GlStateManager.func_179109_b(0.0F, -f, 0.0F);
@@ -1103,7 +1101,7 @@
@@ -1103,7 +1100,7 @@
try
{
@@ -79,7 +62,7 @@
}
catch (Throwable throwable)
{
@@ -1164,7 +1162,7 @@
@@ -1164,7 +1161,7 @@
if (this.field_78531_r.field_71442_b.func_178889_l() == WorldSettings.GameType.SPECTATOR)
{
@@ -88,7 +71,7 @@
}
else
{
@@ -1314,7 +1312,9 @@
@@ -1314,7 +1311,9 @@
GlStateManager.func_179094_E();
RenderHelper.func_74519_b();
this.field_78531_r.field_71424_I.func_76318_c("entities");
@@ -98,7 +81,7 @@
RenderHelper.func_74518_a();
this.func_175072_h();
GlStateManager.func_179128_n(5888);
@@ -1326,6 +1326,7 @@
@@ -1326,6 +1325,7 @@
EntityPlayer entityplayer = (EntityPlayer)entity;
GlStateManager.func_179118_c();
this.field_78531_r.field_71424_I.func_76318_c("outline");
@@ -106,7 +89,7 @@
renderglobal.func_72731_b(entityplayer, this.field_78531_r.field_71476_x, 0, p_175068_2_);
GlStateManager.func_179141_d();
}
@@ -1339,6 +1340,7 @@
@@ -1339,6 +1339,7 @@
EntityPlayer entityplayer1 = (EntityPlayer)entity;
GlStateManager.func_179118_c();
this.field_78531_r.field_71424_I.func_76318_c("outline");
@@ -114,7 +97,7 @@
renderglobal.func_72731_b(entityplayer1, this.field_78531_r.field_71476_x, 0, p_175068_2_);
GlStateManager.func_179141_d();
}
@@ -1380,6 +1382,15 @@
@@ -1380,6 +1381,15 @@
GlStateManager.func_179103_j(7425);
this.field_78531_r.field_71424_I.func_76318_c("translucent");
renderglobal.func_174977_a(EnumWorldBlockLayer.TRANSLUCENT, (double)p_175068_2_, p_175068_1_, entity);
@@ -130,7 +113,7 @@
GlStateManager.func_179103_j(7424);
GlStateManager.func_179132_a(true);
GlStateManager.func_179089_o();
@@ -1392,8 +1403,12 @@
@@ -1392,8 +1402,12 @@
this.func_180437_a(renderglobal, p_175068_2_, p_175068_1_);
}
@@ -143,7 +126,7 @@
if (this.field_175074_C)
{
GlStateManager.func_179086_m(256);
@@ -1505,6 +1520,13 @@
@@ -1505,6 +1519,13 @@
protected void func_78474_d(float p_78474_1_)
{
@@ -157,7 +140,7 @@
float f = this.field_78531_r.field_71441_e.func_72867_j(p_78474_1_);
if (f > 0.0F)
@@ -1830,6 +1852,13 @@
@@ -1830,6 +1851,13 @@
this.field_175081_S = f7;
}
@@ -171,7 +154,7 @@
GlStateManager.func_179082_a(this.field_175080_Q, this.field_175082_R, this.field_175081_S, 0.0F);
}
@@ -1848,6 +1877,10 @@
@@ -1848,6 +1876,10 @@
GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F);
Block block = ActiveRenderInfo.func_180786_a(this.field_78531_r.field_71441_e, entity, p_78468_2_);
@@ -182,7 +165,7 @@
if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).func_70644_a(Potion.field_76440_q))
{
float f1 = 5.0F;
@@ -1925,6 +1958,7 @@
@@ -1925,6 +1957,7 @@
GlStateManager.func_179102_b(f * 0.05F);
GlStateManager.func_179153_c(Math.min(f, 192.0F) * 0.5F);
}
@@ -27,7 +27,7 @@
}
+ potion.renderInventoryEffect(i, j, potioneffect, field_146297_k);
+ if (!potion.shouldRenderInvText(potioneffect)) { j += l; continue; }
+ if (!potion.shouldRenderInvText(potioneffect)) continue;
String s1 = I18n.func_135052_a(potion.func_76393_a(), new Object[0]);
if (potioneffect.func_76458_c() == 1)
@@ -56,15 +56,7 @@
flag2 = this.field_175010_j.func_178635_a(entity2, p_180446_2_, d0, d1, d2) || entity2.field_70153_n == this.field_72777_q.field_71439_g;
if (!flag2)
@@ -654,6 +665,7 @@
this.field_72769_h.field_72984_F.func_76318_c("blockentities");
RenderHelper.func_74519_b();
+ TileEntityRendererDispatcher.field_147556_a.preDrawBatch();
for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation1 : this.field_72755_R)
{
List<TileEntity> list1 = renderglobal$containerlocalrenderinformation1.field_178036_a.func_178571_g().func_178485_b();
@@ -662,6 +674,7 @@
@@ -662,6 +673,7 @@
{
for (TileEntity tileentity2 : list1)
{
@@ -72,7 +64,7 @@
TileEntityRendererDispatcher.field_147556_a.func_180546_a(tileentity2, p_180446_3_, -1);
}
}
@@ -671,9 +684,11 @@
@@ -671,6 +683,7 @@
{
for (TileEntity tileentity : this.field_181024_n)
{
@@ -80,11 +72,7 @@
TileEntityRendererDispatcher.field_147556_a.func_180546_a(tileentity, p_180446_3_, -1);
}
}
+ TileEntityRendererDispatcher.field_147556_a.drawBatch(pass);
this.func_180443_s();
@@ -700,7 +715,7 @@
@@ -700,7 +713,7 @@
Block block = this.field_72769_h.func_180495_p(blockpos).func_177230_c();
@@ -93,7 +81,7 @@
{
TileEntityRendererDispatcher.field_147556_a.func_180546_a(tileentity1, p_180446_3_, destroyblockprogress.func_73106_e());
}
@@ -1161,6 +1176,12 @@
@@ -1161,6 +1174,12 @@
public void func_174976_a(float p_174976_1_, int p_174976_2_)
{
@@ -106,7 +94,7 @@
if (this.field_72777_q.field_71441_e.field_73011_w.func_177502_q() == 1)
{
this.func_180448_r();
@@ -1378,6 +1399,12 @@
@@ -1378,6 +1397,12 @@
public void func_180447_b(float p_180447_1_, int p_180447_2_)
{
@@ -119,7 +107,7 @@
if (this.field_72777_q.field_71441_e.field_73011_w.func_76569_d())
{
if (this.field_72777_q.field_71474_y.func_181147_e() == 2)
@@ -1793,8 +1820,11 @@
@@ -1793,8 +1818,11 @@
double d4 = (double)blockpos.func_177956_o() - d1;
double d5 = (double)blockpos.func_177952_p() - d2;
Block block = this.field_72769_h.func_180495_p(blockpos).func_177230_c();
@@ -132,7 +120,7 @@
{
if (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D)
{
@@ -1949,13 +1979,16 @@
@@ -1949,13 +1977,16 @@
if (p_174961_1_ != null)
{
ItemRecord itemrecord = ItemRecord.func_150926_b(p_174961_1_);
@@ -1,28 +1,6 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/WorldRenderer.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/WorldRenderer.java
@@ -506,15 +506,15 @@
break;
case USHORT:
case SHORT:
- this.field_179001_a.putShort(i, (short)((int)p_181663_1_ * 32767 & 65535));
- this.field_179001_a.putShort(i + 2, (short)((int)p_181663_2_ * 32767 & 65535));
- this.field_179001_a.putShort(i + 4, (short)((int)p_181663_3_ * 32767 & 65535));
+ this.field_179001_a.putShort(i, (short)((int)(p_181663_1_ * 32767) & 65535));
+ this.field_179001_a.putShort(i + 2, (short)((int)(p_181663_2_ * 32767) & 65535));
+ this.field_179001_a.putShort(i + 4, (short)((int)(p_181663_3_ * 32767) & 65535));
break;
case UBYTE:
case BYTE:
- this.field_179001_a.put(i, (byte)((int)p_181663_1_ * 127 & 255));
- this.field_179001_a.put(i + 1, (byte)((int)p_181663_2_ * 127 & 255));
- this.field_179001_a.put(i + 2, (byte)((int)p_181663_3_ * 127 & 255));
+ this.field_179001_a.put(i, (byte)((int)(p_181663_1_ * 127) & 255));
+ this.field_179001_a.put(i + 1, (byte)((int)(p_181663_2_ * 127) & 255));
+ this.field_179001_a.put(i + 2, (byte)((int)(p_181663_3_ * 127) & 255));
}
this.func_181667_k();
@@ -578,6 +578,16 @@
@@ -578,6 +578,11 @@
}
}
@@ -30,11 +8,6 @@
+ {
+ this.func_181670_b(field_179011_q.func_177338_f()/* / 4 * 4 */);
+ }
+
+ public boolean isColorDisabled()
+ {
+ return field_78939_q;
+ }
+
@SideOnly(Side.CLIENT)
public class State
@@ -1,17 +1,15 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/chunk/RenderChunk.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/chunk/RenderChunk.java
@@ -131,7 +131,9 @@
@@ -131,7 +131,7 @@
return;
}
- iblockaccess = new RegionRenderCache(this.field_178588_d, blockpos.func_177982_a(-1, -1, -1), blockpos1.func_177982_a(1, 1, 1), 1);
+ RegionRenderCache cache = createRegionRenderCache(this.field_178588_d, blockpos.func_177982_a(-1, -1, -1), blockpos1.func_177982_a(1, 1, 1), 1);
+ net.minecraftforge.client.MinecraftForgeClient.onRebuildChunk(field_178588_d, field_178586_f, cache);
+ iblockaccess = cache;
+ iblockaccess = createRegionRenderCache(this.field_178588_d, blockpos.func_177982_a(-1, -1, -1), blockpos1.func_177982_a(1, 1, 1), 1);
p_178581_4_.func_178543_a(compiledchunk);
}
finally
@@ -158,7 +160,7 @@
@@ -158,7 +158,7 @@
lvt_10_1_.func_178606_a(blockpos$mutableblockpos);
}
@@ -20,7 +18,7 @@
{
TileEntity tileentity = iblockaccess.func_175625_s(new BlockPos(blockpos$mutableblockpos));
TileEntitySpecialRenderer<TileEntity> tileentityspecialrenderer = TileEntityRendererDispatcher.field_147556_a.<TileEntity>func_147547_b(tileentity);
@@ -174,7 +176,9 @@
@@ -174,7 +174,9 @@
}
}
@@ -31,7 +29,7 @@
int j = enumworldblocklayer1.ordinal();
if (block.func_149645_b() != -1)
@@ -189,6 +193,7 @@
@@ -189,6 +191,7 @@
aboolean[j] |= blockrendererdispatcher.func_175018_a(iblockstate, blockpos$mutableblockpos, iblockaccess, worldrenderer);
}
@@ -39,7 +37,7 @@
}
for (EnumWorldBlockLayer enumworldblocklayer : EnumWorldBlockLayer.values())
@@ -385,6 +390,26 @@
@@ -385,6 +388,26 @@
return this.field_178593_n;
}
@@ -9,44 +9,7 @@
float f2 = p_177077_9_.func_177552_f().func_181688_b(ItemCameraTransforms.TransformType.GROUND).field_178363_d.y;
GlStateManager.func_179109_b((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_);
@@ -110,7 +110,6 @@
for (int j = 0; j < i; ++j)
{
- if (ibakedmodel.func_177556_c())
{
GlStateManager.func_179094_E();
@@ -119,25 +118,15 @@
float f = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F;
float f1 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F;
float f2 = (this.field_177079_e.nextFloat() * 2.0F - 1.0F) * 0.15F;
- GlStateManager.func_179109_b(f, f1, f2);
+ GlStateManager.func_179109_b(shouldSpreadItems() ? f : 0.0F, shouldSpreadItems() ? f1 : 0.0F, f2);
}
+ if (ibakedmodel.func_177556_c())
GlStateManager.func_179152_a(0.5F, 0.5F, 0.5F);
- ibakedmodel.func_177552_f().func_181689_a(ItemCameraTransforms.TransformType.GROUND);
+ ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GROUND);
this.field_177080_a.func_180454_a(itemstack, ibakedmodel);
GlStateManager.func_179121_F();
}
- else
- {
- GlStateManager.func_179094_E();
- ibakedmodel.func_177552_f().func_181689_a(ItemCameraTransforms.TransformType.GROUND);
- this.field_177080_a.func_180454_a(itemstack, ibakedmodel);
- GlStateManager.func_179121_F();
- float f3 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.x;
- float f4 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.y;
- float f5 = ibakedmodel.func_177552_f().field_181699_o.field_178363_d.z;
- GlStateManager.func_179109_b(0.0F * f3, 0.0F * f4, 0.046875F * f5);
- }
}
GlStateManager.func_179121_F();
@@ -157,4 +146,25 @@
@@ -157,4 +157,25 @@
{
return TextureMap.field_110575_b;
}
@@ -1,10 +1,8 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderManager.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderManager.java
@@ -192,7 +192,12 @@
this.field_178637_m = new RenderPlayer(this);
@@ -193,6 +193,10 @@
this.field_178636_l.put("default", this.field_178637_m);
this.field_178636_l.put("slim", new RenderPlayer(this, true));
+ net.minecraftforge.fml.client.registry.RenderingRegistry.loadEntityRenderers(this, this.field_78729_o);
}
+
+ public Map<String, RenderPlayer> getSkinMap() {
@@ -13,7 +11,7 @@
public void func_178628_a(double p_178628_1_, double p_178628_3_, double p_178628_5_)
{
@@ -241,9 +246,9 @@
@@ -241,9 +245,9 @@
IBlockState iblockstate = p_180597_1_.func_180495_p(new BlockPos(p_180597_3_));
Block block = iblockstate.func_177230_c();
@@ -10,7 +10,7 @@
public RendererLivingEntity(RenderManager p_i46156_1_, ModelBase p_i46156_2_, float p_i46156_3_)
{
super(p_i46156_1_);
@@ -83,10 +86,12 @@
@@ -83,6 +86,7 @@
public void func_76986_a(T p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
{
@@ -18,22 +18,7 @@
GlStateManager.func_179094_E();
GlStateManager.func_179129_p();
this.field_77045_g.field_78095_p = this.func_77040_d(p_76986_1_, p_76986_9_);
- this.field_77045_g.field_78093_q = p_76986_1_.func_70115_ae();
+ boolean shouldSit = p_76986_1_.func_70115_ae() && (p_76986_1_.field_70154_o != null && p_76986_1_.field_70154_o.shouldRiderSit());
+ this.field_77045_g.field_78093_q = shouldSit;
this.field_77045_g.field_78091_s = p_76986_1_.func_70631_g_();
try
@@ -95,7 +100,7 @@
float f1 = this.func_77034_a(p_76986_1_.field_70758_at, p_76986_1_.field_70759_as, p_76986_9_);
float f2 = f1 - f;
- if (p_76986_1_.func_70115_ae() && p_76986_1_.field_70154_o instanceof EntityLivingBase)
+ if (shouldSit && p_76986_1_.field_70154_o instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)p_76986_1_.field_70154_o;
f = this.func_77034_a(entitylivingbase.field_70760_ar, entitylivingbase.field_70761_aq, p_76986_9_);
@@ -191,6 +196,7 @@
@@ -191,6 +195,7 @@
{
super.func_76986_a(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
}
@@ -41,7 +26,7 @@
}
protected boolean func_177088_c(T p_177088_1_)
@@ -469,10 +475,11 @@
@@ -469,10 +474,11 @@
public void func_177067_a(T p_177067_1_, double p_177067_2_, double p_177067_4_, double p_177067_6_)
{
@@ -54,7 +39,7 @@
if (d0 < (double)(f * f))
{
@@ -518,6 +525,7 @@
@@ -518,6 +524,7 @@
}
}
}
@@ -1,15 +0,0 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/tileentity/TileEntityPistonRenderer.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/tileentity/TileEntityPistonRenderer.java
@@ -23,10 +23,11 @@
@SideOnly(Side.CLIENT)
public class TileEntityPistonRenderer extends TileEntitySpecialRenderer<TileEntityPiston>
{
- private final BlockRendererDispatcher field_178462_c = Minecraft.func_71410_x().func_175602_ab();
+ private BlockRendererDispatcher field_178462_c;
public void func_180535_a(TileEntityPiston p_180535_1_, double p_180535_2_, double p_180535_4_, double p_180535_6_, float p_180535_8_, int p_180535_9_)
{
+ if(field_178462_c == null) field_178462_c = Minecraft.func_71410_x().func_175602_ab();
BlockPos blockpos = p_180535_1_.func_174877_v();
IBlockState iblockstate = p_180535_1_.func_174927_b();
Block block = iblockstate.func_177230_c();
@@ -1,79 +0,0 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/tileentity/TileEntityRendererDispatcher.java
@@ -102,11 +102,14 @@
{
if (p_180546_1_.func_145835_a(this.field_147560_j, this.field_147561_k, this.field_147558_l) < p_180546_1_.func_145833_n())
{
+ if(!p_180546_1_.hasFastRenderer())
+ {
int i = this.field_147550_f.func_175626_b(p_180546_1_.func_174877_v(), 0);
int j = i % 65536;
int k = i / 65536;
OpenGlHelper.func_77475_a(OpenGlHelper.field_77476_b, (float)j / 1.0F, (float)k / 1.0F);
GlStateManager.func_179131_c(1.0F, 1.0F, 1.0F, 1.0F);
+ }
BlockPos blockpos = p_180546_1_.func_174877_v();
this.func_178469_a(p_180546_1_, (double)blockpos.func_177958_n() - field_147554_b, (double)blockpos.func_177956_o() - field_147555_c, (double)blockpos.func_177952_p() - field_147552_d, p_180546_2_, p_180546_3_);
}
@@ -125,6 +128,11 @@
{
try
{
+ if(p_178469_1_.hasFastRenderer())
+ {
+ tileentityspecialrenderer.renderTileEntityFast(p_178469_1_, p_178469_2_, p_178469_4_, p_178469_6_, p_178469_8_, p_178469_9_, batchBuffer.func_178180_c());
+ }
+ else
tileentityspecialrenderer.func_180535_a(p_178469_1_, p_178469_2_, p_178469_4_, p_178469_6_, p_178469_8_, p_178469_9_);
}
catch (Throwable throwable)
@@ -146,4 +154,49 @@
{
return this.field_147557_n;
}
+
+ /* ======================================== FORGE START =====================================*/
+ /**
+ * Buffer used for batched TESRs
+ */
+ private net.minecraft.client.renderer.Tessellator batchBuffer = new net.minecraft.client.renderer.Tessellator(0x200000);
+
+ /**
+ * Prepare for a batched TESR rendering.
+ * You probably shouldn't call this manually.
+ */
+ public void preDrawBatch()
+ {
+ batchBuffer.func_178180_c().func_181668_a(org.lwjgl.opengl.GL11.GL_QUADS, net.minecraft.client.renderer.vertex.DefaultVertexFormats.field_176600_a);
+ }
+
+ /**
+ * Render all TESRs batched so far.
+ * You probably shouldn't call this manually.
+ */
+ public void drawBatch(int pass)
+ {
+ field_147553_e.func_110577_a(net.minecraft.client.renderer.texture.TextureMap.field_110575_b);
+ net.minecraft.client.renderer.RenderHelper.func_74518_a();
+ GlStateManager.func_179112_b(org.lwjgl.opengl.GL11.GL_SRC_ALPHA, org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GlStateManager.func_179147_l();
+ GlStateManager.func_179129_p();
+
+ if (net.minecraft.client.Minecraft.func_71379_u())
+ {
+ GlStateManager.func_179103_j(org.lwjgl.opengl.GL11.GL_SMOOTH);
+ }
+ else
+ {
+ GlStateManager.func_179103_j(org.lwjgl.opengl.GL11.GL_FLAT);
+ }
+
+ if(pass > 0)
+ {
+ batchBuffer.func_178180_c().func_181674_a((float)field_147554_b, (float)field_147555_c, (float)field_147552_d);
+ }
+ batchBuffer.func_78381_a();
+
+ net.minecraft.client.renderer.RenderHelper.func_74519_b();
+ }
}
@@ -1,9 +0,0 @@
--- ../src-base/minecraft/net/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer.java
+++ ../src-work/minecraft/net/minecraft/client/renderer/tileentity/TileEntitySpecialRenderer.java
@@ -45,4 +45,6 @@
{
return false;
}
+
+ public void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, net.minecraft.client.renderer.WorldRenderer worldRenderer) {}
}
@@ -9,7 +9,15 @@
}
}
catch (Exception exception)
@@ -294,6 +294,7 @@
@@ -160,6 +160,7 @@
}
}
}
+ catch (FileNotFoundException e) {}
catch (IOException ioexception)
{
throw new RuntimeException("Encountered an exception when loading model definition of model " + resourcelocation.toString(), ioexception);
@@ -294,6 +295,7 @@
protected void func_177592_e()
{
@@ -17,7 +25,7 @@
this.field_177613_u.put(Item.func_150898_a(Blocks.field_150348_b), Lists.newArrayList(new String[] {"stone", "granite", "granite_smooth", "diorite", "diorite_smooth", "andesite", "andesite_smooth"}));
this.field_177613_u.put(Item.func_150898_a(Blocks.field_150346_d), Lists.newArrayList(new String[] {"dirt", "coarse_dirt", "podzol"}));
this.field_177613_u.put(Item.func_150898_a(Blocks.field_150344_f), Lists.newArrayList(new String[] {"oak_planks", "spruce_planks", "birch_planks", "jungle_planks", "acacia_planks", "dark_oak_planks"}));
@@ -336,6 +337,10 @@
@@ -336,6 +338,10 @@
this.field_177613_u.put(Item.func_150898_a(Blocks.field_180390_bo), Lists.newArrayList(new String[] {"oak_fence_gate"}));
this.field_177613_u.put(Item.func_150898_a(Blocks.field_180407_aO), Lists.newArrayList(new String[] {"oak_fence"}));
this.field_177613_u.put(Items.field_179570_aq, Lists.newArrayList(new String[] {"oak_door"}));
@@ -28,7 +36,7 @@
}
protected List<String> func_177596_a(Item p_177596_1_)
@@ -352,7 +357,7 @@
@@ -352,7 +358,7 @@
protected ResourceLocation func_177583_a(String p_177583_1_)
{
@@ -37,7 +45,7 @@
return new ResourceLocation(resourcelocation.func_110624_b(), "item/" + resourcelocation.func_110623_a());
}
@@ -395,7 +400,7 @@
@@ -395,7 +401,7 @@
for (Entry<String, ResourceLocation> entry : this.field_177615_s.entrySet())
{
ResourceLocation resourcelocation = (ResourceLocation)entry.getValue();
@@ -46,7 +54,7 @@
ModelBlock modelblock1 = (ModelBlock)this.field_177611_h.get(resourcelocation);
if (modelblock1 != null && modelblock1.func_178303_d())
@@ -453,6 +458,11 @@
@@ -453,6 +459,11 @@
private IBakedModel func_177578_a(ModelBlock p_177578_1_, ModelRotation p_177578_2_, boolean p_177578_3_)
{
@@ -58,7 +66,7 @@
TextureAtlasSprite textureatlassprite = (TextureAtlasSprite)this.field_177599_g.get(new ResourceLocation(p_177578_1_.func_178308_c("particle")));
SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(p_177578_1_)).func_177646_a(textureatlassprite);
@@ -463,13 +473,13 @@
@@ -463,13 +474,13 @@
BlockPartFace blockpartface = (BlockPartFace)blockpart.field_178240_c.get(enumfacing);
TextureAtlasSprite textureatlassprite1 = (TextureAtlasSprite)this.field_177599_g.get(new ResourceLocation(p_177578_1_.func_178308_c(blockpartface.field_178242_d)));
@@ -75,7 +83,7 @@
}
}
}
@@ -479,9 +489,14 @@
@@ -479,9 +490,14 @@
private BakedQuad func_177589_a(BlockPart p_177589_1_, BlockPartFace p_177589_2_, TextureAtlasSprite p_177589_3_, EnumFacing p_177589_4_, ModelRotation p_177589_5_, boolean p_177589_6_)
{
@@ -91,7 +99,7 @@
private void func_177597_h()
{
this.func_177574_i();
@@ -722,4 +737,35 @@
@@ -722,4 +738,35 @@
field_177617_q.field_178317_b = "class generation marker";
field_177616_r.field_178317_b = "block entity marker";
}
@@ -1,6 +1,6 @@
--- ../src-base/minecraft/net/minecraft/client/settings/GameSettings.java
+++ ../src-work/minecraft/net/minecraft/client/settings/GameSettings.java
@@ -994,6 +994,7 @@
@@ -981,6 +981,7 @@
public void func_74303_b()
{
@@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/command/CommandBase.java
+++ ../src-work/minecraft/net/minecraft/command/CommandBase.java
@@ -329,7 +329,7 @@
ichatcomponent.func_150258_a(" ");
}
- IChatComponent ichatcomponent1 = new ChatComponentText(p_147176_1_[i]);
+ IChatComponent ichatcomponent1 = net.minecraftforge.common.ForgeHooks.newChatWithLinks(p_147176_1_[i]); // Forge: links for messages
if (p_147176_3_)
{
@@ -17,12 +17,3 @@
if (i > -1)
{
List<Entity> list = PlayerSelector.<Entity>func_179656_b(p_71556_1_, astring[i], Entity.class);
@@ -107,7 +117,7 @@
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.generic.exception", new Object[0]);
chatcomponenttranslation.func_150256_b().func_150238_a(EnumChatFormatting.RED);
p_175786_1_.func_145747_a(chatcomponenttranslation);
- field_147175_a.warn("Couldn\'t process command: \'" + p_175786_4_ + "\'");
+ field_147175_a.warn("Couldn\'t process command: \'" + p_175786_4_ + "\'", var9); // Forge: Log stacktrace of unknown exceptions
}
return false;
@@ -1,15 +1,6 @@
--- ../src-base/minecraft/net/minecraft/entity/Entity.java
+++ ../src-work/minecraft/net/minecraft/entity/Entity.java
@@ -49,7 +49,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
-public abstract class Entity implements ICommandSender
+public abstract class Entity implements ICommandSender, net.minecraftforge.common.capabilities.ICapabilitySerializable<NBTTagCompound>
{
private static final AxisAlignedBB field_174836_a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
private static int field_70152_a;
@@ -129,6 +129,15 @@
@@ -129,6 +129,14 @@
protected UUID field_96093_i;
private final CommandResultStats field_174837_as;
@@ -17,31 +8,24 @@
+ private NBTTagCompound customEntityData;
+ public boolean captureDrops = false;
+ public java.util.ArrayList<EntityItem> capturedDrops = new java.util.ArrayList<EntityItem>();
+ private UUID persistentID;
+
+ @Deprecated //ToDo: Move to Capabilities?
+ protected java.util.HashMap<String, net.minecraftforge.common.IExtendedEntityProperties> extendedProperties = new java.util.HashMap<String, net.minecraftforge.common.IExtendedEntityProperties>();
+ private net.minecraftforge.common.capabilities.CapabilityDispatcher capabilities;
+
public int func_145782_y()
{
return this.field_145783_c;
@@ -172,6 +181,9 @@
@@ -172,6 +180,8 @@
this.field_70180_af.func_75682_a(2, "");
this.field_70180_af.func_75682_a(4, Byte.valueOf((byte)0));
this.func_70088_a();
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityEvent.EntityConstructing(this));
+ for (net.minecraftforge.common.IExtendedEntityProperties props : extendedProperties.values()) props.init(this, p_i1582_1_);
+ capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this);
}
protected abstract void func_70088_a();
@@ -996,12 +1008,12 @@
IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos);
Block block = iblockstate.func_177230_c();
@@ -998,10 +1008,7 @@
+ Boolean result = block.isEntityInsideMaterial(this.field_70170_p, blockpos, iblockstate, this, d0, p_70055_1_, true);
+ if (result != null) return result;
+
if (block.func_149688_o() == p_70055_1_)
{
- float f = BlockLiquid.func_149801_b(iblockstate.func_177230_c().func_176201_c(iblockstate)) - 0.11111111F;
@@ -52,7 +36,7 @@
}
else
{
@@ -1356,6 +1368,23 @@
@@ -1356,6 +1363,21 @@
p_70109_1_.func_74757_a("Silent", this.func_174814_R());
}
@@ -70,13 +54,11 @@
+ t.printStackTrace();
+ }
+ }
+
+ if (this.capabilities != null) p_70109_1_.func_74782_a("ForgeCaps", this.capabilities.serializeNBT());
+
this.func_70014_b(p_70109_1_);
if (this.field_70154_o != null)
@@ -1438,6 +1467,30 @@
@@ -1438,6 +1460,28 @@
this.func_174805_g(p_70020_1_.func_74767_n("CustomNameVisible"));
this.field_174837_as.func_179668_a(p_70020_1_);
this.func_174810_b(p_70020_1_.func_74767_n("Silent"));
@@ -96,18 +78,16 @@
+ }
+ }
+
+ //Rawr, legacy code, Vanilla added a UUID, keep this so older maps will convert properly TODO: Remove in 1.9
+ //Rawr, legacy code, Vanilla added a UUID, keep this so older maps will convert properly
+ if (p_70020_1_.func_74764_b("PersistentIDMSB") && p_70020_1_.func_74764_b("PersistentIDLSB"))
+ {
+ this.field_96093_i = new UUID(p_70020_1_.func_74763_f("PersistentIDMSB"), p_70020_1_.func_74763_f("PersistentIDLSB"));
+ }
+
+ if (this.capabilities != null && p_70020_1_.func_74764_b("ForgeCaps")) this.capabilities.deserializeNBT(p_70020_1_.func_74775_l("ForgeCaps"));
+
this.func_70037_a(p_70020_1_);
if (this.func_142008_O())
@@ -1512,7 +1565,10 @@
@@ -1512,7 +1556,10 @@
{
EntityItem entityitem = new EntityItem(this.field_70170_p, this.field_70165_t, this.field_70163_u + (double)p_70099_2_, this.field_70161_v, p_70099_1_);
entityitem.func_174869_p();
@@ -119,7 +99,7 @@
return entityitem;
}
else
@@ -1655,6 +1711,7 @@
@@ -1655,6 +1702,7 @@
public void func_70078_a(Entity p_70078_1_)
{
@@ -127,15 +107,16 @@
this.field_70149_e = 0.0D;
this.field_70147_f = 0.0D;
@@ -2049,6 +2106,7 @@
@@ -1789,7 +1837,7 @@
public boolean func_70115_ae()
{
if (!this.field_70170_p.field_72995_K && !this.field_70128_L)
{
+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_71027_1_)) return;
this.field_70170_p.field_72984_F.func_76320_a("changeDimension");
MinecraftServer minecraftserver = MinecraftServer.func_71276_C();
int i = this.field_71093_bK;
@@ -2092,7 +2150,7 @@
- return this.field_70154_o != null;
+ return this.field_70154_o != null && field_70154_o.shouldRiderSit();
}
public boolean func_70093_af()
@@ -2092,7 +2140,7 @@
public float func_180428_a(Explosion p_180428_1_, World p_180428_2_, BlockPos p_180428_3_, IBlockState p_180428_4_)
{
@@ -144,7 +125,7 @@
}
public boolean func_174816_a(Explosion p_174816_1_, World p_174816_2_, BlockPos p_174816_3_, IBlockState p_174816_4_, float p_174816_5_)
@@ -2353,4 +2411,209 @@
@@ -2353,4 +2401,184 @@
EnchantmentHelper.func_151385_b(p_174815_1_, p_174815_2_);
}
@@ -327,30 +308,5 @@
+ {
+ return this instanceof EntityLivingBase;
+ }
+
+ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability<?> capability, net.minecraft.util.EnumFacing facing)
+ {
+ if (getCapability(capability, facing) != null)
+ return true;
+ return capabilities == null ? false : capabilities.hasCapability(capability, facing);
+ }
+
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ {
+ return capabilities == null ? null : capabilities.getCapability(capability, facing);
+ }
+
+ public void deserializeNBT(NBTTagCompound nbt)
+ {
+ this.func_70020_e(nbt);
+ }
+
+ public NBTTagCompound serializeNBT()
+ {
+ NBTTagCompound ret = new NBTTagCompound();
+ ret.func_74778_a("id", this.func_70022_Q());
+ this.func_70109_d(ret);
+ return ret;
+ }
+ /* ================================== Forge End =====================================*/
}
@@ -18,7 +18,7 @@
+ if (--this.field_75445_i <= 0)
+ {
+ this.field_75438_g = this.field_75441_b.func_70661_as().func_75494_a(entitylivingbase);
+ this.field_75445_i = 4 + this.field_75441_b.func_70681_au().nextInt(7);
+ this.field_151497_i = 4 + this.field_75441_b.func_70681_au().nextInt(7);
+ return this.field_75438_g != null;
+ }
+ else
@@ -35,7 +35,7 @@
+ if (this.canPenalize)
+ {
+ this.field_75445_i += failedPathFindingPenalty;
+ this.field_151497_i += failedPathFindingPenalty;
+ if (this.field_75441_b.func_70661_as().func_75505_d() != null)
+ {
+ net.minecraft.pathfinding.PathPoint finalPathPoint = this.field_75441_b.func_70661_as().func_75505_d().func_75870_c();
@@ -92,23 +92,3 @@
if (!this.func_174814_R())
{
this.field_70170_p.func_72956_a(p_70100_1_, "random.pop", 0.2F, ((this.field_70146_Z.nextFloat() - this.field_70146_Z.nextFloat()) * 0.7F + 1.0F) * 2.0F);
@@ -402,11 +423,6 @@
if (itemstack == null)
{
- if (this.field_70170_p != null)
- {
- field_145803_d.error("Item entity " + this.func_145782_y() + " has no item?!");
- }
-
return new ItemStack(Blocks.field_150348_b);
}
else
@@ -480,6 +496,6 @@
public void func_174870_v()
{
this.func_174871_r();
- this.field_70292_b = 5999;
+ this.field_70292_b = func_92059_d().func_77973_b().getEntityLifespan(func_92059_d(), field_70170_p) - 1;
}
}
@@ -117,9 +117,8 @@
}
- double d0 = 0.0078125D;
- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)p_180460_2_.func_177229_b(blockrailbase.func_176560_l());
+ double slopeAdjustment = getSlopeAdjustment();
+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = blockrailbase.getRailDirection(field_70170_p, p_180460_1_, p_180460_2_, this);
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)p_180460_2_.func_177229_b(blockrailbase.func_176560_l());
switch (blockrailbase$enumraildirection)
{
@@ -191,24 +190,6 @@
double d15 = Math.sqrt(this.field_70159_w * this.field_70159_w + this.field_70179_y * this.field_70179_y);
if (d15 > 0.01D)
@@ -654,7 +679,7 @@
if (BlockRailBase.func_176563_d(iblockstate))
{
- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)iblockstate.func_177229_b(((BlockRailBase)iblockstate.func_177230_c()).func_176560_l());
+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = ((BlockRailBase)iblockstate.func_177230_c()).getRailDirection(field_70170_p, new BlockPos(i, j, k), iblockstate, this);
p_70495_3_ = (double)j;
if (blockrailbase$enumraildirection.func_177018_c())
@@ -703,7 +728,7 @@
if (BlockRailBase.func_176563_d(iblockstate))
{
- BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = (BlockRailBase.EnumRailDirection)iblockstate.func_177229_b(((BlockRailBase)iblockstate.func_177230_c()).func_176560_l());
+ BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = ((BlockRailBase)iblockstate.func_177230_c()).getRailDirection(field_70170_p, new BlockPos(i, j, k), iblockstate, this);
int[][] aint = field_70500_g[blockrailbase$enumraildirection.func_177015_a()];
double d0 = 0.0D;
double d1 = (double)i + 0.5D + (double)aint[0][0] * 0.5D;
@@ -817,13 +842,20 @@
public void func_70108_f(Entity p_70108_1_)
@@ -8,26 +8,3 @@
if (!this.field_70170_p.field_72995_K)
{
p_130002_1_.func_71007_a(this);
@@ -232,4 +233,22 @@
this.field_94113_a[i] = null;
}
}
+
+ public net.minecraftforge.items.IItemHandler itemHandler = new net.minecraftforge.items.wrapper.InvWrapper(this);
+
+ @Override
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ {
+ if (capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
+ {
+ return (T) itemHandler;
+ }
+ return super.getCapability(capability, facing);
+ }
+
+ @Override
+ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability<?> capability, net.minecraft.util.EnumFacing facing)
+ {
+ return capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
+ }
}
@@ -296,12 +296,9 @@
if (!this.field_70170_p.field_72995_K)
{
if (this.func_70608_bn() || !this.func_70089_S())
@@ -1350,9 +1438,9 @@
@@ -1352,7 +1440,7 @@
this.func_70105_a(0.2F, 0.2F);
- if (this.field_70170_p.func_175667_e(p_180469_1_))
+ if (this.field_70170_p.func_175667_e(p_180469_1_) && field_70170_p.func_180495_p(p_180469_1_).func_177230_c().isBed(field_70170_p, p_180469_1_, this))
if (this.field_70170_p.func_175667_e(p_180469_1_))
{
- EnumFacing enumfacing = (EnumFacing)this.field_70170_p.func_180495_p(p_180469_1_).func_177229_b(BlockDirectional.field_176387_N);
+ EnumFacing enumfacing = this.field_70170_p.func_180495_p(p_180469_1_).func_177230_c().getBedDirection(field_70170_p, p_180469_1_);
@@ -326,23 +323,12 @@
if (blockpos == null)
{
@@ -1430,6 +1519,10 @@
this.func_70107_b((double)((float)blockpos.func_177958_n() + 0.5F), (double)((float)blockpos.func_177956_o() + 0.1F), (double)((float)blockpos.func_177952_p() + 0.5F));
}
+ else
+ {
+ p_70999_3_ = false;
+ }
this.field_71083_bS = false;
@@ -1448,14 +1541,14 @@
@@ -1448,14 +1537,14 @@
private boolean func_175143_p()
{
- return this.field_70170_p.func_180495_p(this.field_71081_bT).func_177230_c() == Blocks.field_150324_C;
+ return net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, field_71081_bT);
+ return this.field_70170_p.func_180495_p(this.field_71081_bT).func_177230_c().isBed(field_70170_p, field_71081_bT, this);
}
public static BlockPos func_180467_a(World p_180467_0_, BlockPos p_180467_1_, boolean p_180467_2_)
@@ -354,7 +340,7 @@
{
if (!p_180467_2_)
{
@@ -1470,16 +1563,16 @@
@@ -1470,7 +1559,7 @@
}
else
{
@@ -363,18 +349,16 @@
}
}
@SideOnly(Side.CLIENT)
public float func_71051_bG()
@@ -1479,7 +1568,7 @@
{
- if (this.field_71081_bT != null)
+ if (this.field_71081_bT != null && field_70170_p.func_180495_p(field_71081_bT).func_177230_c().isBed(field_70170_p, field_71081_bT, this))
if (this.field_71081_bT != null)
{
- EnumFacing enumfacing = (EnumFacing)this.field_70170_p.func_180495_p(this.field_71081_bT).func_177229_b(BlockDirectional.field_176387_N);
+ EnumFacing enumfacing = this.field_70170_p.func_180495_p(this.field_71081_bT).func_177230_c().getBedDirection(field_70170_p, field_71081_bT);
switch (enumfacing)
{
@@ -1519,16 +1612,24 @@
@@ -1519,16 +1608,24 @@
public BlockPos func_180470_cg()
{
@@ -401,7 +385,7 @@
if (p_180473_1_ != null)
{
this.field_71077_c = p_180473_1_;
@@ -1712,6 +1813,10 @@
@@ -1712,6 +1809,10 @@
super.func_180430_e(p_180430_1_, p_180430_2_);
}
@@ -412,7 +396,7 @@
}
protected void func_71061_d_()
@@ -1735,6 +1840,7 @@
@@ -1735,6 +1836,7 @@
}
EntityList.EntityEggInfo entitylist$entityegginfo = (EntityList.EntityEggInfo)EntityList.field_75627_a.get(Integer.valueOf(EntityList.func_75619_a(p_70074_1_)));
@@ -420,7 +404,7 @@
if (entitylist$entityegginfo != null)
{
@@ -1847,6 +1953,8 @@
@@ -1847,6 +1949,8 @@
{
if (p_71008_1_ != this.field_71074_e)
{
@@ -429,7 +413,7 @@
this.field_71074_e = p_71008_1_;
this.field_71072_f = p_71008_2_;
@@ -1918,6 +2026,10 @@
@@ -1918,6 +2022,10 @@
this.field_181016_an = p_71049_1_.field_181016_an;
this.field_181017_ao = p_71049_1_.field_181017_ao;
this.field_181018_ap = p_71049_1_.field_181018_ap;
@@ -440,7 +424,7 @@
}
else if (this.field_70170_p.func_82736_K().func_82766_b("keepInventory"))
{
@@ -1931,6 +2043,18 @@
@@ -1931,6 +2039,18 @@
this.field_175152_f = p_71049_1_.field_175152_f;
this.field_71078_a = p_71049_1_.field_71078_a;
this.func_70096_w().func_75692_b(10, Byte.valueOf(p_71049_1_.func_70096_w().func_75683_a(10)));
@@ -459,7 +443,7 @@
}
protected boolean func_70041_e_()
@@ -1968,7 +2092,14 @@
@@ -1968,7 +2088,14 @@
public void func_70062_b(int p_70062_1_, ItemStack p_70062_2_)
{
@@ -475,7 +459,7 @@
}
@SideOnly(Side.CLIENT)
@@ -2013,7 +2144,10 @@
@@ -2013,7 +2140,10 @@
public IChatComponent func_145748_c_()
{
@@ -487,7 +471,7 @@
ichatcomponent.func_150256_b().func_150241_a(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.func_70005_c_() + " "));
ichatcomponent.func_150256_b().func_150209_a(this.func_174823_aP());
ichatcomponent.func_150256_b().func_179989_a(this.func_70005_c_());
@@ -2022,7 +2156,7 @@
@@ -2022,7 +2152,7 @@
public float func_70047_e()
{
@@ -496,7 +480,7 @@
if (this.func_70608_bn())
{
@@ -2155,6 +2289,136 @@
@@ -2155,6 +2285,136 @@
this.field_175153_bG = p_175150_1_;
}
@@ -72,15 +72,7 @@
if (entitylist$entityegginfo != null)
{
@@ -528,6 +545,7 @@
public void func_71027_c(int p_71027_1_)
{
+ if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension(this, p_71027_1_)) return;
if (this.field_71093_bK == 1 && p_71027_1_ == 1)
{
this.func_71029_a(AchievementList.field_76003_C);
@@ -831,6 +849,7 @@
@@ -831,6 +848,7 @@
{
if (p_71064_1_ != null)
{
@@ -1,21 +1,6 @@
--- ../src-base/minecraft/net/minecraft/entity/player/InventoryPlayer.java
+++ ../src-work/minecraft/net/minecraft/entity/player/InventoryPlayer.java
@@ -272,12 +272,8 @@
{
if (this.field_70462_a[j] == null)
{
- this.field_70462_a[j] = new ItemStack(item, 0, p_70452_1_.func_77960_j());
-
- if (p_70452_1_.func_77942_o())
- {
- this.field_70462_a[j].func_77982_d((NBTTagCompound)p_70452_1_.func_77978_p().func_74737_b());
- }
+ this.field_70462_a[j] = p_70452_1_.func_77946_l(); // Forge: Replace Item clone above to preserve item capabilities when picking the item up.
+ this.field_70462_a[j].field_77994_a = 0;
}
int k = i;
@@ -315,6 +311,14 @@
@@ -315,6 +315,14 @@
this.field_70462_a[i].func_77945_a(this.field_70458_d.field_70170_p, this.field_70458_d, i, this.field_70461_c == i);
}
}
@@ -57,7 +57,7 @@
Vec3 vec31 = vec3.func_72441_c((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
return p_77621_1_.func_147447_a(vec3, vec31, p_77621_3_, !p_77621_3_, false);
}
@@ -371,11 +380,670 @@
@@ -371,11 +380,591 @@
return false;
}
@@ -91,16 +91,16 @@
+ }
+
+ /**
+ * Allow the item one last chance to modify its name used for the
+ * Allow the item one last chance to modify its name used for the
+ * tool highlight useful for adding something extra that can't be removed
+ * by a user in the displayed name, such as a mode of operation.
+ *
+ *
+ * @param item the ItemStack for the item.
+ * @param the name that will be displayed unless it is changed in this method.
+ */
+ public String getHighlightTip( ItemStack item, String displayName )
+ {
+ return displayName;
+ return displayName;
+ }
+
+ /**
@@ -427,29 +427,18 @@
+ }
+
+ /**
+ * @deprecated Use 4-argument version.
+ */
+ // remove 1.9
+ @SideOnly(Side.CLIENT)
+ @Deprecated
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
+ {
+ return null;
+ }
+
+ /**
+ * Override this method to have an item handle its own armor rendering.
+ *
+ * @param entityLiving The entity wearing the armor
+ * @param itemStack The itemStack to render the model of
+ * @param armorSlot 0=head, 1=torso, 2=legs, 3=feet
+ * @param _default Original armor model. Will have attributes set.
+ *
+ * @return A ModelBiped to render instead of the default
+ */
+ @SideOnly(Side.CLIENT)
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot, net.minecraft.client.model.ModelBiped _default)
+ public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
+ {
+ return getArmorModel(entityLiving, itemStack, armorSlot);
+ return null;
+ }
+
+ /**
@@ -655,80 +644,12 @@
+ {
+ return !ItemStack.func_77989_b(oldStack, newStack);
+ }
+
+
+ private ResourceLocation registryName = null;
+ /**
+ * Sets a unique name for this Item. This should be used for uniquely identify the instance of the Item.
+ * This is the valid replacement for the atrocious 'getUnlocalizedName().substring(6)' stuff that everyone does.
+ * Unlocalized names have NOTHING to do with unique identifiers. As demonstrated by vanilla blocks and items.
+ *
+ * The supplied name will be prefixed with the currently active mod's modId.
+ * If the supplied name already has a prefix that is different, it will be used and a warning will be logged.
+ *
+ * If a name already exists, or this Item is already registered in a registry, then an IllegalStateException is thrown.
+ *
+ * Returns 'this' to allow for chaining.
+ *
+ * @param name Unique registry name
+ * @return This instance
+ */
+ public final Item setRegistryName(String name)
+ {
+ if (getRegistryName() != null)
+ throw new IllegalStateException("Attempted to set registry name on block with exisiting registry name! New: " + name + " Old: " + getRegistryName());
+ int index = name.lastIndexOf(':');
+ String oldPrefix = index == -1 ? "" : name.substring(0, index);
+ name = index == -1 ? name : name.substring(index + 1);
+ net.minecraftforge.fml.common.ModContainer mc = net.minecraftforge.fml.common.Loader.instance().activeModContainer();
+ String prefix = mc == null ? "minecraft" : mc.getModId();
+ if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
+ {
+ net.minecraftforge.fml.common.FMLLog.bigWarning("Dangerous alternative prefix %s for name %s, invalid registry invocation/invalid name?", oldPrefix, name);
+ prefix = oldPrefix;
+ }
+ this.registryName = new ResourceLocation(prefix, name);
+ return this;
+ }
+ public final Item setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); }
+ public final Item setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); }
+
+ /**
+ * A unique identifier for this block, if this block is registered in the game registry it will return that name.
+ * Otherwise it will return the name set in setRegistryName().
+ * If neither are valid null is returned.
+ *
+ * @return Unique identifier or null.
+ */
+ public final String getRegistryName()
+ {
+ if (delegate.getResourceName() != null) return delegate.getResourceName().toString();
+ return registryName != null ? registryName.toString() : null;
+ }
+
+ /**
+ * Called from ItemStack.setItem, will hold extra data for the life of this ItemStack.
+ * Can be retrieved from stack.getCapabilities()
+ * The NBT can be null if this is not called from readNBT or if the item the stack is
+ * changing FROM is different then this item, or the previous item had no capabilities.
+ *
+ * This is called BEFORE the stacks item is set so you can use stack.getItem() to see the OLD item.
+ * Remember that getItem CAN return null.
+ *
+ * @param stack The ItemStack
+ * @param nbt NBT of this item serialized, or null.
+ * @return A holder instance associated with this ItemStack where you can hold capabilities for the life of this item.
+ */
+ public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
+ {
+ return null;
+ }
+ /* ======================================== FORGE END =====================================*/
+
public static void func_150900_l()
{
func_179214_a(Blocks.field_150348_b, (new ItemMultiTexture(Blocks.field_150348_b, Blocks.field_150348_b, new Function<ItemStack, String>()
@@ -855,6 +1523,10 @@
@@ -855,6 +1444,10 @@
private final float field_78011_i;
private final int field_78008_j;
@@ -739,7 +660,7 @@
private ToolMaterial(int p_i1874_3_, int p_i1874_4_, float p_i1874_5_, float p_i1874_6_, int p_i1874_7_)
{
this.field_78001_f = p_i1874_3_;
@@ -889,9 +1561,36 @@
@@ -889,9 +1482,36 @@
return this.field_78008_j;
}
@@ -1,35 +1,14 @@
--- ../src-base/minecraft/net/minecraft/item/ItemStack.java
+++ ../src-work/minecraft/net/minecraft/item/ItemStack.java
@@ -35,7 +35,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
-public final class ItemStack
+public final class ItemStack implements net.minecraftforge.common.capabilities.ICapabilitySerializable<NBTTagCompound>
{
public static final DecimalFormat field_111284_a = new DecimalFormat("#.###");
public int field_77994_a;
@@ -49,6 +49,10 @@
@@ -49,6 +49,7 @@
private Block field_179550_j;
private boolean field_179551_k;
+ private net.minecraftforge.fml.common.registry.RegistryDelegate<Item> delegate;
+ private net.minecraftforge.common.capabilities.CapabilityDispatcher capabilities;
+ private NBTTagCompound capNBT;
+
public ItemStack(Block p_i1876_1_)
{
this((Block)p_i1876_1_, 1);
@@ -74,13 +78,15 @@
this((Item)p_i1880_1_, p_i1880_2_, 0);
}
- public ItemStack(Item p_i1881_1_, int p_i1881_2_, int p_i1881_3_)
+ public ItemStack(Item p_i1881_1_, int p_i1881_2_, int p_i1881_3_) { this (p_i1881_1_, p_i1881_2_, p_i1881_3_, null); }
+ public ItemStack(Item p_i1881_1_, int p_i1881_2_, int p_i1881_3_, NBTTagCompound capNBT)
{
+ this.capNBT = capNBT;
this.field_179552_h = null;
@@ -80,7 +81,7 @@
this.field_179553_i = false;
this.field_179550_j = null;
this.field_179551_k = false;
@@ -38,16 +17,7 @@
this.field_77994_a = p_i1881_2_;
this.field_77991_e = p_i1881_3_;
@@ -107,7 +113,7 @@
public ItemStack func_77979_a(int p_77979_1_)
{
- ItemStack itemstack = new ItemStack(this.field_151002_e, p_77979_1_, this.field_77991_e);
+ ItemStack itemstack = new ItemStack(this.field_151002_e, p_77979_1_, this.field_77991_e, this.capabilities != null ? this.capabilities.serializeNBT() : null);
if (this.field_77990_d != null)
{
@@ -120,11 +126,12 @@
@@ -120,11 +121,12 @@
public Item func_77973_b()
{
@@ -61,18 +31,8 @@
boolean flag = this.func_77973_b().func_180614_a(this, p_179546_1_, p_179546_2_, p_179546_3_, p_179546_4_, p_179546_5_, p_179546_6_, p_179546_7_);
if (flag)
@@ -162,19 +169,23 @@
p_77955_1_.func_74782_a("tag", this.field_77990_d);
}
+ if (this.capabilities != null) p_77955_1_.func_74782_a("ForgeCaps", this.capabilities.serializeNBT());
+
return p_77955_1_;
}
public void func_77963_c(NBTTagCompound p_77963_1_)
@@ -169,11 +171,11 @@
{
+ this.capNBT = p_77963_1_.func_74764_b("ForgeCaps") ? p_77963_1_.func_74775_l("ForgeCaps") : null;
if (p_77963_1_.func_150297_b("id", 8))
{
- this.field_151002_e = Item.func_111206_d(p_77963_1_.func_74779_i("id"));
@@ -83,11 +43,9 @@
- this.field_151002_e = Item.func_150899_d(p_77963_1_.func_74765_d("id"));
+ this.func_150996_a(Item.func_150899_d(p_77963_1_.func_74765_d("id")));
}
+ this.capNBT = null;
this.field_77994_a = p_77963_1_.func_74771_c("Count");
this.field_77991_e = p_77963_1_.func_74765_d("Damage");
@@ -197,7 +208,7 @@
@@ -197,7 +199,7 @@
public int func_77976_d()
{
@@ -96,7 +54,7 @@
}
public boolean func_77985_e()
@@ -207,7 +218,7 @@
@@ -207,7 +209,7 @@
public boolean func_77984_f()
{
@@ -105,7 +63,7 @@
}
public boolean func_77981_g()
@@ -217,32 +228,27 @@
@@ -217,32 +219,27 @@
public boolean func_77951_h()
{
@@ -143,7 +101,7 @@
}
public boolean func_96631_a(int p_96631_1_, Random p_96631_2_)
@@ -274,8 +280,8 @@
@@ -274,8 +271,8 @@
}
}
@@ -154,7 +112,7 @@
}
}
@@ -334,7 +340,7 @@
@@ -334,7 +331,7 @@
public boolean func_150998_b(Block p_150998_1_)
{
@@ -163,16 +121,7 @@
}
public boolean func_111282_a(EntityPlayer p_111282_1_, EntityLivingBase p_111282_2_)
@@ -344,7 +350,7 @@
public ItemStack func_77946_l()
{
- ItemStack itemstack = new ItemStack(this.field_151002_e, this.field_77994_a, this.field_77991_e);
+ ItemStack itemstack = new ItemStack(this.field_151002_e, this.field_77994_a, this.field_77991_e, this.capabilities != null ? this.capabilities.serializeNBT() : null);
if (this.field_77990_d != null)
{
@@ -742,6 +748,7 @@
@@ -742,6 +739,7 @@
}
}
@@ -180,7 +129,7 @@
return list;
}
@@ -852,7 +859,7 @@
@@ -852,7 +850,7 @@
}
else
{
@@ -189,49 +138,11 @@
}
return multimap;
@@ -860,6 +867,18 @@
@@ -860,6 +858,7 @@
public void func_150996_a(Item p_150996_1_)
{
+ if (p_150996_1_ == this.field_151002_e && field_151002_e != null && this.capabilities != null) //Item Didn't change but refreshed
+ {
+ net.minecraftforge.common.capabilities.ICapabilityProvider parent = field_151002_e.initCapabilities(this, this.capabilities.serializeNBT());
+ this.capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(field_151002_e, this, parent);
+ }
+ else if (p_150996_1_ != this.field_151002_e && p_150996_1_ != null) // Item Changed
+ {
+ net.minecraftforge.common.capabilities.ICapabilityProvider parent = p_150996_1_.initCapabilities(this, this.capNBT);
+ this.capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(p_150996_1_, this, parent);
+ }
+ if (this.capNBT != null && this.capabilities != null) this.capabilities.deserializeNBT(this.capNBT);
+ this.delegate = p_150996_1_ != null ? p_150996_1_.delegate : null;
this.field_151002_e = p_150996_1_;
}
@@ -946,4 +965,26 @@
return false;
}
}
+
+ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability<?> capability, net.minecraft.util.EnumFacing facing)
+ {
+ return this.capabilities == null ? false : this.capabilities.hasCapability(capability, facing);
+ }
+
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ {
+ return this.capabilities == null ? null : this.capabilities.getCapability(capability, facing);
+ }
+
+ public void deserializeNBT(NBTTagCompound nbt)
+ {
+ this.func_77963_c(nbt);
+ }
+
+ public NBTTagCompound serializeNBT()
+ {
+ NBTTagCompound ret = new NBTTagCompound();
+ this.func_77955_b(ret);
+ return ret;
+ }
}
@@ -69,7 +69,7 @@
return;
}
+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_147369_b, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_AIR, worldserver, new BlockPos(0, 0, 0), null, new net.minecraft.util.Vec3(p_147346_1_.func_149573_h(), p_147346_1_.func_149569_i(), p_147346_1_.func_149575_j()));
+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_147369_b, net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_AIR, worldserver, new BlockPos(0, 0, 0), null);
+ if (event.useItem != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+ {
this.field_147369_b.field_71134_c.func_73085_a(this.field_147369_b, worldserver, itemstack);
@@ -88,28 +88,16 @@
}
flag = true;
@@ -598,12 +617,18 @@
this.field_147369_b.field_71137_h = true;
this.field_147369_b.field_71071_by.field_70462_a[this.field_147369_b.field_71071_by.field_70461_c] = ItemStack.func_77944_b(this.field_147369_b.field_71071_by.field_70462_a[this.field_147369_b.field_71071_by.field_70461_c]);
Slot slot = this.field_147369_b.field_71070_bA.func_75147_a(this.field_147369_b.field_71071_by, this.field_147369_b.field_71071_by.field_70461_c);
+ int windowId = this.field_147369_b.field_71070_bA.field_75152_c;
+ if (slot == null) // Forge: Fix 'slotless' inventories not selecting a valid slot to update
+ {
+ slot = this.field_147369_b.field_71069_bz.func_75147_a(this.field_147369_b.field_71071_by, this.field_147369_b.field_71071_by.field_70461_c);
+ windowId = this.field_147369_b.field_71069_bz.field_75152_c;
+ }
@@ -601,7 +620,7 @@
this.field_147369_b.field_71070_bA.func_75142_b();
this.field_147369_b.field_71137_h = false;
- if (!ItemStack.func_77989_b(this.field_147369_b.field_71071_by.func_70448_g(), p_147346_1_.func_149574_g()))
+ if (!ItemStack.func_77989_b(this.field_147369_b.field_71071_by.func_70448_g(), p_147346_1_.func_149574_g()) || !placeResult) // force client itemstack update if place event was cancelled
{
- this.func_147359_a(new S2FPacketSetSlot(this.field_147369_b.field_71070_bA.field_75152_c, slot.field_75222_d, this.field_147369_b.field_71071_by.func_70448_g()));
+ this.func_147359_a(new S2FPacketSetSlot(windowId, slot.field_75222_d, this.field_147369_b.field_71071_by.func_70448_g()));
this.func_147359_a(new S2FPacketSetSlot(this.field_147369_b.field_71070_bA.field_75152_c, slot.field_75222_d, this.field_147369_b.field_71071_by.func_70448_g()));
}
}
}
@@ -770,8 +795,10 @@
@@ -770,8 +789,10 @@
}
else
{
@@ -122,7 +110,7 @@
}
this.field_147374_l += 20;
@@ -916,7 +943,7 @@
@@ -916,7 +937,7 @@
return;
}
@@ -35,7 +35,7 @@
if (i >= 0 && i < Potion.field_76425_a.length && Potion.field_76425_a[i] != null)
{
@@ -223,4 +228,53 @@
@@ -223,4 +228,62 @@
{
return this.field_100013_f;
}
@@ -50,11 +50,3 @@
}
}
}
@@ -621,4 +627,7 @@
this.field_71321_q.func_71556_a(RConConsoleSource.func_175570_h(), p_71252_1_);
return RConConsoleSource.func_175570_h().func_70008_c();
}
+
+ //Forge: Enable formated text for colors in console.
+ @Override public void func_145747_a(net.minecraft.util.IChatComponent message) { field_155771_h.info(message.func_150254_d()); }
}
@@ -1,28 +0,0 @@
--- ../src-base/minecraft/net/minecraft/server/dedicated/ServerHangWatchdog.java
+++ ../src-work/minecraft/net/minecraft/server/dedicated/ServerHangWatchdog.java
@@ -22,6 +22,7 @@
private static final Logger field_180251_a = LogManager.getLogger();
private final DedicatedServer field_180249_b;
private final long field_180250_c;
+ private boolean firstRun = true;
public ServerHangWatchdog(DedicatedServer p_i46310_1_)
{
@@ -37,7 +38,7 @@
long j = MinecraftServer.func_130071_aq();
long k = j - i;
- if (k > this.field_180250_c)
+ if (k > this.field_180250_c && !this.firstRun)
{
field_180251_a.fatal("A single server tick took " + String.format("%.2f", new Object[] {Float.valueOf((float)k / 1000.0F)}) + " seconds (should be max " + String.format("%.2f", new Object[] {Float.valueOf(0.05F)}) + ")");
field_180251_a.fatal("Considering it to be crashed, server will forcibly shutdown.");
@@ -75,6 +76,8 @@
this.func_180248_a();
}
+ this.firstRun = false;
+
try
{
Thread.sleep(i + this.field_180250_c - j);
@@ -9,21 +9,12 @@
public World field_73092_a;
public EntityPlayerMP field_73090_b;
private WorldSettings.GameType field_73091_c = WorldSettings.GameType.NOT_SET;
@@ -116,7 +118,7 @@
else
{
int k = this.field_73100_i - this.field_73089_e;
- float f1 = block1.func_180647_a(this.field_73090_b, this.field_73090_b.field_70170_p, this.field_180241_i) * (float)(k + 1);
+ float f1 = block1.func_180647_a(this.field_73090_b, this.field_73090_b.field_70170_p, this.field_180240_f) * (float)(k + 1); //Forge: Fix network break progress using wrong position
int l = (int)(f1 * 10.0F);
if (l != this.field_73094_o)
@@ -130,6 +132,14 @@
public void func_180784_a(BlockPos p_180784_1_, EnumFacing p_180784_2_)
{
+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_73090_b,
+ net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, field_73092_a, p_180784_1_, p_180784_2_, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(field_73090_b, getBlockReachDistance() + 1));
+ net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, field_73092_a, p_180784_1_, p_180784_2_);
+ if (event.isCanceled())
+ {
+ field_73090_b.field_71135_a.func_147359_a(new S23PacketBlockChange(field_73092_a, p_180784_1_));
@@ -186,7 +177,7 @@
{
- if (!p_180236_1_.func_70093_af() || p_180236_1_.func_70694_bm() == null)
+ net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(p_180236_1_,
+ net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, p_180236_2_, p_180236_4_, p_180236_5_, new net.minecraft.util.Vec3(p_180236_6_, p_180236_7_, p_180236_8_));
+ net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, p_180236_2_, p_180236_4_, p_180236_5_);
+ if (event.isCanceled())
{
- IBlockState iblockstate = p_180236_2_.func_180495_p(p_180236_4_);
@@ -57,24 +57,24 @@
- func_151180_a(p_75924_0_, Blocks.field_180388_cO, Blocks.field_180389_cP);
- func_151180_a(p_75924_0_, Blocks.field_150349_c, Blocks.field_150346_d);
- func_151180_a(p_75924_0_, Blocks.field_150458_ak, Blocks.field_150346_d);
+ mergeStatBases(p_75924_0_, Blocks.field_150355_j, Blocks.field_150358_i, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150353_l, Blocks.field_150356_k, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150428_aP, Blocks.field_150423_aK, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150470_am, Blocks.field_150460_al, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150439_ay, Blocks.field_150450_ax, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150416_aS, Blocks.field_150413_aR, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150455_bV, Blocks.field_150441_bU, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150429_aA, Blocks.field_150437_az, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150374_bv, Blocks.field_150379_bu, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150334_T, Blocks.field_150333_U, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150373_bw, Blocks.field_150376_bx, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_180388_cO, Blocks.field_180389_cP, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150349_c, Blocks.field_150346_d, useItemIds);
+ mergeStatBases(p_75924_0_, Blocks.field_150458_ak, Blocks.field_150346_d, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150355_j, Blocks.field_150358_i, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150353_l, Blocks.field_150356_k, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150428_aP, Blocks.field_150423_aK, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150470_am, Blocks.field_150460_al, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150439_ay, Blocks.field_150450_ax, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150416_aS, Blocks.field_150413_aR, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150455_bV, Blocks.field_150441_bU, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150429_aA, Blocks.field_150437_az, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150374_bv, Blocks.field_150379_bu, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150334_T, Blocks.field_150333_U, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150373_bw, Blocks.field_150376_bx, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_180388_cO, Blocks.field_180389_cP, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150349_c, Blocks.field_150346_d, useItemIds);
+ func_151180_a(p_75924_0_, Blocks.field_150458_ak, Blocks.field_150346_d, useItemIds);
}
- private static void func_151180_a(StatBase[] p_151180_0_, Block p_151180_1_, Block p_151180_2_)
+ private static void mergeStatBases(StatBase[] p_151180_0_, Block p_151180_1_, Block p_151180_2_, boolean useItemIds)
+ private static void func_151180_a(StatBase[] p_151180_0_, Block p_151180_1_, Block p_151180_2_, boolean useItemIds)
{
- int i = Block.func_149682_b(p_151180_1_);
- int j = Block.func_149682_b(p_151180_2_);
@@ -1,33 +1,22 @@
--- ../src-base/minecraft/net/minecraft/tileentity/TileEntity.java
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntity.java
@@ -17,7 +17,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-public abstract class TileEntity
+public abstract class TileEntity implements net.minecraftforge.common.capabilities.ICapabilitySerializable<NBTTagCompound>
{
private static final Logger field_145852_a = LogManager.getLogger();
private static Map < String, Class <? extends TileEntity >> field_145855_i = Maps. < String, Class <? extends TileEntity >> newHashMap();
@@ -59,6 +59,8 @@
@@ -59,6 +59,7 @@
public void func_145839_a(NBTTagCompound p_145839_1_)
{
this.field_174879_c = new BlockPos(p_145839_1_.func_74762_e("x"), p_145839_1_.func_74762_e("y"), p_145839_1_.func_74762_e("z"));
+ if (p_145839_1_.func_74764_b("ForgeData")) this.customTileData = p_145839_1_.func_74775_l("ForgeData");
+ if (this.capabilities != null && p_145839_1_.func_74764_b("ForgeCaps")) this.capabilities.deserializeNBT(p_145839_1_.func_74775_l("ForgeCaps"));
}
public void func_145841_b(NBTTagCompound p_145841_1_)
@@ -75,6 +77,8 @@
@@ -75,6 +76,7 @@
p_145841_1_.func_74768_a("x", this.field_174879_c.func_177958_n());
p_145841_1_.func_74768_a("y", this.field_174879_c.func_177956_o());
p_145841_1_.func_74768_a("z", this.field_174879_c.func_177952_p());
+ if (this.customTileData != null) p_145841_1_.func_74782_a("ForgeData", this.customTileData);
+ if (this.capabilities != null) p_145841_1_.func_74782_a("ForgeCaps", this.capabilities.serializeNBT());
}
}
@@ -82,9 +86,10 @@
@@ -82,9 +84,10 @@
{
TileEntity tileentity = null;
@@ -39,7 +28,7 @@
if (oclass != null)
{
@@ -102,7 +107,17 @@
@@ -102,7 +105,17 @@
}
else
{
@@ -57,7 +46,7 @@
}
return tileentity;
@@ -134,7 +149,6 @@
@@ -134,7 +147,6 @@
}
}
@@ -65,7 +54,7 @@
public double func_145835_a(double p_145835_1_, double p_145835_3_, double p_145835_5_)
{
double d0 = (double)this.field_174879_c.func_177958_n() + 0.5D - p_145835_1_;
@@ -279,4 +293,183 @@
@@ -279,4 +291,146 @@
func_145826_a(TileEntityFlowerPot.class, "FlowerPot");
func_145826_a(TileEntityBanner.class, "Banner");
}
@@ -93,18 +82,18 @@
+
+ private boolean isVanilla = getClass().getName().startsWith("net.minecraft.");
+ /**
+ * Called from Chunk.setBlockIDWithMetadata and Chunk.fillChunk, determines if this tile entity should be re-created when the ID, or Metadata changes.
+ * Called from Chunk.setBlockIDWithMetadata, determines if this tile entity should be re-created when the ID, or Metadata changes.
+ * Use with caution as this will leave straggler TileEntities, or create conflicts with other TileEntities if not used properly.
+ *
+ * @param world Current world
+ * @param pos Tile's world position
+ * @param oldState The old ID of the block
+ * @param newState The new ID of the block (May be the same)
+ * @return true forcing the invalidation of the existing TE, false not to invalidate the existing TE
+ * @param oldID The old ID of the block
+ * @param newID The new ID of the block (May be the same)
+ * @return True to remove the old tile entity, false to keep it in tact {and create a new one if the new values specify to}
+ */
+ public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newSate)
+ {
+ return isVanilla ? (oldState.func_177230_c() != newSate.func_177230_c()) : oldState != newSate;
+ return !isVanilla || (oldState.func_177230_c() != newSate.func_177230_c());
+ }
+
+ public boolean shouldRenderInPass(int pass)
@@ -210,42 +199,5 @@
+ public void onLoad()
+ {
+ // NOOP
+ }
+
+ /**
+ * If the TileEntitySpecialRenderer associated with this TileEntity can be batched in with another renderers, and won't access the GL state.
+ * If TileEntity returns true, then TESR should have the same functionality as (and probably extend) the FastTESR class.
+ */
+ public boolean hasFastRenderer()
+ {
+ return false;
+ }
+
+ private net.minecraftforge.common.capabilities.CapabilityDispatcher capabilities;
+ public TileEntity()
+ {
+ capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this);
+ }
+
+ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability<?> capability, net.minecraft.util.EnumFacing facing)
+ {
+ return capabilities == null ? false : capabilities.hasCapability(capability, facing);
+ }
+
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ {
+ return capabilities == null ? null : capabilities.getCapability(capability, facing);
+ }
+
+ public void deserializeNBT(NBTTagCompound nbt)
+ {
+ this.func_145839_a(nbt);
+ }
+
+ public NBTTagCompound serializeNBT()
+ {
+ NBTTagCompound ret = new NBTTagCompound();
+ this.func_145841_b(ret);
+ return ret;
+ }
}
@@ -5,7 +5,7 @@
Block block = this.field_145850_b.func_180495_p(new BlockPos(j1, i2, k1)).func_177230_c();
- if (block != Blocks.field_150475_bE && block != Blocks.field_150340_R && block != Blocks.field_150484_ah && block != Blocks.field_150339_S)
+ if (!block.isBeaconBase(this.field_145850_b, new BlockPos(j1, i2, k1), func_174877_v()))
+ if (!block.isBeaconBase(this.field_145850_b, new BlockPos(l1, k1, j1), func_174877_v()))
{
flag1 = false;
break;
@@ -76,22 +76,3 @@
}
public boolean[] func_174902_m()
@@ -386,4 +393,18 @@
this.field_145945_j[i] = null;
}
}
+
+ net.minecraftforge.items.IItemHandler handlerInput = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.UP);
+ net.minecraftforge.items.IItemHandler handlerOutput = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN);
+
+ @Override
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ {
+ if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
+ if (facing == EnumFacing.UP)
+ return (T) handlerInput;
+ else
+ return (T) handlerOutput;
+ return super.getCapability(capability, facing);
+ }
}
@@ -1,35 +0,0 @@
--- ../src-base/minecraft/net/minecraft/tileentity/TileEntityChest.java
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityChest.java
@@ -186,6 +186,7 @@
{
super.func_145836_u();
this.field_145984_a = false;
+ doubleChestHandler = null;
}
@SuppressWarnings("incomplete-switch")
@@ -468,4 +469,24 @@
this.field_145985_p[i] = null;
}
}
+
+ public net.minecraftforge.items.VanillaDoubleChestItemHandler doubleChestHandler;
+
+ @Override
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ {
+ if (capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
+ {
+ if(doubleChestHandler == null || doubleChestHandler.needsRefresh())
+ doubleChestHandler = net.minecraftforge.items.VanillaDoubleChestItemHandler.get(this);
+ if (doubleChestHandler != null && doubleChestHandler != net.minecraftforge.items.VanillaDoubleChestItemHandler.NO_ADJACENT_CHESTS_INSTANCE)
+ return (T) doubleChestHandler;
+ }
+ return super.getCapability(capability, facing);
+ }
+
+ public net.minecraftforge.items.IItemHandler getSingleChestHandler()
+ {
+ return super.getCapability(net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
+ }
}
@@ -1,31 +1,5 @@
--- ../src-base/minecraft/net/minecraft/tileentity/TileEntityFurnace.java
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityFurnace.java
@@ -141,9 +141,9 @@
}
}
- this.field_145956_a = p_145839_1_.func_74765_d("BurnTime");
- this.field_174906_k = p_145839_1_.func_74765_d("CookTime");
- this.field_174905_l = p_145839_1_.func_74765_d("CookTimeTotal");
+ this.field_145956_a = p_145839_1_.func_74762_e("BurnTime");
+ this.field_174906_k = p_145839_1_.func_74762_e("CookTime");
+ this.field_174905_l = p_145839_1_.func_74762_e("CookTimeTotal");
this.field_145963_i = func_145952_a(this.field_145957_n[1]);
if (p_145839_1_.func_150297_b("CustomName", 8))
@@ -155,9 +155,9 @@
public void func_145841_b(NBTTagCompound p_145841_1_)
{
super.func_145841_b(p_145841_1_);
- p_145841_1_.func_74777_a("BurnTime", (short)this.field_145956_a);
- p_145841_1_.func_74777_a("CookTime", (short)this.field_174906_k);
- p_145841_1_.func_74777_a("CookTimeTotal", (short)this.field_174905_l);
+ p_145841_1_.func_74768_a("BurnTime", this.field_145956_a);
+ p_145841_1_.func_74768_a("CookTime", this.field_174906_k);
+ p_145841_1_.func_74768_a("CookTimeTotal", this.field_174905_l);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.field_145957_n.length; ++i)
@@ -223,8 +223,7 @@
if (this.field_145957_n[1].field_77994_a == 0)
@@ -75,25 +49,3 @@
}
}
@@ -451,4 +462,21 @@
this.field_145957_n[i] = null;
}
}
+
+ net.minecraftforge.items.IItemHandler handlerTop = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.UP);
+ net.minecraftforge.items.IItemHandler handlerBottom = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN);
+ net.minecraftforge.items.IItemHandler handlerSide = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.WEST);
+
+ @Override
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ {
+ if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
+ if (facing == EnumFacing.DOWN)
+ return (T) handlerBottom;
+ else if (facing == EnumFacing.UP)
+ return (T) handlerTop;
+ else
+ return (T) handlerSide;
+ return super.getCapability(capability, facing);
+ }
}
@@ -1,22 +1,6 @@
--- ../src-base/minecraft/net/minecraft/tileentity/TileEntityHopper.java
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityHopper.java
@@ -260,6 +260,7 @@
private boolean func_145883_k()
{
+ if (net.minecraftforge.items.VanillaInventoryCodeHooks.insertHook(this)) { return true; }
IInventory iinventory = this.func_145895_l();
if (iinventory == null)
@@ -366,6 +367,7 @@
public static boolean func_145891_a(IHopper p_145891_0_)
{
+ if (net.minecraftforge.items.VanillaInventoryCodeHooks.extractHook(p_145891_0_)) { return true; }
IInventory iinventory = func_145884_b(p_145891_0_);
if (iinventory != null)
@@ -515,17 +517,31 @@
@@ -515,17 +515,31 @@
if (itemstack == null)
{
@@ -49,14 +33,3 @@
}
if (flag)
@@ -668,4 +684,10 @@
this.field_145900_a[i] = null;
}
}
+
+
+ protected net.minecraftforge.items.IItemHandler createUnSidedHandler()
+ {
+ return new net.minecraftforge.items.VanillaHopperItemHandler(this);
+ }
}
@@ -1,28 +0,0 @@
--- ../src-base/minecraft/net/minecraft/tileentity/TileEntityLockable.java
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityLockable.java
@@ -47,4 +47,25 @@
{
return (IChatComponent)(this.func_145818_k_() ? new ChatComponentText(this.func_70005_c_()) : new ChatComponentTranslation(this.func_70005_c_(), new Object[0]));
}
+
+ private net.minecraftforge.items.IItemHandler itemHandler;
+
+ protected net.minecraftforge.items.IItemHandler createUnSidedHandler()
+ {
+ return new net.minecraftforge.items.wrapper.InvWrapper(this);
+ }
+
+ @Override
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ {
+ if (capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
+ return (T) (itemHandler == null ? (itemHandler = createUnSidedHandler()) : itemHandler);
+ return super.getCapability(capability, facing);
+ }
+
+ @Override
+ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability<?> capability, net.minecraft.util.EnumFacing facing)
+ {
+ return capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
+ }
}
@@ -1,32 +0,0 @@
--- ../src-base/minecraft/net/minecraft/util/BlockPos.java
+++ ../src-work/minecraft/net/minecraft/util/BlockPos.java
@@ -257,6 +257,21 @@
};
}
+ /**
+ * Returns a version of this BlockPos that is guaranteed to be Immutable.
+ * In most cases this will return 'this', but if 'this' is an instance of
+ * MutableBlockPos it will return a new instance of BlockPos with the same values.
+ *
+ * When storing a parameter given to you for an extended period of time, make sure you
+ * use this in case the value is changed internally.
+ *
+ * @return An immutable BlockPos.
+ */
+ public BlockPos getImmutable()
+ {
+ return this;
+ }
+
public static final class MutableBlockPos extends BlockPos
{
private int field_177997_b;
@@ -298,5 +313,7 @@
this.field_177996_d = p_181079_3_;
return this;
}
+
+ @Override public BlockPos getImmutable() { return new BlockPos(this); }
}
}
@@ -9,7 +9,15 @@
return this.field_72817_c[i][j].func_177424_a(p_175625_1_, Chunk.EnumCreateEntityType.IMMEDIATE);
}
@@ -139,6 +141,8 @@
@@ -84,6 +86,7 @@
{
int i = (p_180495_1_.func_177958_n() >> 4) - this.field_72818_a;
int j = (p_180495_1_.func_177952_p() >> 4) - this.field_72816_b;
+ if (i < 0 || i >= field_72817_c.length || j < 0 || i >= field_72817_c[i].length) return Blocks.field_150350_a.func_176223_P();
if (i >= 0 && i < this.field_72817_c.length && j >= 0 && j < this.field_72817_c[i].length)
{
@@ -139,6 +142,8 @@
{
int i = (p_175629_2_.func_177958_n() >> 4) - this.field_72818_a;
int j = (p_175629_2_.func_177952_p() >> 4) - this.field_72816_b;
@@ -18,7 +26,7 @@
return this.field_72817_c[i][j].func_177413_a(p_175629_1_, p_175629_2_);
}
}
@@ -150,7 +154,7 @@
@@ -150,7 +155,7 @@
public boolean func_175623_d(BlockPos p_175623_1_)
{
@@ -27,15 +35,15 @@
}
@SideOnly(Side.CLIENT)
@@ -160,6 +164,7 @@
@@ -160,6 +165,7 @@
{
int i = (p_175628_2_.func_177958_n() >> 4) - this.field_72818_a;
int j = (p_175628_2_.func_177952_p() >> 4) - this.field_72816_b;
+ if (i < 0 || i >= field_72817_c.length || j < 0 || j >= field_72817_c[i].length) return p_175628_1_.field_77198_c;
+ if (i < 0 || i >= field_72817_c.length || j < 0 || i >= field_72817_c[i].length) return p_175628_1_.field_77198_c;
return this.field_72817_c[i][j].func_177413_a(p_175628_1_, p_175628_2_);
}
else
@@ -179,4 +184,16 @@
@@ -179,4 +185,15 @@
{
return this.field_72815_e.func_175624_G();
}
@@ -46,8 +54,7 @@
+ int x = (pos.func_177958_n() >> 4) - this.field_72818_a;
+ int z = (pos.func_177952_p() >> 4) - this.field_72816_b;
+ if (pos.func_177956_o() >= 0 && pos.func_177956_o() < 256) return _default;
+ if (x < 0 || x >= field_72817_c.length || z < 0 || z >= field_72817_c[x].length) return _default;
+ if (field_72817_c[x][z] == null) return _default;
+ if (x < 0 || x >= field_72817_c.length || z < 0 || x >= field_72817_c[x].length) return _default;
+
+ return func_180495_p(pos).func_177230_c().isSideSolid(this, pos, side);
+ }
@@ -24,10 +24,10 @@
entityliving.func_70012_b((double)f, (double)i3, (double)f1, p_77192_1_.field_73012_v.nextFloat() * 360.0F, 0.0F);
- if (entityliving.func_70601_bi() && entityliving.func_70058_J())
+ net.minecraftforge.fml.common.eventhandler.Event.Result canSpawn = net.minecraftforge.event.ForgeEventFactory.canEntitySpawn(entityliving, p_77192_1_, f, i3, f1);
+ net.minecraftforge.fml.common.eventhandler.Event.Result canSpawn = net.minecraftforge.event.ForgeEventFactory.canEntitySpawn(entityliving, p_77192_1_, f, l2, f1);
+ if (canSpawn == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW || (canSpawn == net.minecraftforge.fml.common.eventhandler.Event.Result.DEFAULT && (entityliving.func_70601_bi() && entityliving.func_70058_J())))
{
+ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(entityliving, p_77192_1_, f, l3, f1))
+ if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(entityliving, p_77192_1_, f1, l2, f1))
ientitylivingdata = entityliving.func_180482_a(p_77192_1_.func_175649_E(new BlockPos(entityliving)), ientitylivingdata);
if (entityliving.func_70058_J())
@@ -82,7 +82,7 @@
}
public boolean func_175667_e(BlockPos p_175667_1_)
@@ -284,39 +301,63 @@
@@ -284,39 +301,61 @@
{
Chunk chunk = this.func_175726_f(p_180501_1_);
Block block = p_180501_2_.func_177230_c();
@@ -93,9 +93,7 @@
+ blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(this, p_180501_1_, p_180501_3_);
+ this.capturedBlockSnapshots.add(blockSnapshot);
+ }
+ Block oldBlock = func_180495_p(p_180501_1_).func_177230_c();
+ int oldLight = oldBlock.getLightValue(this, p_180501_1_);
+ int oldOpacity = oldBlock.getLightOpacity(this, p_180501_1_);
+ int oldLight = func_180495_p(p_180501_1_).func_177230_c().getLightValue(this, p_180501_1_);
+
IBlockState iblockstate = chunk.func_177436_a(p_180501_1_, p_180501_2_);
@@ -109,7 +107,7 @@
Block block1 = iblockstate.func_177230_c();
- if (block.func_149717_k() != block1.func_149717_k() || block.func_149750_m() != block1.func_149750_m())
+ if (block.getLightOpacity(this, p_180501_1_) != oldOpacity || block.getLightValue(this, p_180501_1_) != oldLight)
+ if (block.func_149717_k() != block1.func_149717_k() || block.getLightValue(this, p_180501_1_) != oldLight)
{
this.field_72984_F.func_76320_a("checkLight");
this.func_175664_x(p_180501_1_);
@@ -141,7 +139,7 @@
+ if (!this.field_72995_K && (flags & 1) != 0)
{
- this.func_175722_b(p_180501_1_, iblockstate.func_177230_c());
+ this.func_175722_b(pos, old.func_177230_c());
+ this.func_175722_b(pos, new_.func_177230_c());
- if (block.func_149740_M())
+ if (new_.func_177230_c().func_149740_M())
@@ -155,7 +153,7 @@
}
}
}
@@ -404,6 +445,9 @@
@@ -404,6 +443,9 @@
public void func_175685_c(BlockPos p_175685_1_, Block p_175685_2_)
{
@@ -165,7 +163,7 @@
this.func_180496_d(p_175685_1_.func_177976_e(), p_175685_2_);
this.func_180496_d(p_175685_1_.func_177974_f(), p_175685_2_);
this.func_180496_d(p_175685_1_.func_177977_b(), p_175685_2_);
@@ -414,6 +458,11 @@
@@ -414,6 +456,11 @@
public void func_175695_a(BlockPos p_175695_1_, Block p_175695_2_, EnumFacing p_175695_3_)
{
@@ -177,7 +175,7 @@
if (p_175695_3_ != EnumFacing.WEST)
{
this.func_180496_d(p_175695_1_.func_177976_e(), p_175695_2_);
@@ -777,7 +826,7 @@
@@ -777,7 +824,7 @@
public boolean func_72935_r()
{
@@ -186,7 +184,7 @@
}
public MovingObjectPosition func_72933_a(Vec3 p_72933_1_, Vec3 p_72933_2_)
@@ -972,6 +1021,12 @@
@@ -972,6 +1019,12 @@
public void func_72956_a(Entity p_72956_1_, String p_72956_2_, float p_72956_3_, float p_72956_4_)
{
@@ -199,7 +197,7 @@
for (int i = 0; i < this.field_73021_x.size(); ++i)
{
((IWorldAccess)this.field_73021_x.get(i)).func_72704_a(p_72956_2_, p_72956_1_.field_70165_t, p_72956_1_.field_70163_u, p_72956_1_.field_70161_v, p_72956_3_, p_72956_4_);
@@ -980,6 +1035,12 @@
@@ -980,6 +1033,12 @@
public void func_85173_a(EntityPlayer p_85173_1_, String p_85173_2_, float p_85173_3_, float p_85173_4_)
{
@@ -212,7 +210,7 @@
for (int i = 0; i < this.field_73021_x.size(); ++i)
{
((IWorldAccess)this.field_73021_x.get(i)).func_85102_a(p_85173_1_, p_85173_2_, p_85173_1_.field_70165_t, p_85173_1_.field_70163_u, p_85173_1_.field_70161_v, p_85173_3_, p_85173_4_);
@@ -1033,6 +1094,9 @@
@@ -1033,6 +1092,9 @@
public boolean func_72838_d(Entity p_72838_1_)
{
@@ -222,7 +220,7 @@
int i = MathHelper.func_76128_c(p_72838_1_.field_70165_t / 16.0D);
int j = MathHelper.func_76128_c(p_72838_1_.field_70161_v / 16.0D);
boolean flag = p_72838_1_.field_98038_p;
@@ -1055,6 +1119,8 @@
@@ -1055,6 +1117,8 @@
this.func_72854_c();
}
@@ -231,7 +229,7 @@
this.func_72964_e(i, j).func_76612_a(p_72838_1_);
this.field_72996_f.add(p_72838_1_);
this.func_72923_a(p_72838_1_);
@@ -1267,17 +1333,29 @@
@@ -1267,17 +1331,29 @@
public int func_72967_a(float p_72967_1_)
{
@@ -264,7 +262,7 @@
public void func_72848_b(IWorldAccess p_72848_1_)
{
this.field_73021_x.remove(p_72848_1_);
@@ -1286,6 +1364,12 @@
@@ -1286,6 +1362,12 @@
@SideOnly(Side.CLIENT)
public float func_72971_b(float p_72971_1_)
{
@@ -277,7 +275,7 @@
float f = this.func_72826_c(p_72971_1_);
float f1 = 1.0F - (MathHelper.func_76134_b(f * (float)Math.PI * 2.0F) * 2.0F + 0.2F);
f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F);
@@ -1298,6 +1382,12 @@
@@ -1298,6 +1380,12 @@
@SideOnly(Side.CLIENT)
public Vec3 func_72833_a(Entity p_72833_1_, float p_72833_2_)
{
@@ -290,7 +288,7 @@
float f = this.func_72826_c(p_72833_2_);
float f1 = MathHelper.func_76134_b(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F);
@@ -1305,9 +1395,7 @@
@@ -1305,9 +1393,7 @@
int j = MathHelper.func_76128_c(p_72833_1_.field_70163_u);
int k = MathHelper.func_76128_c(p_72833_1_.field_70161_v);
BlockPos blockpos = new BlockPos(i, j, k);
@@ -301,7 +299,7 @@
float f3 = (float)(l >> 16 & 255) / 255.0F;
float f4 = (float)(l >> 8 & 255) / 255.0F;
float f5 = (float)(l & 255) / 255.0F;
@@ -1367,6 +1455,11 @@
@@ -1367,6 +1453,11 @@
public float func_130001_d()
{
@@ -313,7 +311,7 @@
return WorldProvider.field_111203_a[this.field_73011_w.func_76559_b(this.field_72986_A.func_76073_f())];
}
@@ -1379,6 +1472,12 @@
@@ -1379,6 +1470,12 @@
@SideOnly(Side.CLIENT)
public Vec3 func_72824_f(float p_72824_1_)
{
@@ -326,7 +324,7 @@
float f = this.func_72826_c(p_72824_1_);
float f1 = MathHelper.func_76134_b(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F;
f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F);
@@ -1434,9 +1533,9 @@
@@ -1434,9 +1531,9 @@
for (blockpos = new BlockPos(p_175672_1_.func_177958_n(), chunk.func_76625_h() + 16, p_175672_1_.func_177952_p()); blockpos.func_177956_o() >= 0; blockpos = blockpos1)
{
blockpos1 = blockpos.func_177977_b();
@@ -338,7 +336,7 @@
{
break;
}
@@ -1448,6 +1547,12 @@
@@ -1448,6 +1545,12 @@
@SideOnly(Side.CLIENT)
public float func_72880_h(float p_72880_1_)
{
@@ -351,7 +349,7 @@
float f = this.func_72826_c(p_72880_1_);
float f1 = 1.0F - (MathHelper.func_76134_b(f * (float)Math.PI * 2.0F) * 2.0F + 0.25F);
f1 = MathHelper.func_76131_a(f1, 0.0F, 1.0F);
@@ -1494,7 +1599,15 @@
@@ -1494,7 +1597,15 @@
entity.func_85029_a(crashreportcategory);
}
@@ -368,7 +366,7 @@
}
if (entity.field_70128_L)
@@ -1554,7 +1667,15 @@
@@ -1554,7 +1665,15 @@
CrashReport crashreport1 = CrashReport.func_85055_a(throwable1, "Ticking entity");
CrashReportCategory crashreportcategory2 = crashreport1.func_85058_a("Entity being ticked");
entity2.func_85029_a(crashreportcategory2);
@@ -385,7 +383,7 @@
}
}
@@ -1601,7 +1722,16 @@
@@ -1601,7 +1720,16 @@
CrashReport crashreport2 = CrashReport.func_85055_a(throwable, "Ticking block entity");
CrashReportCategory crashreportcategory1 = crashreport2.func_85058_a("Block entity being ticked");
tileentity.func_145828_a(crashreportcategory1);
@@ -403,7 +401,7 @@
}
}
}
@@ -1618,15 +1748,20 @@
@@ -1618,15 +1746,20 @@
}
}
@@ -426,7 +424,7 @@
this.field_72984_F.func_76318_c("pendingBlockEntities");
if (!this.field_147484_a.isEmpty())
@@ -1660,7 +1795,8 @@
@@ -1660,7 +1793,8 @@
public boolean func_175700_a(TileEntity p_175700_1_)
{
@@ -436,7 +434,7 @@
if (flag && p_175700_1_ instanceof ITickable)
{
@@ -1699,9 +1835,13 @@
@@ -1699,9 +1833,13 @@
{
int i = MathHelper.func_76128_c(p_72866_1_.field_70165_t);
int j = MathHelper.func_76128_c(p_72866_1_.field_70161_v);
@@ -452,7 +450,7 @@
{
p_72866_1_.field_70142_S = p_72866_1_.field_70165_t;
p_72866_1_.field_70137_T = p_72866_1_.field_70163_u;
@@ -1829,7 +1969,7 @@
@@ -1829,7 +1967,7 @@
{
Block block = this.func_180495_p(blockpos$mutableblockpos.func_181079_c(k1, l1, i2)).func_177230_c();
@@ -461,7 +459,7 @@
{
return true;
}
@@ -1894,6 +2034,10 @@
@@ -1894,6 +2032,10 @@
{
return true;
}
@@ -472,34 +470,7 @@
}
}
}
@@ -1930,6 +2074,16 @@
blockpos$mutableblockpos.func_181079_c(k1, l1, i2);
IBlockState iblockstate = this.func_180495_p(blockpos$mutableblockpos);
Block block = iblockstate.func_177230_c();
+
+ Boolean result = block.isEntityInsideMaterial(this, blockpos$mutableblockpos, iblockstate, p_72918_3_, (double)l, p_72918_2_, false);
+ if (result != null && result == true)
+ {
+ // Forge: When requested call blocks modifyAcceleration method, and more importantly cause this method to return true, which results in an entity being "inWater"
+ flag = true;
+ vec3 = block.func_176197_a(this, blockpos$mutableblockpos, p_72918_3_, vec3);
+ continue;
+ }
+ else if (result != null && result == false) continue;
if (block.func_149688_o() == p_72918_2_)
{
@@ -2004,6 +2158,9 @@
IBlockState iblockstate = this.func_180495_p(blockpos$mutableblockpos.func_181079_c(k1, l1, i2));
Block block = iblockstate.func_177230_c();
+ Boolean result = block.isAABBInsideMaterial(this, blockpos$mutableblockpos, p_72830_1_, p_72830_2_);
+ if (result != null) return result;
+
if (block.func_149688_o() == p_72830_2_)
{
int j2 = ((Integer)iblockstate.func_177229_b(BlockLiquid.field_176367_b)).intValue();
@@ -2034,6 +2191,7 @@
@@ -2034,6 +2176,7 @@
public Explosion func_72885_a(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
{
Explosion explosion = new Explosion(this, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_, p_72885_9_, p_72885_10_);
@@ -507,7 +478,7 @@
explosion.func_77278_a();
explosion.func_77279_a(true);
return explosion;
@@ -2180,19 +2338,27 @@
@@ -2180,19 +2323,27 @@
else
{
this.func_175700_a(p_175690_2_);
@@ -536,7 +507,7 @@
}
else
{
@@ -2205,6 +2371,7 @@
@@ -2205,6 +2356,7 @@
this.func_175726_f(p_175713_1_).func_177425_e(p_175713_1_);
}
@@ -544,7 +515,7 @@
}
public void func_147457_a(TileEntity p_147457_1_)
@@ -2223,7 +2390,7 @@
@@ -2223,7 +2375,7 @@
{
IBlockState iblockstate = p_175683_0_.func_180495_p(p_175683_1_);
Block block = iblockstate.func_177230_c();
@@ -553,7 +524,7 @@
}
public boolean func_175677_d(BlockPos p_175677_1_, boolean p_175677_2_)
@@ -2243,7 +2410,7 @@
@@ -2243,7 +2395,7 @@
else
{
Block block = this.func_180495_p(p_175677_1_).func_177230_c();
@@ -562,7 +533,7 @@
}
}
}
@@ -2262,6 +2429,7 @@
@@ -2262,6 +2414,7 @@
{
this.field_72985_G = p_72891_1_;
this.field_72992_H = p_72891_2_;
@@ -570,7 +541,7 @@
}
public void func_72835_b()
@@ -2271,6 +2439,11 @@
@@ -2271,6 +2424,11 @@
protected void func_72947_a()
{
@@ -582,7 +553,7 @@
if (this.field_72986_A.func_76059_o())
{
this.field_73004_o = 1.0F;
@@ -2284,6 +2457,11 @@
@@ -2284,6 +2442,11 @@
protected void func_72979_l()
{
@@ -594,7 +565,7 @@
if (!this.field_73011_w.func_177495_o())
{
if (!this.field_72995_K)
@@ -2378,6 +2556,7 @@
@@ -2378,6 +2541,7 @@
{
this.field_72993_I.clear();
this.field_72984_F.func_76320_a("buildList");
@@ -602,7 +573,7 @@
for (int i = 0; i < this.field_73010_i.size(); ++i)
{
@@ -2434,8 +2613,9 @@
@@ -2434,8 +2598,9 @@
Block block = p_147467_3_.func_177428_a(blockpos);
j = j + p_147467_1_;
k = k + p_147467_2_;
@@ -613,7 +584,7 @@
{
EntityPlayer entityplayer = this.func_72977_a((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, 8.0D);
@@ -2475,6 +2655,11 @@
@@ -2475,6 +2640,11 @@
public boolean func_175670_e(BlockPos p_175670_1_, boolean p_175670_2_)
{
@@ -625,7 +596,7 @@
BiomeGenBase biomegenbase = this.func_180494_b(p_175670_1_);
float f = biomegenbase.func_180626_a(p_175670_1_);
@@ -2516,6 +2701,11 @@
@@ -2516,6 +2686,11 @@
public boolean func_175708_f(BlockPos p_175708_1_, boolean p_175708_2_)
{
@@ -637,7 +608,7 @@
BiomeGenBase biomegenbase = this.func_180494_b(p_175708_1_);
float f = biomegenbase.func_180626_a(p_175708_1_);
@@ -2533,7 +2723,7 @@
@@ -2533,7 +2708,7 @@
{
Block block = this.func_180495_p(p_175708_1_).func_177230_c();
@@ -646,7 +617,7 @@
{
return true;
}
@@ -2565,10 +2755,11 @@
@@ -2565,10 +2740,11 @@
else
{
Block block = this.func_180495_p(p_175638_1_).func_177230_c();
@@ -661,7 +632,7 @@
{
j = 1;
}
@@ -2768,10 +2959,10 @@
@@ -2768,10 +2944,10 @@
public List<Entity> func_175674_a(Entity p_175674_1_, AxisAlignedBB p_175674_2_, Predicate <? super Entity > p_175674_3_)
{
List<Entity> list = Lists.<Entity>newArrayList();
@@ -676,7 +647,7 @@
for (int i1 = i; i1 <= j; ++i1)
{
@@ -2824,10 +3015,10 @@
@@ -2824,10 +3000,10 @@
public <T extends Entity> List<T> func_175647_a(Class <? extends T > p_175647_1_, AxisAlignedBB p_175647_2_, Predicate <? super T > p_175647_3_)
{
@@ -691,7 +662,7 @@
List<T> list = Lists.<T>newArrayList();
for (int i1 = i; i1 <= j; ++i1)
@@ -2905,11 +3096,13 @@
@@ -2905,11 +3081,13 @@
public void func_175650_b(Collection<Entity> p_175650_1_)
{
@@ -708,7 +679,7 @@
}
}
@@ -2922,7 +3115,9 @@
@@ -2922,7 +3100,9 @@
{
Block block = this.func_180495_p(p_175716_2_).func_177230_c();
AxisAlignedBB axisalignedbb = p_175716_3_ ? null : p_175716_1_.func_180640_a(this, p_175716_2_, p_175716_1_.func_176223_P());
@@ -719,7 +690,7 @@
}
public int func_181545_F()
@@ -3007,7 +3202,7 @@
@@ -3007,7 +3187,7 @@
{
IBlockState iblockstate = this.func_180495_p(p_175651_1_);
Block block = iblockstate.func_177230_c();
@@ -728,7 +699,7 @@
}
public boolean func_175640_z(BlockPos p_175640_1_)
@@ -3134,7 +3329,7 @@
@@ -3134,7 +3314,7 @@
public long func_72905_C()
{
@@ -737,7 +708,7 @@
}
public long func_82737_E()
@@ -3144,17 +3339,17 @@
@@ -3144,17 +3324,17 @@
public long func_72820_D()
{
@@ -758,7 +729,7 @@
if (!this.func_175723_af().func_177746_a(blockpos))
{
@@ -3166,7 +3361,7 @@
@@ -3166,7 +3346,7 @@
public void func_175652_B(BlockPos p_175652_1_)
{
@@ -767,7 +738,7 @@
}
@SideOnly(Side.CLIENT)
@@ -3186,12 +3381,18 @@
@@ -3186,12 +3366,18 @@
if (!this.field_72996_f.contains(p_72897_1_))
{
@@ -786,7 +757,7 @@
return true;
}
@@ -3285,8 +3486,7 @@
@@ -3285,8 +3471,7 @@
public boolean func_180502_D(BlockPos p_180502_1_)
{
@@ -796,7 +767,7 @@
}
public MapStorage func_175693_T()
@@ -3345,12 +3545,12 @@
@@ -3345,12 +3530,12 @@
public int func_72800_K()
{
@@ -811,7 +782,7 @@
}
public Random func_72843_D(int p_72843_1_, int p_72843_2_, int p_72843_3_)
@@ -3405,7 +3605,7 @@
@@ -3405,7 +3590,7 @@
@SideOnly(Side.CLIENT)
public double func_72919_O()
{
@@ -820,16 +791,7 @@
}
public void func_175715_c(int p_175715_1_, BlockPos p_175715_2_, int p_175715_3_)
@@ -3439,7 +3639,7 @@
public void func_175666_e(BlockPos p_175666_1_, Block p_175666_2_)
{
- for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
+ for (EnumFacing enumfacing : EnumFacing.field_82609_l)
{
BlockPos blockpos = p_175666_1_.func_177972_a(enumfacing);
@@ -3447,18 +3647,14 @@
@@ -3447,18 +3632,14 @@
{
IBlockState iblockstate = this.func_180495_p(blockpos);
@@ -854,7 +816,7 @@
}
}
}
@@ -3528,4 +3724,81 @@
@@ -3528,4 +3709,81 @@
int k = 128;
return i >= -k && i <= k && j >= -k && j <= k;
}
@@ -60,7 +60,7 @@
this.field_72984_F.func_76319_b();
this.func_147488_Z();
}
@@ -217,12 +237,14 @@
@@ -217,6 +237,7 @@
public BiomeGenBase.SpawnListEntry func_175734_a(EnumCreatureType p_175734_1_, BlockPos p_175734_2_)
{
List<BiomeGenBase.SpawnListEntry> list = this.func_72863_F().func_177458_a(p_175734_1_, p_175734_2_);
@@ -68,14 +68,7 @@
return list != null && !list.isEmpty() ? (BiomeGenBase.SpawnListEntry)WeightedRandom.func_76271_a(this.field_73012_v, list) : null;
}
public boolean func_175732_a(EnumCreatureType p_175732_1_, BiomeGenBase.SpawnListEntry p_175732_2_, BlockPos p_175732_3_)
{
List<BiomeGenBase.SpawnListEntry> list = this.func_72863_F().func_177458_a(p_175732_1_, p_175732_3_);
+ list = net.minecraftforge.event.ForgeEventFactory.getPotentialSpawns(this, p_175732_1_, p_175732_3_, list);
return list != null && !list.isEmpty() ? list.contains(p_175732_2_) : false;
}
@@ -268,10 +290,7 @@
@@ -268,10 +289,7 @@
private void func_73051_P()
{
@@ -140,13 +133,13 @@
- for (int i = 0; i < this.field_147482_g.size(); ++i)
+ //Forge: Optimize this loop to only grab from the chunks it needs
+ for (int x = (p_147486_1_ & ~0x0F); x < p_147486_4_; x += 16)
+ for (int x = p_147486_1_; x < p_147486_4_; x += 16)
{
- TileEntity tileentity = (TileEntity)this.field_147482_g.get(i);
- BlockPos blockpos = tileentity.func_174877_v();
-
- if (blockpos.func_177958_n() >= p_147486_1_ && blockpos.func_177956_o() >= p_147486_2_ && blockpos.func_177952_p() >= p_147486_3_ && blockpos.func_177958_n() < p_147486_4_ && blockpos.func_177956_o() < p_147486_5_ && blockpos.func_177952_p() < p_147486_6_)
+ for (int z = (p_147486_3_ & ~0x0F); z < p_147486_6_; z += 16) // & ~0xF Floors it by 16. Yay bitmath!
+ for (int z = p_147486_3_; z < p_147486_6_; z += 16)
{
- list.add(tileentity);
+ if (!this.func_175680_a(x >> 4, z >> 4, true)) continue; //Prevent loading extra chunks to just read data. This causes orphaned chunks that never unload.
@@ -24,15 +24,7 @@
}
private Block func_150810_a(int p_150810_1_, int p_150810_2_, int p_150810_3_)
@@ -607,6 +607,7 @@
{
Block block = p_177436_2_.func_177230_c();
Block block1 = iblockstate.func_177230_c();
+ int k1 = block1.getLightOpacity(this.field_76637_e, p_177436_1_); // Relocate old light value lookup here, so that it is called before TE is removed.
ExtendedBlockStorage extendedblockstorage = this.field_76652_q[j >> 4];
boolean flag = false;
@@ -623,14 +624,19 @@
@@ -623,14 +623,19 @@
extendedblockstorage.func_177484_a(i, j & 15, k, p_177436_2_);
@@ -54,24 +46,23 @@
this.field_76637_e.func_175713_t(p_177436_1_);
}
}
@@ -647,8 +653,7 @@
@@ -647,8 +652,8 @@
}
else
{
- int j1 = block.func_149717_k();
- int k1 = block1.func_149717_k();
+ int j1 = block.getLightOpacity(this.field_76637_e, p_177436_1_);
+ int k1 = block1.getLightOpacity(this.field_76637_e, p_177436_1_);
if (j1 > 0)
{
@@ -668,28 +673,19 @@
@@ -668,28 +673,18 @@
}
}
- if (block1 instanceof ITileEntityProvider)
+ // If capturing blocks, only run block physics for TE's. Non-TE's are handled in ForgeHooks.onPlaceItemIntoWorld
+ if (!this.field_76637_e.field_72995_K && block1 != block && (!this.field_76637_e.captureBlockSnapshots || block.hasTileEntity(p_177436_2_)))
{
- {
- TileEntity tileentity = this.func_177424_a(p_177436_1_, Chunk.EnumCreateEntityType.CHECK);
-
- if (tileentity != null)
@@ -80,8 +71,8 @@
- }
- }
-
- if (!this.field_76637_e.field_72995_K && block1 != block)
- {
if (!this.field_76637_e.field_72995_K && block1 != block)
{
block.func_176213_c(this.field_76637_e, p_177436_1_, p_177436_2_);
}
@@ -97,7 +88,7 @@
this.field_76637_e.func_175690_a(p_177436_1_, tileentity1);
}
@@ -792,6 +788,7 @@
@@ -792,6 +787,7 @@
k = this.field_76645_j.length - 1;
}
@@ -105,7 +96,7 @@
p_76612_1_.field_70175_ag = true;
p_76612_1_.field_70176_ah = this.field_76635_g;
p_76612_1_.field_70162_ai = k;
@@ -830,13 +827,20 @@
@@ -830,13 +826,20 @@
private TileEntity func_177422_i(BlockPos p_177422_1_)
{
Block block = this.func_177428_a(p_177422_1_);
@@ -127,12 +118,8 @@
if (tileentity == null)
{
if (p_177424_2_ == Chunk.EnumCreateEntityType.IMMEDIATE)
@@ -846,14 +850,9 @@
}
else if (p_177424_2_ == Chunk.EnumCreateEntityType.QUEUED)
{
- this.field_177447_w.add(p_177424_1_);
+ this.field_177447_w.add(p_177424_1_.getImmutable());
@@ -849,11 +852,6 @@
this.field_177447_w.add(p_177424_1_);
}
}
- else if (tileentity.func_145837_r())
@@ -143,7 +130,7 @@
return tileentity;
}
@@ -873,7 +872,7 @@
@@ -873,7 +871,7 @@
p_177426_2_.func_145834_a(this.field_76637_e);
p_177426_2_.func_174878_a(p_177426_1_);
@@ -152,7 +139,7 @@
{
if (this.field_150816_i.containsKey(p_177426_1_))
{
@@ -882,6 +881,7 @@
@@ -882,6 +880,7 @@
p_177426_2_.func_145829_t();
this.field_150816_i.put(p_177426_1_, p_177426_2_);
@@ -160,7 +147,7 @@
}
}
@@ -910,8 +910,9 @@
@@ -910,8 +909,9 @@
entity.func_110123_P();
}
@@ -171,7 +158,7 @@
}
public void func_76623_d()
@@ -927,6 +928,7 @@
@@ -927,6 +927,7 @@
{
this.field_76637_e.func_175681_c(this.field_76645_j[i]);
}
@@ -179,7 +166,7 @@
}
public void func_76630_e()
@@ -936,8 +938,8 @@
@@ -936,8 +937,8 @@
public void func_177414_a(Entity p_177414_1_, AxisAlignedBB p_177414_2_, List<Entity> p_177414_3_, Predicate <? super Entity > p_177414_4_)
{
@@ -190,7 +177,7 @@
i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1);
j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1);
@@ -976,8 +978,8 @@
@@ -976,8 +977,8 @@
public <T extends Entity> void func_177430_a(Class <? extends T > p_177430_1_, AxisAlignedBB p_177430_2_, List<T> p_177430_3_, Predicate <? super T > p_177430_4_)
{
@@ -201,7 +188,7 @@
i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1);
j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1);
@@ -1137,8 +1139,10 @@
@@ -1137,8 +1138,10 @@
while (!this.field_177447_w.isEmpty())
{
BlockPos blockpos = (BlockPos)this.field_177447_w.poll();
@@ -213,7 +200,7 @@
{
TileEntity tileentity = this.func_177422_i(blockpos);
this.field_76637_e.func_175690_a(blockpos, tileentity);
@@ -1200,6 +1204,13 @@
@@ -1200,6 +1203,13 @@
@SideOnly(Side.CLIENT)
public void func_177439_a(byte[] p_177439_1_, int p_177439_2_, boolean p_177439_3_)
{
@@ -227,7 +214,7 @@
int i = 0;
boolean flag = !this.field_76637_e.field_73011_w.func_177495_o();
@@ -1267,10 +1278,16 @@
@@ -1267,10 +1277,16 @@
this.field_76646_k = true;
this.func_76590_a();
@@ -244,7 +231,7 @@
}
public BiomeGenBase func_177411_a(BlockPos p_177411_1_, WorldChunkManager p_177411_2_)
@@ -1583,4 +1600,20 @@
@@ -1583,4 +1599,20 @@
QUEUED,
CHECK;
}
@@ -5,7 +5,7 @@
Block block = p_180709_1_.func_180495_p(blockpos$mutableblockpos.func_181079_c(k1, i1, l1)).func_177230_c();
- if (block.func_149688_o() != Material.field_151579_a && block.func_149688_o() != Material.field_151584_j)
+ if (!block.isAir(p_180709_1_, blockpos$mutableblockpos) && !block.isLeaves(p_180709_1_, blockpos$mutableblockpos))
+ if (block.isAir(p_180709_1_, blockpos$mutableblockpos) && !block.isLeaves(p_180709_1_, blockpos$mutableblockpos))
{
flag = false;
}
@@ -4,7 +4,7 @@
i = 6;
}
+ i = getModdedBiomeSize(p_180781_2_, i);
+ i = getModdedBiomeSize(p_180781_2_, j);
+
GenLayer lvt_8_1_ = GenLayerZoom.func_75915_a(1000L, genlayer4, 0);
GenLayerRiverInit genlayerriverinit = new GenLayerRiverInit(100L, lvt_8_1_);
@@ -51,7 +51,12 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IRegistry;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
@@ -75,7 +80,6 @@ import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.common.ForgeVersion.Status;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.commons.lang3.tuple.Pair;
@@ -160,7 +164,7 @@ public class ForgeHooksClient
public static ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int slotID, ModelBiped _default)
{
ModelBiped model = itemStack.getItem().getArmorModel(entityLiving, itemStack, slotID, _default);
ModelBiped model = itemStack.getItem().getArmorModel(entityLiving, itemStack, slotID);
return model == null ? _default : model;
}
@@ -196,12 +200,6 @@ public class ForgeHooksClient
MinecraftForge.EVENT_BUS.post(fovUpdateEvent);
return fovUpdateEvent.newfov;
}
public static float getFOVModifier(EntityRenderer renderer, Entity entity, Block block, double renderPartialTicks, float fov) {
EntityViewRenderEvent.FOVModifier event = new EntityViewRenderEvent.FOVModifier(renderer, entity, block, renderPartialTicks, fov);
MinecraftForge.EVENT_BUS.post(event);
return event.getFOV();
}
private static int skyX, skyZ;
@@ -389,7 +387,7 @@ public class ForgeHooksClient
}
else
{
model.getItemCameraTransforms().applyTransform(cameraTransformType);
model.getItemCameraTransforms().func_181689_a(cameraTransformType);
}
return model;
}
@@ -414,30 +412,28 @@ public class ForgeHooksClient
public static void preDraw(EnumUsage attrType, VertexFormat format, int element, int stride, ByteBuffer buffer)
{
VertexFormatElement attr = format.getElement(element);
int count = attr.getElementCount();
int constant = attr.getType().getGlConstant();
buffer.position(format.func_181720_d(element));
switch(attrType)
{
case POSITION:
glVertexPointer(count, constant, stride, buffer);
glVertexPointer(attr.getElementCount(), attr.getType().getGlConstant(), stride, buffer);
glEnableClientState(GL_VERTEX_ARRAY);
break;
case NORMAL:
if(count != 3)
if(attr.getElementCount() != 3)
{
throw new IllegalArgumentException("Normal attribute should have the size 3: " + attr);
}
glNormalPointer(constant, stride, buffer);
glNormalPointer(attr.getType().getGlConstant(), stride, buffer);
glEnableClientState(GL_NORMAL_ARRAY);
break;
case COLOR:
glColorPointer(count, constant, stride, buffer);
glColorPointer(attr.getElementCount(), attr.getType().getGlConstant(), stride, buffer);
glEnableClientState(GL_COLOR_ARRAY);
break;
case UV:
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + attr.getIndex());
glTexCoordPointer(count, constant, stride, buffer);
glTexCoordPointer(attr.getElementCount(), attr.getType().getGlConstant(), stride, buffer);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
break;
@@ -445,7 +441,7 @@ public class ForgeHooksClient
break;
case GENERIC:
glEnableVertexAttribArray(attr.getIndex());
glVertexAttribPointer(attr.getIndex(), count, constant, false, stride, buffer);
glVertexAttribPointer(attr.getIndex(), attr.getElementCount(), attr.getType().getGlConstant(), false, stride, buffer);
default:
FMLLog.severe("Unimplemented vanilla attribute upload: %s", attrType.getDisplayName());
}
@@ -580,16 +576,4 @@ public class ForgeHooksClient
if(part.isPresent()) return Optional.absent();
return Optional.of(new TRSRTransformation(matrix));
}
public static void loadEntityShader(Entity entity, EntityRenderer entityRenderer)
{
if (entity != null)
{
ResourceLocation shader = ClientRegistry.getEntityShader(entity.getClass());
if (shader != null)
{
entityRenderer.loadShader(shader);
}
}
}
}
@@ -153,7 +153,7 @@ public class GuiIngameForge extends GuiIngame
Scoreboard scoreboard = this.mc.theWorld.getScoreboard();
ScoreObjective objective = null;
ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(mc.thePlayer.getName());
ScorePlayerTeam scoreplayerteam = scoreboard.getPlayersTeam(mc.thePlayer.getCommandSenderName());
if (scoreplayerteam != null)
{
int slot = scoreplayerteam.getChatFormat().getColorIndex();
@@ -205,7 +205,6 @@ public class GuiIngameForge extends GuiIngame
protected void renderBossHealth()
{
if (pre(BOSSHEALTH)) return;
bind(Gui.icons);
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
mc.mcProfiler.startSection("bossHealth");
GlStateManager.enableBlend();
@@ -277,7 +276,7 @@ public class GuiIngameForge extends GuiIngame
if (f1 > 0.0F)
{
renderPortal(f1, res);
func_180474_b(f1, res);
}
post(PORTAL);
@@ -6,18 +6,7 @@
package net.minecraftforge.client;
import java.util.BitSet;
import java.util.concurrent.TimeUnit;
import net.minecraft.client.renderer.RegionRenderCache;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
public class MinecraftForgeClient
{
@@ -67,29 +56,4 @@ public class MinecraftForgeClient
stencilBits.set(bit);
}
}
private static final LoadingCache<Pair<World, BlockPos>, RegionRenderCache> regionCache = CacheBuilder.newBuilder()
.maximumSize(500)
.concurrencyLevel(5)
.expireAfterAccess(1, TimeUnit.SECONDS)
.build(new CacheLoader<Pair<World, BlockPos>, RegionRenderCache>()
{
public RegionRenderCache load(Pair<World, BlockPos> key) throws Exception
{
return new RegionRenderCache(key.getLeft(), key.getRight().add(-1, -1, -1), key.getRight().add(16, 16, 16), 1);
}
});
public static void onRebuildChunk(World world, BlockPos position, RegionRenderCache cache)
{
regionCache.put(Pair.of(world, position), cache);
}
public static RegionRenderCache getRegionRenderCache(World world, BlockPos pos)
{
int x = pos.getX() & ~0xF;
int y = pos.getY() & ~0xF;
int z = pos.getZ() & ~0xF;
return regionCache.getUnchecked(Pair.of(world, new BlockPos(x, y, z)));
}
}
@@ -7,8 +7,8 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
/**
* Event that hooks into EntityRenderer, allowing any feature to customize visual attributes
* the player sees.
* Event that hooks into EntityRenderer, allowing any feature to customize visual attributes of
* fog the player sees.
*/
public abstract class EntityViewRenderEvent extends Event
{
@@ -94,26 +94,4 @@ public abstract class EntityViewRenderEvent extends Event
this.roll = roll;
}
}
/**
* Event that allows mods to alter the raw FOV itself.
* This directly affects to the FOV without being modified.
* */
public static class FOVModifier extends EntityViewRenderEvent
{
private float fov;
public FOVModifier(EntityRenderer renderer, Entity entity, Block block, double renderPartialTicks, float fov) {
super(renderer, entity, block, renderPartialTicks);
this.setFOV(fov);
}
public float getFOV() {
return fov;
}
public void setFOV(float fov) {
this.fov = fov;
}
}
}
@@ -3,12 +3,8 @@ package net.minecraftforge.client.event;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Mouse;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.relauncher.Side;
@@ -123,42 +119,6 @@ public class GuiScreenEvent extends Event
}
}
}
/**
* This event fires at the end of {@code GuiScreen.drawDefaultBackground()} and before the rest of the Gui draws.
* This allows drawing next to Guis, above the background but below any tooltips.
*/
public static class BackgroundDrawnEvent extends GuiScreenEvent
{
private final int mouseX;
private final int mouseY;
public BackgroundDrawnEvent(GuiScreen gui)
{
super(gui);
final ScaledResolution scaledresolution = new ScaledResolution(gui.mc);
final int scaledWidth = scaledresolution.getScaledWidth();
final int scaledHeight = scaledresolution.getScaledHeight();
this.mouseX = Mouse.getX() * scaledWidth / gui.mc.displayWidth;
this.mouseY = scaledHeight - Mouse.getY() * scaledHeight / gui.mc.displayHeight - 1;
}
/**
* The x coordinate of the mouse pointer on the screen.
*/
public int getMouseX()
{
return mouseX;
}
/**
* The y coordinate of the mouse pointer on the screen.
*/
public int getMouseY()
{
return mouseY;
}
}
public static class ActionPerformedEvent extends GuiScreenEvent
{
@@ -17,10 +17,10 @@ public class Attributes
static
{
DEFAULT_BAKED_FORMAT = new VertexFormat();
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, EnumType.FLOAT, EnumUsage.POSITION, 3));
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, EnumType.UBYTE, EnumUsage.COLOR, 4));
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, EnumType.FLOAT, EnumUsage.UV, 2));
DEFAULT_BAKED_FORMAT.addElement(new VertexFormatElement(0, EnumType.BYTE, EnumUsage.PADDING, 4));
DEFAULT_BAKED_FORMAT.func_181721_a(new VertexFormatElement(0, EnumType.FLOAT, EnumUsage.POSITION, 3));
DEFAULT_BAKED_FORMAT.func_181721_a(new VertexFormatElement(0, EnumType.UBYTE, EnumUsage.COLOR, 4));
DEFAULT_BAKED_FORMAT.func_181721_a(new VertexFormatElement(0, EnumType.FLOAT, EnumUsage.UV, 2));
DEFAULT_BAKED_FORMAT.func_181721_a(new VertexFormatElement(0, EnumType.BYTE, EnumUsage.PADDING, 4));
}
/*
@@ -63,14 +63,12 @@ public class BlockStateLoader
for (ForgeBlockStateV1.Variant var : entry.getValue())
{
boolean uvLock = var.getUvLock().or(false);
boolean smooth = var.getSmooth().or(true);
boolean gui3d = var.getGui3d().or(true);
int weight = var.getWeight().or(1);
if (var.getModel() != null && var.getSubmodels().size() == 0 && var.getTextures().size() == 0 && var.getCustomData().size() == 0 && var.getState().orNull() instanceof ModelRotation)
mcVars.add(new ModelBlockDefinition.Variant(var.getModel(), (ModelRotation)var.getState().get(), uvLock, weight));
else
mcVars.add(new ForgeVariant(var.getModel(), var.getState().or(TRSRTransformation.identity()), uvLock, smooth, gui3d, weight, var.getTextures(), var.getOnlyPartsVariant(), var.getCustomData()));
mcVars.add(new ForgeVariant(var.getModel(), var.getState().or(TRSRTransformation.identity()), uvLock, weight, var.getTextures(), var.getOnlyPartsVariant(), var.getCustomData()));
}
variants.add(new ModelBlockDefinition.Variants(entry.getKey(), mcVars));
}
@@ -98,24 +96,14 @@ public class BlockStateLoader
{
private final IModelState state;
private final boolean uvLock;
private final boolean smooth;
private final boolean gui3d;
private final ImmutableMap<String, String> textures;
private final ResourceLocation model;
private final ImmutableMap<String, String> customData;
@Deprecated // remove in 1.9
public SubModel(IModelState state, boolean uvLock, ImmutableMap<String, String> textures, ResourceLocation model, ImmutableMap<String, String> customData)
{
this(state, uvLock, true, true, textures, model, customData);
}
public SubModel(IModelState state, boolean uvLock, boolean smooth, boolean gui3d, ImmutableMap<String, String> textures, ResourceLocation model, ImmutableMap<String, String> customData)
{
this.state = state;
this.uvLock = uvLock;
this.smooth = smooth;
this.gui3d = gui3d;
this.textures = textures;
this.model = model;
this.customData = customData;
@@ -133,36 +121,33 @@ public class BlockStateLoader
private final ImmutableMap<String, String> textures;
private final ImmutableMap<String, SubModel> parts;
private final ImmutableMap<String, String> customData;
private final boolean smooth;
private final boolean gui3d;
private final IModelState state;
public ForgeVariant(ResourceLocation model, IModelState state, boolean uvLock, boolean smooth, boolean gui3d, int weight, ImmutableMap<String, String> textures, ImmutableMap<String, SubModel> parts, ImmutableMap<String, String> customData)
public ForgeVariant(ResourceLocation model, IModelState state, boolean uvLock, int weight, ImmutableMap<String, String> textures, ImmutableMap<String, SubModel> parts, ImmutableMap<String, String> customData)
{
super(model == null ? new ResourceLocation("builtin/missing") : model, state instanceof ModelRotation ? (ModelRotation)state : ModelRotation.X0_Y0, uvLock, weight);
this.textures = textures;
this.parts = parts;
this.customData = customData;
this.state = state;
this.smooth = smooth;
this.gui3d = gui3d;
}
private IModel runModelHooks(IModel base, boolean smooth, boolean gui3d, ImmutableMap<String, String> textureMap, ImmutableMap<String, String> customData)
protected IModel runModelHooks(IModel base, ImmutableMap<String, String> textureMap, ImmutableMap<String, String> customData)
{
if (!customData.isEmpty() && base instanceof IModelCustomData)
if (!customData.isEmpty())
{
base = ((IModelCustomData<?>)base).process(customData);
if (base instanceof IModelCustomData)
base = ((IModelCustomData)base).process(customData);
else
throw new RuntimeException("Attempted to add custom data to a model that doesn't need it: " + base);
}
if (!textureMap.isEmpty() && base instanceof IRetexturableModel)
if (!textureMap.isEmpty())
{
base = ((IRetexturableModel<?>)base).retexture(textureMap);
}
if (base instanceof IModelSimpleProperties<?>)
{
base = ((IModelSimpleProperties<?>) base).smoothLighting(smooth).gui3d(gui3d);
if (base instanceof IRetexturableModel)
base = ((IRetexturableModel)base).retexture(textureMap);
else
throw new RuntimeException("Attempted to retexture a non-retexturable model: " + base);
}
return base;
@@ -179,7 +164,7 @@ public class BlockStateLoader
if (hasBase)
{
base = runModelHooks(base, smooth, gui3d, textures, customData);
base = runModelHooks(base, textures, customData);
if (size <= 0)
return base;
@@ -208,7 +193,7 @@ public class BlockStateLoader
IModelState partState = new ModelStateComposition(baseTr, part.getState());
if (part.isUVLock()) partState = new ModelLoader.UVLock(partState);
models.put(entry.getKey(), Pair.<IModel, IModelState>of(runModelHooks(model, part.smooth, part.gui3d, part.getTextures(), part.getCustomData()), partState));
models.put(entry.getKey(), Pair.<IModel, IModelState>of(runModelHooks(model, part.getTextures(), part.getCustomData()), partState));
}
return new MultiModel(getModelLocation(), hasBase ? base : null, baseTr, models.build());
@@ -275,8 +275,6 @@ public class ForgeBlockStateV1 extends Marker
private boolean modelSet = false;
private Optional<IModelState> state = Optional.absent();
private Optional<Boolean> uvLock = Optional.absent();
private Optional<Boolean> smooth = Optional.absent();
private Optional<Boolean> gui3d = Optional.absent();
private Optional<Integer> weight = Optional.absent();
private Map<String, String> textures = Maps.newHashMap();
private Map<String, List<ForgeBlockStateV1.Variant>> submodels = Maps.newHashMap();
@@ -294,8 +292,6 @@ public class ForgeBlockStateV1 extends Marker
this.modelSet = other.modelSet;
this.state = other.state;
this.uvLock = other.uvLock;
this.smooth = other.smooth;
this.gui3d = other.gui3d;
this.weight = other.weight;
this.textures.putAll(other.textures);
this.mergeModelPartVariants(this.submodels, other.submodels);
@@ -315,8 +311,6 @@ public class ForgeBlockStateV1 extends Marker
}
if (!this.state.isPresent()) this.state = parent.state;
if (!this.uvLock.isPresent()) this.uvLock = parent.uvLock;
if (!this.smooth.isPresent()) this.smooth = parent.smooth;
if (!this.gui3d.isPresent()) this.gui3d = parent.gui3d;
if (!this.weight.isPresent()) this.weight = parent.weight;
for (Entry<String, String> e : parent.textures.entrySet())
@@ -406,16 +400,6 @@ public class ForgeBlockStateV1 extends Marker
}
}
public Optional<Boolean> getSmooth()
{
return smooth;
}
public Optional<Boolean> getGui3d()
{
return gui3d;
}
public static class Deserializer implements JsonDeserializer<ForgeBlockStateV1.Variant>
{
static Variant.Deserializer INSTANCE = new Deserializer();
@@ -609,16 +593,6 @@ public class ForgeBlockStateV1 extends Marker
ret.uvLock = Optional.of(JsonUtils.getBoolean(json, "uvlock"));
}
if (json.has("smooth_lighting"))
{
ret.smooth = Optional.of(JsonUtils.getBoolean(json, "smooth_lighting"));
}
if (json.has("gui3d"))
{
ret.gui3d = Optional.of(JsonUtils.getBoolean(json, "gui3d"));
}
if (json.has("weight"))
{ // Load weight.
ret.weight = Optional.of(JsonUtils.getInt(json, "weight"));
@@ -59,9 +59,9 @@ public interface IFlexibleBakedModel extends IBakedModel
return parent.isBuiltInRenderer();
}
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getTexture()
{
return parent.getParticleTexture();
return parent.getTexture();
}
@Deprecated
@@ -17,7 +17,6 @@ public interface IModel
/*
* Returns all model locations that this model depends on.
* Assume that returned collection is immutable.
* See ModelLoaderRegistry.getModel for dependency loading.
*/
Collection<ResourceLocation> getDependencies();
@@ -2,13 +2,11 @@ package net.minecraftforge.client.model;
import com.google.common.collect.ImmutableMap;
public interface IModelCustomData<M extends IModelCustomData<M>> extends IModel
public interface IModelCustomData extends IModel
{
/**
* Allows the model to process custom data from the variant definition.
* If unknown data is encountered it should be skipped.
* @return a new model, with data applied.
* Allows the model to process custom data from the variant definition
* @return a new model, with data applied
*/
// 1.9: change IModel to M
IModel process(ImmutableMap<String, String> customData);
}
@@ -1,10 +0,0 @@
package net.minecraftforge.client.model;
/**
* Implement this if the model can process "smooth_lighting" or "gui3d" attributes from the json.
*/
public interface IModelSimpleProperties<M extends IModelSimpleProperties<M>> extends IModel
{
M smoothLighting(boolean value);
M gui3d(boolean value);
}
@@ -1,12 +0,0 @@
package net.minecraftforge.client.model;
import com.google.common.collect.ImmutableSet;
/**
* Created by rainwarrior on 2/2/16.
*/
public interface IModelWithSubmodels<M extends IModelWithSubmodels<M>> extends IModel
{
M setDefaultSubmodelEnabled (boolean value);
M setSubmodelsEnabled(ImmutableSet<String> submodelNames, boolean show);
}
@@ -63,7 +63,7 @@ public interface IPerspectiveAwareModel extends IFlexibleBakedModel
ImmutableMap.Builder<TransformType, TRSRTransformation> builder = ImmutableMap.builder();
for(TransformType type : TransformType.values())
{
builder.put(type, new TRSRTransformation(transforms.getTransform(type)));
builder.put(type, new TRSRTransformation(transforms.func_181688_b(type)));
}
return builder.build();
}
@@ -72,7 +72,7 @@ public interface IPerspectiveAwareModel extends IFlexibleBakedModel
{
TRSRTransformation tr = transforms.get(cameraTransformType);
Matrix4f mat = null;
if(tr != null && !tr.equals(TRSRTransformation.identity())) mat = TRSRTransformation.blockCornerToCenter(tr).getMatrix();
if(tr != null && tr != TRSRTransformation.identity()) mat = TRSRTransformation.blockCornerToCenter(tr).getMatrix();
return Pair.of(model, mat);
}
@@ -89,7 +89,7 @@ public interface IPerspectiveAwareModel extends IFlexibleBakedModel
public boolean isAmbientOcclusion() { return parent.isAmbientOcclusion(); }
public boolean isGui3d() { return parent.isGui3d(); }
public boolean isBuiltInRenderer() { return parent.isBuiltInRenderer(); }
public TextureAtlasSprite getParticleTexture() { return parent.getParticleTexture(); }
public TextureAtlasSprite getTexture() { return parent.getTexture(); }
public ItemCameraTransforms getItemCameraTransforms() { return parent.getItemCameraTransforms(); }
public List<BakedQuad> getFaceQuads(EnumFacing side) { return parent.getFaceQuads(side); }
public List<BakedQuad> getGeneralQuads() { return parent.getGeneralQuads(); }
@@ -2,7 +2,7 @@ package net.minecraftforge.client.model;
import com.google.common.collect.ImmutableMap;
public interface IRetexturableModel<M extends IRetexturableModel<M>> extends IModel
public interface IRetexturableModel extends IModel
{
/**
* Applies new textures to the model.
@@ -21,6 +21,5 @@ public interface IRetexturableModel<M extends IRetexturableModel<M>> extends IMo
* @param textures New
* @return Model with textures applied.
*/
// 1.9: change IModel to M
IModel retexture(ImmutableMap<String, String> textures);
}
@@ -53,9 +53,9 @@ public interface ISmartBlockModel extends IBakedModel
return parent.isBuiltInRenderer();
}
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getTexture()
{
return parent.getParticleTexture();
return parent.getTexture();
}
public ItemCameraTransforms getItemCameraTransforms()
@@ -5,11 +5,8 @@ import java.util.BitSet;
import java.util.Collection;
import java.util.List;
import javax.vecmath.Matrix4f;
import javax.vecmath.Vector4f;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
@@ -26,7 +23,7 @@ import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
public class ItemLayerModel implements IRetexturableModel<ItemLayerModel>
public class ItemLayerModel implements IRetexturableModel
{
public static final ItemLayerModel instance = new ItemLayerModel(ImmutableList.<ResourceLocation>of());
@@ -71,16 +68,12 @@ public class ItemLayerModel implements IRetexturableModel<ItemLayerModel>
public IModel retexture(ImmutableMap<String, String> textures)
{
ImmutableList.Builder<ResourceLocation> builder = ImmutableList.builder();
for(int i = 0; i < textures.size() + this.textures.size(); i++)
for(int i = 0; i < textures.size(); i++)
{
if(textures.containsKey("layer" + i))
{
builder.add(new ResourceLocation(textures.get("layer" + i)));
}
else if(i < this.textures.size())
{
builder.add(this.textures.get(i));
}
}
return new ItemLayerModel(builder.build());
}
@@ -96,10 +89,14 @@ public class ItemLayerModel implements IRetexturableModel<ItemLayerModel>
}
TextureAtlasSprite particle = bakedTextureGetter.apply(textures.isEmpty() ? new ResourceLocation("missingno") : textures.get(0));
ImmutableMap<TransformType, TRSRTransformation> map = IPerspectiveAwareModel.MapWrapper.getTransforms(state);
return new BakedItemModel(builder.build(), particle, format, map, null);
IFlexibleBakedModel ret = new BakedModel(builder.build(), particle, format);
if(map.isEmpty())
{
return ret;
}
return new IPerspectiveAwareModel.MapWrapper(ret, map);
}
@Deprecated // remove 1.9
public static class BakedModel implements IFlexibleBakedModel
{
private final ImmutableList<BakedQuad> quads;
@@ -116,72 +113,13 @@ public class ItemLayerModel implements IRetexturableModel<ItemLayerModel>
public boolean isAmbientOcclusion() { return true; }
public boolean isGui3d() { return false; }
public boolean isBuiltInRenderer() { return false; }
public TextureAtlasSprite getParticleTexture() { return particle; }
public TextureAtlasSprite getTexture() { return particle; }
public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
public List<BakedQuad> getFaceQuads(EnumFacing side) { return ImmutableList.of(); }
public List<BakedQuad> getGeneralQuads() { return quads; }
public VertexFormat getFormat() { return format; }
}
private static class BakedItemModel implements IFlexibleBakedModel, IPerspectiveAwareModel
{
private final ImmutableList<BakedQuad> quads;
private final TextureAtlasSprite particle;
private final VertexFormat format;
private final ImmutableMap<TransformType, TRSRTransformation> transforms;
private final IFlexibleBakedModel otherModel;
private final boolean isCulled;
public BakedItemModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, VertexFormat format, ImmutableMap<TransformType, TRSRTransformation> transforms, IFlexibleBakedModel otherModel)
{
this.quads = quads;
this.particle = particle;
this.format = format;
this.transforms = transforms;
if(otherModel != null)
{
this.otherModel = otherModel;
this.isCulled = true;
}
else
{
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
for(BakedQuad quad : quads)
{
if(quad.getFace() == EnumFacing.SOUTH)
{
builder.add(quad);
}
}
this.otherModel = new BakedItemModel(builder.build(), particle, format, transforms, this);
isCulled = false;
}
}
public boolean isAmbientOcclusion() { return true; }
public boolean isGui3d() { return false; }
public boolean isBuiltInRenderer() { return false; }
public TextureAtlasSprite getParticleTexture() { return particle; }
public ItemCameraTransforms getItemCameraTransforms() { return ItemCameraTransforms.DEFAULT; }
public List<BakedQuad> getFaceQuads(EnumFacing side) { return ImmutableList.of(); }
public List<BakedQuad> getGeneralQuads() { return quads; }
public VertexFormat getFormat() { return format; }
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType type)
{
Pair<? extends IFlexibleBakedModel, Matrix4f> pair = IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, type);
if(type == TransformType.GUI && !isCulled && pair.getRight() == null)
{
return Pair.of(otherModel, null);
}
else if(type != TransformType.GUI && isCulled)
{
return Pair.of(otherModel, pair.getRight());
}
return pair;
}
}
public ImmutableList<BakedQuad> getQuadsForSprite(int tint, TextureAtlasSprite sprite, VertexFormat format, Optional<TRSRTransformation> transform)
{
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
@@ -8,7 +8,6 @@ import com.google.common.collect.ImmutableMap;
/*
* Simple implementation of IModelState via a map and a default value. Provides a full state for each part.
* You probably don't want to use this.
*/
public class MapModelState implements IModelState
{
@@ -27,7 +27,7 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Map;
public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>, IRetexturableModel<ModelDynBucket>
public class ModelDynBucket implements IModel, IModelCustomData, IRetexturableModel
{
public static final ModelResourceLocation LOCATION = new ModelResourceLocation(new ResourceLocation("forge", "dynbucket"), "inventory");
@@ -48,7 +48,7 @@ public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>,
public ModelDynBucket()
{
this(null, null, null, null, false);
this(null, null, null, FluidRegistry.WATER, false);
}
public ModelDynBucket(ResourceLocation baseLocation, ResourceLocation liquidLocation, ResourceLocation coverLocation, Fluid fluid, boolean flipGas)
@@ -88,26 +88,22 @@ public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>,
ImmutableMap<TransformType, TRSRTransformation> transformMap = IPerspectiveAwareModel.MapWrapper.getTransforms(state);
// if the fluid is a gas wi manipulate the initial state to be rotated 180° to turn it upside down
if (flipGas && fluid != null && fluid.isGaseous())
if (flipGas && fluid.isGaseous())
{
state = new ModelStateComposition(state, TRSRTransformation.blockCenterToCorner(new TRSRTransformation(null, new Quat4f(0, 0, 1, 0), null, null)));
}
TRSRTransformation transform = state.apply(Optional.<IModelPart>absent()).or(TRSRTransformation.identity());
TextureAtlasSprite fluidSprite = null;
TextureAtlasSprite fluidSprite = bakedTextureGetter.apply(fluid.getStill());
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
if(fluid != null) {
fluidSprite = bakedTextureGetter.apply(fluid.getStill());
}
if (baseLocation != null)
{
// build base (insidest)
IFlexibleBakedModel model = (new ItemLayerModel(ImmutableList.of(baseLocation))).bake(state, format, bakedTextureGetter);
builder.addAll(model.getGeneralQuads());
}
if (liquidLocation != null && fluidSprite != null)
if (liquidLocation != null)
{
TextureAtlasSprite liquid = bakedTextureGetter.apply(liquidLocation);
// build liquid layer (inside)
@@ -243,10 +239,7 @@ public class ModelDynBucket implements IModel, IModelCustomData<ModelDynBucket>,
// not a fluid item apparently
if (fluidStack == null)
{
// empty bucket
return this;
}
Fluid fluid = fluidStack.getFluid();
@@ -5,7 +5,6 @@ import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import javax.vecmath.Matrix4f;
import javax.vecmath.Vector4f;
import net.minecraft.block.state.IBlockState;
@@ -28,13 +27,8 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -43,7 +37,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
@SuppressWarnings("deprecation")
public class ModelFluid implements IModelCustomData<ModelFluid>
public class ModelFluid implements IModelCustomData
{
public static final ModelFluid waterModel = new ModelFluid(FluidRegistry.WATER);
public static final ModelFluid lavaModel = new ModelFluid(FluidRegistry.LAVA);
@@ -67,7 +61,12 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableMap<TransformType, TRSRTransformation> map = IPerspectiveAwareModel.MapWrapper.getTransforms(state);
return new BakedFluid(state.apply(Optional.<IModelPart>absent()), map, format, fluid.getColor(), bakedTextureGetter.apply(fluid.getStill()), bakedTextureGetter.apply(fluid.getFlowing()), fluid.isGaseous(), Optional.<IExtendedBlockState>absent());
IFlexibleBakedModel ret = new BakedFluid(state.apply(Optional.<IModelPart>absent()), format, fluid.getColor(), bakedTextureGetter.apply(fluid.getStill()), bakedTextureGetter.apply(fluid.getFlowing()), fluid.isGaseous());
if(map.isEmpty())
{
return ret;
}
return new IPerspectiveAwareModel.MapWrapper(ret, map);
}
public IModelState getDefaultState()
@@ -95,35 +94,18 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
}
}
public static class BakedFluid implements IFlexibleBakedModel, ISmartBlockModel, IPerspectiveAwareModel
public static class BakedFluid implements IFlexibleBakedModel, ISmartBlockModel
{
private static final int x[] = { 0, 0, 1, 1 };
private static final int z[] = { 0, 1, 1, 0 };
private static final float eps = 1e-3f;
private final LoadingCache<Long, BakedFluid> modelCache = CacheBuilder.newBuilder().maximumSize(200).build(new CacheLoader<Long, BakedFluid>()
{
public BakedFluid load(Long key) throws Exception
{
boolean statePresent = (key & 1) != 0;
key >>>= 1;
int[] cornerRound = new int[4];
for(int i = 0; i < 4; i++)
{
cornerRound[i] = (int)(key & 0x3FF);
key >>>= 10;
}
int flowRound = (int)(key & 0x7FF) - 1024;
return new BakedFluid(transformation, transforms, format, color, still, flowing, gas, statePresent, cornerRound, flowRound);
}
});
private final Optional<TRSRTransformation> transformation;
private final ImmutableMap<TransformType, TRSRTransformation> transforms;
private final VertexFormat format;
private final int color;
private final TextureAtlasSprite still, flowing;
private final boolean gas;
private final Optional<IExtendedBlockState> state;
private final EnumMap<EnumFacing, List<BakedQuad>> faceQuads;
public BakedFluid(Optional<TRSRTransformation> transformation, VertexFormat format, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, boolean gas)
@@ -132,52 +114,14 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
}
public BakedFluid(Optional<TRSRTransformation> transformation, VertexFormat format, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, boolean gas, Optional<IExtendedBlockState> stateOption)
{
this(transformation, ImmutableMap.<TransformType, TRSRTransformation>of(), format, color, still, flowing, gas, stateOption);
}
public BakedFluid(Optional<TRSRTransformation> transformation, ImmutableMap<TransformType, TRSRTransformation> transforms, VertexFormat format, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, boolean gas, Optional<IExtendedBlockState> stateOption)
{
this(transformation, transforms, format, color, still, flowing, gas, stateOption.isPresent(), getCorners(stateOption), getFlow(stateOption));
}
private static int[] getCorners(Optional<IExtendedBlockState> stateOption)
{
int[] cornerRound = new int[]{0, 0, 0, 0};
if(stateOption.isPresent())
{
IExtendedBlockState state = stateOption.get();
for(int i = 0; i < 4; i++)
{
Float level = state.getValue(BlockFluidBase.LEVEL_CORNERS[i]);
cornerRound[i] = Math.round((level == null ? 7f / 8 : level) * 768);
}
}
return cornerRound;
}
private static int getFlow(Optional<IExtendedBlockState> stateOption)
{
Float flow = -1000f;
if(stateOption.isPresent())
{
flow = stateOption.get().getValue(BlockFluidBase.FLOW_DIRECTION);
if(flow == null) flow = -1000f;
}
int flowRound = (int)Math.round(Math.toDegrees(flow));
flowRound = MathHelper.clamp_int(flowRound, -1000, 1000);
return flowRound;
}
public BakedFluid(Optional<TRSRTransformation> transformation, ImmutableMap<TransformType, TRSRTransformation> transforms, VertexFormat format, int color, TextureAtlasSprite still, TextureAtlasSprite flowing, boolean gas, boolean statePresent, int[] cornerRound, int flowRound)
{
this.transformation = transformation;
this.transforms = transforms;
this.format = format;
this.color = color;
this.still = still;
this.flowing = flowing;
this.gas = gas;
this.state = stateOption;
faceQuads = Maps.newEnumMap(EnumFacing.class);
for(EnumFacing side : EnumFacing.values())
@@ -185,28 +129,29 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
faceQuads.put(side, ImmutableList.<BakedQuad>of());
}
if(statePresent)
if(state.isPresent())
{
IExtendedBlockState state = this.state.get();
float[] y = new float[4];
for(int i = 0; i < 4; i++)
{
if(gas)
{
y[i] = 1 - cornerRound[i] / 768f;
y[i] = 1 - state.getValue(BlockFluidBase.LEVEL_CORNERS[i]);
}
else
{
y[i] = cornerRound[i] / 768f;
y[i] = state.getValue(BlockFluidBase.LEVEL_CORNERS[i]);
}
}
float flow = (float)Math.toRadians(flowRound);
float flow = state.getValue(BlockFluidBase.FLOW_DIRECTION);
// top
TextureAtlasSprite topSprite = flowing;
float scale = 4;
if(flow < -17F)
if(flow < -999F)
{
flow = 0;
scale = 8;
@@ -277,6 +222,7 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
else
{
// 1 quad for inventory
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder(format);
builder.setQuadOrientation(EnumFacing.UP);
builder.setQuadColored();
@@ -285,8 +231,8 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
putVertex(
builder, EnumFacing.UP,
z[i], x[i], 0,
still.getInterpolatedU(z[i] * 16),
still.getInterpolatedV(x[i] * 16));
still.getInterpolatedU(x[i] * 16),
still.getInterpolatedV(z[i] * 16));
}
faceQuads.put(EnumFacing.SOUTH, ImmutableList.<BakedQuad>of(builder.build()));
}
@@ -296,11 +242,12 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
{
for(int e = 0; e < format.getElementCount(); e++)
{
// TODO transformation
switch(format.getElement(e).getUsage())
{
case POSITION:
float[] data = new float[]{ x - side.getDirectionVec().getX() * eps, y, z - side.getDirectionVec().getZ() * eps, 1 };
if(transformation.isPresent() && transformation.get() != TRSRTransformation.identity())
if(transformation.isPresent())
{
Vector4f vec = new Vector4f(data);
transformation.get().getMatrix().transform(vec);
@@ -333,7 +280,7 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
public boolean isAmbientOcclusion()
{
return false;
return false; // FIXME
}
public boolean isGui3d()
@@ -346,7 +293,7 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
return false;
}
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getTexture()
{
return still;
}
@@ -373,28 +320,7 @@ public class ModelFluid implements IModelCustomData<ModelFluid>
public IBakedModel handleBlockState(IBlockState state)
{
if(state instanceof IExtendedBlockState)
{
IExtendedBlockState exState = (IExtendedBlockState)state;
int[] cornerRound = getCorners(Optional.of(exState));
int flowRound = getFlow(Optional.of(exState));
long key = flowRound + 1024;
for(int i = 3; i >= 0; i--)
{
key <<= 10;
key |= cornerRound[i];
}
key <<= 1;
key |= 1;
return modelCache.getUnchecked(key);
}
return this;
}
@Override
public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(TransformType type)
{
return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, type);
return new BakedFluid(transformation, format, color, still, flowing, gas, Optional.of((IExtendedBlockState)state));
}
}
@@ -3,20 +3,18 @@ package net.minecraftforge.client.model;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.google.common.base.Joiner;
import com.google.common.collect.*;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
@@ -25,7 +23,6 @@ import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.renderer.block.model.BlockPart;
import net.minecraft.client.renderer.block.model.BlockPartFace;
import net.minecraft.client.renderer.block.model.BlockPartRotation;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.block.model.ItemModelGenerator;
@@ -51,24 +48,15 @@ import net.minecraft.client.resources.model.WeightedBakedModel;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IRegistry;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.animation.Animation;
import net.minecraftforge.client.model.animation.IAnimatedModel;
import net.minecraftforge.client.model.animation.IClip;
import net.minecraftforge.client.model.animation.ModelBlockAnimation;
import net.minecraftforge.common.ForgeModContainer;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.Properties;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.ProgressManager;
import net.minecraftforge.fml.common.ProgressManager.ProgressBar;
import net.minecraftforge.fml.common.registry.GameData;
import net.minecraftforge.fml.common.registry.RegistryDelegate;
@@ -77,15 +65,20 @@ import org.apache.commons.lang3.tuple.Pair;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@SuppressWarnings("ALL")
@SuppressWarnings("deprecation")
public class ModelLoader extends ModelBakery
{
private final Map<ModelResourceLocation, IModel> stateModels = Maps.newHashMap();
private final Set<ResourceLocation> textures = Sets.newHashSet();
private final Set<ResourceLocation> loadingModels = Sets.newHashSet();
private final Map<ModelResourceLocation, IModel> stateModels = new HashMap<ModelResourceLocation, IModel>();
private final Set<ResourceLocation> textures = new HashSet<ResourceLocation>();
private final Set<ResourceLocation> loadingModels = new HashSet<ResourceLocation>();
private final Set<ModelResourceLocation> missingVariants = Sets.newHashSet();
private final Map<ResourceLocation, Exception> loadingExceptions = Maps.newHashMap();
private IModel missingModel = null;
private IModel itemModel = new ItemLayerModel(MODEL_GENERATED);
@@ -95,8 +88,6 @@ public class ModelLoader extends ModelBakery
return isLoading;
}
private final boolean enableVerboseMissingInfo = (Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment") || Boolean.parseBoolean(System.getProperty("forge.verboseMissingModelLogging", "false"));
public ModelLoader(IResourceManager manager, TextureMap map, BlockModelShapes shapes)
{
super(manager, map, shapes);
@@ -132,7 +123,14 @@ public class ModelLoader extends ModelBakery
}
}
});
IFlexibleBakedModel missingBaked = missingModel.bake(missingModel.getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.instance);
Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
{
public TextureAtlasSprite apply(ResourceLocation location)
{
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
}
};
IFlexibleBakedModel missingBaked = missingModel.bake(missingModel.getDefaultState(), DefaultVertexFormats.ITEM, textureGetter);
for (Entry<ModelResourceLocation, IModel> e : stateModels.entrySet())
{
if(e.getValue() == getMissingModel())
@@ -141,7 +139,7 @@ public class ModelLoader extends ModelBakery
}
else
{
bakedRegistry.putObject(e.getKey(), e.getValue().bake(e.getValue().getDefaultState(), DefaultVertexFormats.ITEM, DefaultTextureGetter.instance));
bakedRegistry.putObject(e.getKey(), e.getValue().bake(e.getValue().getDefaultState(), DefaultVertexFormats.ITEM, textureGetter));
}
}
return bakedRegistry;
@@ -150,23 +148,10 @@ public class ModelLoader extends ModelBakery
private void loadBlocks()
{
Map<IBlockState, ModelResourceLocation> stateMap = blockModelShapes.getBlockStateMapper().putAllStateModelLocations();
List<ModelResourceLocation> variants = Lists.newArrayList(stateMap.values());
Collection<ModelResourceLocation> variants = Lists.newArrayList(stateMap.values());
variants.add(new ModelResourceLocation("minecraft:item_frame", "normal")); //Vanilla special cases item_frames so must we
variants.add(new ModelResourceLocation("minecraft:item_frame", "map"));
Collections.sort(variants, new Comparator<ModelResourceLocation>()
{
public int compare(ModelResourceLocation v1, ModelResourceLocation v2)
{
return v1.toString().compareTo(v2.toString());
}
});
ProgressBar blockBar = ProgressManager.push("ModelLoader: blocks", variants.size());
for(ModelResourceLocation variant : variants)
{
loadVariants(ImmutableList.of(variant));
blockBar.step(variant.toString());
}
ProgressManager.pop(blockBar);
loadVariants(variants);
}
@Override
@@ -194,77 +179,36 @@ public class ModelLoader extends ModelBakery
}
}
private void storeException(ResourceLocation location, Exception exception)
{
loadingExceptions.put(location, exception);
}
@Override
protected ModelBlockDefinition getModelBlockDefinition(ResourceLocation location)
{
try
{
return super.getModelBlockDefinition(location);
}
catch (Exception exception)
{
storeException(location, new Exception("Could not load model definition for variant " + location, exception));
}
return new ModelBlockDefinition(new ArrayList<ModelBlockDefinition>());
}
private void loadItems()
{
// register model for the universal bucket, if it exists
if(FluidRegistry.isUniversalBucketEnabled())
{
setBucketModelDefinition(ForgeModContainer.getInstance().universalBucket);
}
registerVariantNames();
List<String> itemVariants = Lists.newArrayList();
for(Item item : GameData.getItemRegistry().typeSafeIterable())
{
itemVariants.addAll(getVariantNames(item));
}
Collections.sort(itemVariants);
ProgressBar itemBar = ProgressManager.push("ModelLoader: items", itemVariants.size());
for(String s : itemVariants)
{
ResourceLocation file = getItemLocation(s);
ModelResourceLocation memory = getInventoryVariant(s);
itemBar.step(memory.toString());
IModel model = null;
try
// default loading
for(String s : (List<String>)getVariantNames(item))
{
// default loading
model = getModel(file);
if (model == null)
{
model = getMissingModel();
}
stateModels.put(memory, model);
}
catch (FileNotFoundException e)
{
// try blockstate json if the item model is missing
FMLLog.fine("Item json isn't found for '" + memory + "', trying to load the variant from the blockstate json");
ResourceLocation file = getItemLocation(s);
ModelResourceLocation memory = getInventoryVariant(s);
IModel model = null;
try
{
registerVariant(getModelBlockDefinition(memory), memory);
model = getModel(file);
}
catch (Exception exception)
catch (IOException e)
{
storeException(memory, new Exception("Could not load item model either from the normal location " + file + " or from the blockstate", exception));
// Handled by our finally block.
}
finally
{
if (model == null || model == getMissingModel())
{
FMLLog.fine("Item json isn't found for '" + memory + "', trying to load the variant from the blockstate json");
registerVariant(getModelBlockDefinition(memory), memory);
}
else stateModels.put(memory, model);
}
}
catch (Exception exception)
{
storeException(memory, exception);
}
}
ProgressManager.pop(itemBar);
// replace vanilla bucket models if desired. done afterwards for performance reasons
if(ForgeModContainer.replaceVanillaBucketModel)
@@ -273,15 +217,8 @@ public class ModelLoader extends ModelBakery
if(!stateModels.containsKey(ModelDynBucket.LOCATION))
{
// load forges blockstate json for it
try
{
registerVariant(getModelBlockDefinition(ModelDynBucket.LOCATION), ModelDynBucket.LOCATION);
}
catch (Exception exception)
{
FMLLog.getLogger().error("Could not load the forge bucket model from the blockstate", exception);
return;
}
ModelResourceLocation memory = getInventoryVariant("forge:dynbucket");
registerVariant(getModelBlockDefinition(memory), memory);
}
// empty bucket
@@ -386,21 +323,13 @@ public class ModelLoader extends ModelBakery
}
}
IModel getVariantModel(ModelResourceLocation location)
{
loadVariants(ImmutableList.of(location));
IModel model = stateModels.get(location);
if(model == null) model = getMissingModel();
return model;
}
private void resolveDependencies(IModel model) throws IOException
{
for (ResourceLocation dep : model.getDependencies())
{
if(dep instanceof ModelResourceLocation)
{
getVariantModel((ModelResourceLocation)dep);
loadVariants(ImmutableList.of((ModelResourceLocation)dep));
}
else
{
@@ -410,17 +339,15 @@ public class ModelLoader extends ModelBakery
textures.addAll(model.getTextures());
}
private class VanillaModelWrapper implements IRetexturableModel<VanillaModelWrapper>, IModelSimpleProperties<VanillaModelWrapper>, IAnimatedModel
private class VanillaModelWrapper implements IRetexturableModel
{
private final ResourceLocation location;
private final ModelBlock model;
private final ModelBlockAnimation animation;
public VanillaModelWrapper(ResourceLocation location, ModelBlock model, ModelBlockAnimation animation)
public VanillaModelWrapper(ResourceLocation location, ModelBlock model)
{
this.location = location;
this.model = model;
this.animation = animation;
}
public Collection<ResourceLocation> getDependencies()
@@ -472,7 +399,7 @@ public class ModelLoader extends ModelBakery
if(hasItemModel(model))
{
for(String s : ItemModelGenerator.LAYERS)
for(String s : (List<String>)ItemModelGenerator.LAYERS)
{
String r = model.resolveTextureName(s);
ResourceLocation loc = new ResourceLocation(r);
@@ -491,7 +418,7 @@ public class ModelLoader extends ModelBakery
}
}
}
for(String s : model.textures.values())
for(String s : (Iterable<String>)model.textures.values())
{
if(!s.startsWith("#"))
{
@@ -513,8 +440,7 @@ public class ModelLoader extends ModelBakery
List<TRSRTransformation> newTransforms = Lists.newArrayList();
for(int i = 0; i < model.getElements().size(); i++)
{
BlockPart part = model.getElements().get(i);
newTransforms.add(animation.getPartTransform(state, part, i));
newTransforms.add(null);
}
ItemCameraTransforms transforms = model.func_181682_g();
@@ -537,7 +463,7 @@ public class ModelLoader extends ModelBakery
return bakeNormal(model, perState, state.apply(Optional.<IModelPart>absent()).or(TRSRTransformation.identity()), newTransforms, format, bakedTextureGetter, uvlock);
}
private IFlexibleBakedModel bakeNormal(ModelBlock model, IModelState perState, final TRSRTransformation modelState, List<TRSRTransformation> newTransforms, VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, boolean uvLocked)
private IFlexibleBakedModel bakeNormal(ModelBlock model, IModelState perState, final TRSRTransformation modelState, List<TRSRTransformation> newTransforms, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, boolean uvLocked)
{
TextureAtlasSprite particle = bakedTextureGetter.apply(new ResourceLocation(model.resolveTextureName("particle")));
SimpleBakedModel.Builder builder = (new SimpleBakedModel.Builder(model)).setTexture(particle);
@@ -548,11 +474,8 @@ public class ModelLoader extends ModelBakery
if(newTransforms.get(i) != null)
{
transformation = transformation.compose(newTransforms.get(i));
BlockPartRotation rot = part.partRotation;
if(rot == null) rot = new BlockPartRotation(new org.lwjgl.util.vector.Vector3f(), EnumFacing.Axis.Y, 0, false);
part = new BlockPart(part.positionFrom, part.positionTo, part.mapFaces, rot, part.shade);
}
for(Map.Entry<EnumFacing, BlockPartFace> e : part.mapFaces.entrySet())
for(Map.Entry<EnumFacing, BlockPartFace> e : (Iterable<Map.Entry<EnumFacing, BlockPartFace>>)part.mapFaces.entrySet())
{
TextureAtlasSprite textureatlassprite1 = bakedTextureGetter.apply(new ResourceLocation(model.resolveTextureName(e.getValue().texture)));
@@ -571,25 +494,13 @@ public class ModelLoader extends ModelBakery
{
public IBakedModel handleBlockState(IBlockState state)
{
return VanillaModelWrapper.this.handleBlockState(parent, bakedTextureGetter, modelState, state);
return VanillaModelWrapper.this.handleBlockState(parent, modelState, state);
}
};
}
private IBakedModel handleBlockState(IFlexibleBakedModel model, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, TRSRTransformation modelState, IBlockState state)
private IBakedModel handleBlockState(IFlexibleBakedModel model, TRSRTransformation modelState, IBlockState state)
{
if(state instanceof IExtendedBlockState)
{
IExtendedBlockState exState = (IExtendedBlockState)state;
if(exState.getUnlistedNames().contains(Properties.AnimationProperty))
{
IModelState newState = exState.getValue(Properties.AnimationProperty);
if(newState != null)
{
return VanillaModelWrapper.this.bake(new ModelStateComposition(modelState, newState), model.getFormat(), bakedTextureGetter);
}
}
}
return model;
}
@@ -600,16 +511,16 @@ public class ModelLoader extends ModelBakery
return this;
List<BlockPart> elements = Lists.newArrayList(); //We have to duplicate this so we can edit it below.
for (BlockPart part : this.model.getElements())
for (BlockPart part : (List<BlockPart>)this.model.getElements())
{
elements.add(new BlockPart(part.positionFrom, part.positionTo, Maps.newHashMap(part.mapFaces), part.partRotation, part.shade));
}
ModelBlock newModel = new ModelBlock(this.model.getParentLocation(), elements,
ModelBlock neweModel = new ModelBlock(this.model.getParentLocation(), elements,
Maps.newHashMap(this.model.textures), this.model.isAmbientOcclusion(), this.model.isGui3d(), //New Textures man VERY IMPORTANT
model.func_181682_g());
newModel.name = this.model.name;
newModel.parent = this.model.parent;
neweModel.name = this.model.name;
neweModel.parent = this.model.parent;
Set<String> removed = Sets.newHashSet();
@@ -618,29 +529,29 @@ public class ModelLoader extends ModelBakery
if ("".equals(e.getValue()))
{
removed.add(e.getKey());
newModel.textures.remove(e.getKey());
neweModel.textures.remove(e.getKey());
}
else
newModel.textures.put(e.getKey(), e.getValue());
neweModel.textures.put(e.getKey(), e.getValue());
}
// Map the model's texture references as if it was the parent of a model with the retexture map as its textures.
Map<String, String> remapped = Maps.newHashMap();
for (Entry<String, String> e : newModel.textures.entrySet())
for (Entry<String, String> e : (Set<Entry<String, String>>)neweModel.textures.entrySet())
{
if (e.getValue().startsWith("#"))
{
String key = e.getValue().substring(1);
if (newModel.textures.containsKey(key))
remapped.put(e.getKey(), newModel.textures.get(key));
if (neweModel.textures.containsKey(key))
remapped.put(e.getKey(), (String)neweModel.textures.get(key));
}
}
newModel.textures.putAll(remapped);
neweModel.textures.putAll(remapped);
//Remove any faces that use a null texture, this is for performance reasons, also allows some cool layering stuff.
for (BlockPart part : newModel.getElements())
for (BlockPart part : (List<BlockPart>)neweModel.getElements())
{
Iterator<Entry<EnumFacing, BlockPartFace>> itr = part.mapFaces.entrySet().iterator();
while (itr.hasNext())
@@ -651,52 +562,15 @@ public class ModelLoader extends ModelBakery
}
}
return new VanillaModelWrapper(location, newModel, animation);
}
@Override
public Optional<? extends IClip> getClip(String name)
{
if(animation.getClips().containsKey(name))
{
return Optional.<IClip>fromNullable(animation.getClips().get(name));
}
return Optional.absent();
return new VanillaModelWrapper(location, neweModel);
}
public IModelState getDefaultState()
{
return ModelRotation.X0_Y0;
}
@Override
public VanillaModelWrapper smoothLighting(boolean value)
{
if(model.ambientOcclusion == value)
{
return this;
}
ModelBlock newModel = new ModelBlock(model.getParentLocation(), model.getElements(), model.textures, value, model.isGui3d(), model.func_181682_g());
newModel.parent = model.parent;
newModel.name = model.name;
return new VanillaModelWrapper(location, newModel, animation);
}
@Override
public VanillaModelWrapper gui3d(boolean value)
{
if(model.isGui3d() == value)
{
return this;
}
ModelBlock newModel = new ModelBlock(model.getParentLocation(), model.getElements(), model.textures, model.ambientOcclusion, value, model.func_181682_g());
newModel.parent = model.parent;
newModel.name = model.name;
return new VanillaModelWrapper(location, newModel, animation);
}
}
@Deprecated // rework in 1.9
public static class UVLock implements IModelState
{
private final IModelState parent;
@@ -717,6 +591,37 @@ public class ModelLoader extends ModelBakery
}
}
// Weighted models can contain multiple copies of 1 model with different rotations - this is to make it work with IModelState (different copies will be different objects).
private static class WeightedPartWrapper implements IModel
{
private final IModel model;
public WeightedPartWrapper(IModel model)
{
this.model = model;
}
public Collection<ResourceLocation> getDependencies()
{
return model.getDependencies();
}
public Collection<ResourceLocation> getTextures()
{
return model.getTextures();
}
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
return model.bake(state, format, bakedTextureGetter);
}
public IModelState getDefaultState()
{
return model.getDefaultState();
}
}
private class WeightedRandomModel implements IModel
{
private final List<Variant> variants;
@@ -724,11 +629,12 @@ public class ModelLoader extends ModelBakery
private final List<IModel> models = new ArrayList<IModel>();
private final IModelState defaultState;
@Deprecated @SuppressWarnings("unused") public WeightedRandomModel(Variants variants){ this(null, variants); } // Remove 1.9
public WeightedRandomModel(ModelResourceLocation parent, Variants variants)
{
this.variants = variants.getVariants();
ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder();
for (Variant v : variants.getVariants())
ImmutableMap.Builder<MapModelState.Wrapper, IModelState> builder = ImmutableMap.builder();
for (Variant v : (List<Variant>)variants.getVariants())
{
ResourceLocation loc = v.getModelLocation();
locations.add(loc);
@@ -763,18 +669,20 @@ public class ModelLoader extends ModelBakery
textures.addAll(model.getTextures()); // Kick this, just in case.
}
model = new WeightedPartWrapper(model);
models.add(model);
builder.add(Pair.of(model, v.getState()));
builder.put(MapModelState.wrap(model), v.getState());
}
if (models.size() == 0) //If all variants are missing, add one with the missing model and default rotation.
{
IModel missing = getMissingModel();
models.add(missing);
builder.add(Pair.<IModel, IModelState>of(missing, TRSRTransformation.identity()));
builder.put(MapModelState.wrap(missing), TRSRTransformation.identity());
}
defaultState = new MultiModelState(builder.build());
defaultState = new MapModelState(builder.build());
}
public Collection<ResourceLocation> getDependencies()
@@ -793,6 +701,15 @@ public class ModelLoader extends ModelBakery
return state;
}
private IModelState getState(IModelState state, IModel model)
{
if(state instanceof MapModelState)
{
return ((MapModelState)state).getState(model);
}
return state;
}
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
if(!Attributes.moreSpecific(format, Attributes.DEFAULT_BAKED_FORMAT))
@@ -803,14 +720,14 @@ public class ModelLoader extends ModelBakery
{
Variant v = variants.get(0);
IModel model = models.get(0);
return model.bake(addUV(v.isUvLocked(), MultiModelState.getPartState(state, model, 0)), format, bakedTextureGetter);
return model.bake(addUV(v.isUvLocked(), getState(state, model)), format, bakedTextureGetter);
}
WeightedBakedModel.Builder builder = new WeightedBakedModel.Builder();
for(int i = 0; i < variants.size(); i++)
{
IModel model = models.get(i);
Variant v = variants.get(i);
builder.add(model.bake(addUV(v.isUvLocked(), MultiModelState.getPartState(state, model, i)), format, bakedTextureGetter), variants.get(i).getWeight());
builder.add(model.bake(addUV(v.isUvLocked(), getState(state, model)), format, bakedTextureGetter), variants.get(i).getWeight());
}
return new FlexibleWeightedBakedModel(builder.build(), Attributes.DEFAULT_BAKED_FORMAT);
}
@@ -823,11 +740,14 @@ public class ModelLoader extends ModelBakery
private static class FlexibleWeightedBakedModel extends WeightedBakedModel implements IFlexibleBakedModel
{
@SuppressWarnings("unused")
private final WeightedBakedModel parent;
private final VertexFormat format;
public FlexibleWeightedBakedModel(WeightedBakedModel parent, VertexFormat format)
{
super(parent.models);
this.parent = parent;
this.format = format;
}
@@ -837,6 +757,12 @@ public class ModelLoader extends ModelBakery
}
}
@SuppressWarnings("unused")
private boolean isBuiltinModel(ModelBlock model)
{
return model == MODEL_GENERATED || model == MODEL_COMPASS || model == MODEL_CLOCK || model == MODEL_ENTITY;
}
public IModel getMissingModel()
{
if (missingModel == null)
@@ -887,14 +813,7 @@ public class ModelLoader extends ModelBakery
public IModel loadModel(ResourceLocation modelLocation) throws IOException
{
String modelPath = modelLocation.getResourcePath();
if(modelLocation.getResourcePath().startsWith("models/"))
{
modelPath = modelPath.substring("models/".length());
}
ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getResourceDomain(), "armatures/" + modelPath + ".json");
ModelBlockAnimation animation = Animation.INSTANCE.loadVanillaAnimation(armatureLocation);
return loader.new VanillaModelWrapper(modelLocation, loader.loadModel(modelLocation), animation);
return loader.new VanillaModelWrapper(modelLocation, loader.loadModel(modelLocation));
}
}
@@ -943,106 +862,12 @@ public class ModelLoader extends ModelBakery
public void onPostBakeEvent(IRegistry<ModelResourceLocation, IBakedModel> modelRegistry)
{
IBakedModel missingModel = modelRegistry.getObject(MODEL_MISSING);
Map<String, Integer> modelErrors = Maps.newHashMap();
Multimap<ModelResourceLocation, IBlockState> reverseBlockMap = null;
Multimap<ModelResourceLocation, String> reverseItemMap = null;
if(enableVerboseMissingInfo)
{
reverseBlockMap = HashMultimap.create();
for(Map.Entry<IBlockState, ModelResourceLocation> entry : blockModelShapes.getBlockStateMapper().putAllStateModelLocations().entrySet())
{
reverseBlockMap.put(entry.getValue(), entry.getKey());
}
reverseItemMap = HashMultimap.create();
for(Item item : GameData.getItemRegistry().typeSafeIterable())
{
for(String s : getVariantNames(item))
{
ModelResourceLocation memory = getInventoryVariant(s);
reverseItemMap.put(memory, item.getRegistryName());
}
}
}
for(Map.Entry<ResourceLocation, Exception> entry : loadingExceptions.entrySet())
{
// ignoring pure ResourceLocation arguments, all things we care about pass ModelResourceLocation
if(entry.getKey() instanceof ModelResourceLocation)
{
ModelResourceLocation location = (ModelResourceLocation)entry.getKey();
IBakedModel model = modelRegistry.getObject(location);
if(model == null || model == missingModel)
{
String domain = entry.getKey().getResourceDomain();
Integer errorCountBox = modelErrors.get(domain);
int errorCount = errorCountBox == null ? 0 : errorCountBox;
errorCount++;
if(errorCount < 5)
{
String errorMsg = "Exception loading model for variant " + entry.getKey();
if(enableVerboseMissingInfo)
{
Collection<IBlockState> blocks = reverseBlockMap.get(location);
if(!blocks.isEmpty())
{
if(blocks.size() == 1)
{
errorMsg += " for blockstate \"" + blocks.iterator().next() + "\"";
}
else
{
errorMsg += " for blockstates [\"" + Joiner.on("\", \"").join(blocks) + "\"]";
}
}
Collection<String> items = reverseItemMap.get(location);
if(!items.isEmpty())
{
if(!blocks.isEmpty()) errorMsg += " and";
if(items.size() == 1)
{
errorMsg += " for item \"" + items.iterator().next() + "\"";
}
else
{
errorMsg += " for items [\"" + Joiner.on("\", \"").join(items) + "\"]";
}
}
}
FMLLog.getLogger().error(errorMsg, entry.getValue());
}
modelErrors.put(domain, errorCount);
}
if(model == null)
{
modelRegistry.putObject(location, missingModel);
}
}
}
for(ModelResourceLocation missing : missingVariants)
{
IBakedModel model = modelRegistry.getObject(missing);
if(model == null || model == missingModel)
{
String domain = missing.getResourceDomain();
Integer errorCountBox = modelErrors.get(domain);
int errorCount = errorCountBox == null ? 0 : errorCountBox;
errorCount++;
if(errorCount < 5)
{
FMLLog.severe("Model definition for location %s not found", missing);
}
modelErrors.put(domain, errorCount);
}
if(model == null)
{
modelRegistry.putObject(missing, missingModel);
}
}
for(Map.Entry<String, Integer> e : modelErrors.entrySet())
{
if(e.getValue() >= 5)
{
FMLLog.severe("Suppressed additional %s model loading errors for domain %s", e.getValue(), e.getKey());
FMLLog.severe("Model definition for location %s not found", missing);
}
}
isLoading = false;
@@ -1111,19 +936,4 @@ public class ModelLoader extends ModelBakery
mesher.register(e.getKey().getLeft().get(), e.getKey().getRight(), e.getValue());
}
}
private static enum DefaultTextureGetter implements Function<ResourceLocation, TextureAtlasSprite>
{
instance;
public TextureAtlasSprite apply(ResourceLocation location)
{
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
}
}
public static Function<ResourceLocation, TextureAtlasSprite> defaultTextureGetter()
{
return DefaultTextureGetter.instance;
}
}
@@ -10,7 +10,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader.VanillaLoader;
import net.minecraftforge.client.model.b3d.B3DLoader;
@@ -44,7 +43,13 @@ public class ModelLoaderRegistry
public static void registerLoader(ICustomModelLoader loader)
{
loaders.add(loader);
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(loader);
((IReloadableResourceManager)Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new IResourceManagerReloadListener()
{
public void onResourceManagerReload(IResourceManager manager)
{
for(ICustomModelLoader loader : loaders) loader.onResourceManagerReload(manager);
}
});
}
public static boolean loaded(ResourceLocation location)
@@ -59,79 +64,58 @@ public class ModelLoaderRegistry
return new ResourceLocation(location.getResourceDomain(), "models/" + location.getResourcePath());
}
/**
* Primary method to get IModel instances.
* ResourceLocation argument will be passed directly to the custom model loaders,
* ModelResourceLocation argument will be loaded through the blockstate system.
*/
public static IModel getModel(ResourceLocation location) throws IOException
{
IModel model;
if(location instanceof ModelResourceLocation)
if(cache.containsKey(location)) return cache.get(location);
ResourceLocation actual = getActualLocation(location);
ICustomModelLoader accepted = null;
for(ICustomModelLoader loader : loaders)
{
ModelLoader loader = ModelLoader.VanillaLoader.instance.getLoader();
if(loader != null)
try
{
model = loader.getVariantModel((ModelResourceLocation)location);
if(loader.accepts(actual))
{
if(accepted != null)
{
FMLLog.severe("2 loaders (%s and %s) want to load the same model %s", accepted, loader, location);
throw new IllegalStateException("2 loaders want to load the same model");
}
accepted = loader;
}
}
else
catch(Exception e)
{
FMLLog.log(Level.ERROR, "Loading model too early, skipping: %s", location);
model = getMissingModel();
FMLLog.log(Level.ERROR, e, "Exception checking if model %s can be loaded with loader %s, skipping", location, loader);
}
}
// no custom loaders found, try vanilla one
if(accepted == null)
{
if(VanillaLoader.instance.accepts(actual)) accepted = VanillaLoader.instance;
}
IModel model;
if(accepted == null)
{
FMLLog.severe("no suitable loader found for the model %s, skipping", location);
model = getMissingModel();
}
else
{
if(cache.containsKey(location)) return cache.get(location);
ResourceLocation actual = getActualLocation(location);
ICustomModelLoader accepted = null;
for(ICustomModelLoader loader : loaders)
try
{
try
{
if(loader.accepts(actual))
{
if(accepted != null)
{
FMLLog.severe("2 loaders (%s and %s) want to load the same model %s", accepted, loader, location);
throw new IllegalStateException("2 loaders want to load the same model");
}
accepted = loader;
}
}
catch(Exception e)
{
FMLLog.log(Level.ERROR, e, "Exception checking if model %s can be loaded with loader %s, skipping", location, loader);
}
model = accepted.loadModel(actual);
}
// no custom loaders found, try vanilla one
if(accepted == null)
catch (IOException e)
{
if(VanillaLoader.instance.accepts(actual)) accepted = VanillaLoader.instance;
throw e;
}
if(accepted == null)
catch(Exception e)
{
FMLLog.severe("no suitable loader found for the model %s, skipping", location);
FMLLog.log(Level.ERROR, e, "Exception loading model %s with loader %s, skipping", location, accepted);
model = getMissingModel();
}
else
{
try
{
model = accepted.loadModel(actual);
}
catch (IOException e)
{
throw e;
}
catch(Exception e)
{
FMLLog.log(Level.ERROR, e, "Exception loading model %s with loader %s, skipping", location, accepted);
model = getMissingModel();
}
}
}
cache.put(location, model);
return model;
@@ -1,11 +1,12 @@
package net.minecraftforge.client.model;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import javax.vecmath.Matrix4f;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
@@ -15,16 +16,15 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.model.ItemLayerModel.BakedModel;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.Level;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
@@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
public class MultiLayerModel implements IModelCustomData
{
public static final MultiLayerModel instance = new MultiLayerModel(ImmutableMap.<Optional<EnumWorldBlockLayer>, ModelResourceLocation>of());
@@ -55,36 +55,10 @@ public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
return ImmutableList.of();
}
private static ImmutableMap<Optional<EnumWorldBlockLayer>, IFlexibleBakedModel> buildModels(ImmutableMap<Optional<EnumWorldBlockLayer>, ModelResourceLocation> models, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableMap.Builder<Optional<EnumWorldBlockLayer>, IFlexibleBakedModel> builder = ImmutableMap.builder();
for(Optional<EnumWorldBlockLayer> key : models.keySet())
{
IModel model;
try
{
model = ModelLoaderRegistry.getModel(models.get(key));
}
catch (IOException e)
{
FMLLog.log(Level.ERROR, e, "Couldn't load MultiLayerModel dependency: %s", models.get(key));
model = ModelLoaderRegistry.getMissingModel();
}
builder.put(key, model.bake(new ModelStateComposition(state, model.getDefaultState()), format, bakedTextureGetter));
}
return builder.build();
}
@Override
public IFlexibleBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
IModel missing = ModelLoaderRegistry.getMissingModel();
return new MultiLayerBakedModel(
buildModels(models, state, format, bakedTextureGetter),
missing.bake(missing.getDefaultState(), format, bakedTextureGetter),
format,
IPerspectiveAwareModel.MapWrapper.getTransforms(state)
);
return new MultiLayerBakedModel(models, format, IPerspectiveAwareModel.MapWrapper.getTransforms(state));
}
@Override
@@ -129,59 +103,63 @@ public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
public static class MultiLayerBakedModel implements IFlexibleBakedModel, ISmartBlockModel, IPerspectiveAwareModel
{
private final ImmutableMap<Optional<EnumWorldBlockLayer>, IFlexibleBakedModel> models;
private final ImmutableMap<Optional<EnumWorldBlockLayer>, ModelResourceLocation> models;
private final VertexFormat format;
private final ImmutableMap<TransformType, TRSRTransformation> cameraTransforms;;
private final IFlexibleBakedModel base;
private final IFlexibleBakedModel missing;
private final ImmutableMap<Optional<EnumFacing>, ImmutableList<BakedQuad>> quads;
private IBakedModel missing;
private IBakedModel base;
private ImmutableMap<EnumWorldBlockLayer, IBakedModel> bakedModels;
private ImmutableMap<Optional<EnumFacing>, ImmutableList<BakedQuad>> quads;
private static final Function<ResourceLocation, TextureAtlasSprite> defaultTextureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
{
public TextureAtlasSprite apply(ResourceLocation location)
{
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
}
};
@Deprecated // remove 1.9
public MultiLayerBakedModel(ImmutableMap<Optional<EnumWorldBlockLayer>, ModelResourceLocation> models, VertexFormat format, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms)
{
this(
buildModels(models, TRSRTransformation.identity(), format, defaultTextureGetter),
ModelLoaderRegistry.getMissingModel().bake(ModelLoaderRegistry.getMissingModel().getDefaultState(), format, defaultTextureGetter),
format,
cameraTransforms
);
}
public MultiLayerBakedModel(ImmutableMap<Optional<EnumWorldBlockLayer>, IFlexibleBakedModel> models, IFlexibleBakedModel missing, VertexFormat format, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms)
{
this.models = models;
this.format = format;
this.cameraTransforms = cameraTransforms;
this.missing = missing;
if(models.containsKey(Optional.absent()))
{
base = models.get(Optional.absent());
}
else
{
base = missing;
}
ImmutableMap.Builder<Optional<EnumFacing>, ImmutableList<BakedQuad>> quadBuilder = ImmutableMap.builder();
quadBuilder.put(Optional.<EnumFacing>absent(), buildQuads(models, Optional.<EnumFacing>absent()));
for(EnumFacing side: EnumFacing.values())
{
quadBuilder.put(Optional.of(side), buildQuads(models, Optional.of(side)));
}
quads = quadBuilder.build();
}
private static ImmutableList<BakedQuad> buildQuads(ImmutableMap<Optional<EnumWorldBlockLayer>, IFlexibleBakedModel> models, Optional<EnumFacing> side)
private void compute()
{
if(base == null)
{
ModelManager manager = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager();
missing = manager.getMissingModel();
base = getModel(manager, Optional.<EnumWorldBlockLayer>absent());
ImmutableMap.Builder<EnumWorldBlockLayer, IBakedModel> builder = ImmutableMap.builder();
for(EnumWorldBlockLayer layer : EnumWorldBlockLayer.values())
{
if(models.containsKey(Optional.of(layer)))
{
builder.put(layer, getModel(manager, Optional.of(layer)));
}
}
bakedModels = builder.build();
ImmutableMap.Builder<Optional<EnumFacing>, ImmutableList<BakedQuad>> quadBuilder = ImmutableMap.builder();
quadBuilder.put(Optional.<EnumFacing>absent(), buildQuads(Optional.<EnumFacing>absent()));
for(EnumFacing side: EnumFacing.values())
{
quadBuilder.put(Optional.of(side), buildQuads(Optional.of(side)));
}
quads = quadBuilder.build();
}
}
private IBakedModel getModel(ModelManager manager, Optional<EnumWorldBlockLayer> layer)
{
ModelResourceLocation loc = models.get(layer);
if(loc == null)
{
loc = new ModelResourceLocation("builtin/missing", "missing");
}
return manager.getModel(loc);
}
private ImmutableList<BakedQuad> buildQuads(Optional<EnumFacing> side)
{
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
for(IBakedModel model : models.values())
for(IBakedModel model : bakedModels.values())
{
if(side.isPresent())
{
@@ -198,37 +176,43 @@ public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
@Override
public List<BakedQuad> getFaceQuads(EnumFacing side)
{
compute();
return quads.get(Optional.of(side));
}
@Override
public List<BakedQuad> getGeneralQuads()
{
compute();
return quads.get(Optional.absent());
}
@Override
public boolean isAmbientOcclusion()
{
compute();
return base.isAmbientOcclusion();
}
@Override
public boolean isGui3d()
{
compute();
return base.isGui3d();
}
@Override
public boolean isBuiltInRenderer()
{
compute();
return base.isBuiltInRenderer();
}
@Override
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getTexture()
{
return base.getParticleTexture();
compute();
return base.getTexture();
}
@Override
@@ -240,12 +224,13 @@ public class MultiLayerModel implements IModelCustomData<MultiLayerModel>
@Override
public IBakedModel handleBlockState(IBlockState state)
{
Optional<EnumWorldBlockLayer> layer = Optional.of(MinecraftForgeClient.getRenderLayer());
if(!models.containsKey(layer))
compute();
EnumWorldBlockLayer layer = MinecraftForgeClient.getRenderLayer();
if(!bakedModels.containsKey(layer))
{
return missing;
}
return models.get(layer);
return bakedModels.get(layer);
}
@Override
@@ -100,9 +100,9 @@ public class MultiModel implements IModel
}
@Override
public TextureAtlasSprite getParticleTexture()
public TextureAtlasSprite getTexture()
{
return internalBase.getParticleTexture();
return internalBase.getTexture();
}
@Override
@@ -1,128 +0,0 @@
package net.minecraftforge.client.model;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
public class MultiModelState implements IModelState
{
private final ImmutableMap<MultiModelPart, ? extends IModelState> states;
public <M extends IModel, S extends IModelState> MultiModelState(ImmutableList<Pair<M, S>> states)
{
ImmutableMap.Builder<MultiModelPart, S> builder = ImmutableMap.builder();
for(int i = 0; i < states.size(); i++)
{
Pair<M, S> pair = states.get(i);
builder.put(new MultiModelPart(pair.getLeft(), i), pair.getRight());
}
this.states = builder.build();
}
public static IModelState getPartState(IModelState state, IModel model, int index)
{
if(state.apply(Optional.of(new MultiModelPart(model, index))).isPresent())
{
return new PartState(state, model, index);
}
return state;
}
public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> part)
{
if(part.isPresent())
{
if(part.get() instanceof MultiModelPart)
{
MultiModelPart key = (MultiModelPart)part.get();
if(states.containsKey(key))
{
return Optional.of(states.get(key).apply(Optional.<IModelPart>absent()).or(TRSRTransformation.identity()));
}
}
else if(part.get() instanceof PartPart)
{
PartPart partPart = (PartPart)part.get();
MultiModelPart key = new MultiModelPart(partPart.model, partPart.index);
if(states.containsKey(key))
{
return states.get(key).apply(partPart.part);
}
}
}
return Optional.absent();
}
private static class PartState implements IModelState
{
private final IModelState state;
private final IModel model;
private final int index;
public PartState(IModelState state, IModel model, int index)
{
this.state = state;
this.model = model;
this.index = index;
}
public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> part)
{
Optional<TRSRTransformation> normal = state.apply(part);
Optional<TRSRTransformation> multi = state.apply(Optional.of(new PartPart(model, index, part)));
if(normal.isPresent() && multi.isPresent())
{
return Optional.of(normal.get().compose(multi.get()));
}
return normal.or(multi);
}
}
private static class MultiModelPart implements IModelPart
{
private final IModel model;
private final int index;
public MultiModelPart(IModel model, int index)
{
this.model = model;
this.index = index;
}
@Override
public int hashCode()
{
return Objects.hashCode(model, index);
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
MultiModelPart other = (MultiModelPart)obj;
return Objects.equal(this.model, other.model) && this.index == other.index;
}
}
private static class PartPart implements IModelPart
{
private final IModel model;
private final int index;
private final Optional<? extends IModelPart> part;
public PartPart(IModel model, int index, Optional<? extends IModelPart> part)
{
this.model = model;
this.index = index;
this.part = part;
}
}
}
@@ -157,12 +157,6 @@ public class TRSRTransformation implements IModelState, ITransformation
return ret;
}
public static Vector3f toYXZDegrees(Quat4f q)
{
Vector3f yxz = toYXZ(q);
return new Vector3f((float)Math.toDegrees(yxz.x), (float)Math.toDegrees(yxz.y), (float)Math.toDegrees(yxz.z));
}
public static Vector3f toYXZ(Quat4f q)
{
float w2 = q.w * q.w;
@@ -170,19 +164,19 @@ public class TRSRTransformation implements IModelState, ITransformation
float y2 = q.y * q.y;
float z2 = q.z * q.z;
float l = w2 + x2 + y2 + z2;
float sx = 2 * q.w * q.x - 2 * q.y * q.z;
float sx = 2 * q.y * q.z - 2 * q.w * q.x;
float x = (float)Math.asin(sx / l);
if(Math.abs(sx) > .999f * l)
{
return new Vector3f(
x,
2 * (float)Math.atan2(q.y, q.w),
x,
0
);
}
return new Vector3f(
x,
(float)Math.atan2(2 * q.x * q.z + 2 * q.y * q.w, w2 - x2 - y2 + z2),
x,
(float)Math.atan2(2 * q.x * q.y + 2 * q.w * q.z, w2 - x2 + y2 - z2)
);
}
@@ -449,7 +443,7 @@ public class TRSRTransformation implements IModelState, ITransformation
*/
public ItemTransformVec3f toItemTransform()
{
return new ItemTransformVec3f(toLwjgl(toYXZDegrees(getLeftRot())), toLwjgl(getTranslation()), toLwjgl(getScale()));
return new ItemTransformVec3f(toLwjgl(getTranslation()), toLwjgl(toYXZ(getLeftRot())), toLwjgl(getScale()));
}
public Matrix4f getMatrix()
@@ -1,203 +0,0 @@
package net.minecraftforge.client.model.animation;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import net.minecraftforge.common.util.JsonUtils;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.logging.log4j.Level;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
public enum Animation implements IResourceManagerReloadListener
{
INSTANCE;
private float clientPartialTickTime;
/**
* Get the global world time for the current tick, in seconds.
*/
public static float getWorldTime(World world)
{
return getWorldTime(world, 0);
}
/**
* Get the global world time for the current tick + partial tick progress, in seconds.
*/
public static float getWorldTime(World world, float tickProgress)
{
return (world.getTotalWorldTime() + tickProgress) / 20;
}
/**
* Get current partialTickTime.
*/
public static float getPartialTickTime()
{
return INSTANCE.clientPartialTickTime;
}
/**
* Load a new instance if AnimationStateMachine at specified location, with specified custom parameters.
*/
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> customParameters)
{
try
{
ClipResolver clipResolver = new ClipResolver();
ParameterResolver parameterResolver = new ParameterResolver(customParameters);
Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(clipResolver);
TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(parameterResolver);
IResource resource = manager.getResource(location);
AnimationStateMachine asm = asmGson.fromJson(new InputStreamReader(resource.getInputStream(), "UTF-8"), AnimationStateMachine.class);
clipResolver.asm = asm;
parameterResolver.asm = asm;
asm.initialize();
//String json = asmGson.toJson(asm);
//System.out.println(location + ": " + json);
return asm;
}
catch(IOException e)
{
FMLLog.log(Level.ERROR, e, "Exception loading Animation State Machine %s, skipping", location);
return missing;
}
catch(JsonParseException e)
{
FMLLog.log(Level.ERROR, e, "Exception loading Animation State Machine %s, skipping", location);
return missing;
}
finally
{
Clips.CommonClipTypeAdapterFactory.INSTANCE.setClipResolver(null);
TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE.setValueResolver(null);
}
}
/**
* Load armature associated with a vanilla model.
*/
public ModelBlockAnimation loadVanillaAnimation(ResourceLocation armatureLocation)
{
try
{
IResource resource = null;
try
{
resource = manager.getResource(armatureLocation);
}
catch(FileNotFoundException e)
{
// this is normal. FIXME: error reporting?
return defaultModelBlockAnimation;
}
ModelBlockAnimation mba = mbaGson.fromJson(new InputStreamReader(resource.getInputStream(), "UTF-8"), ModelBlockAnimation.class);
String json = mbaGson.toJson(mba);
return mba;
}
catch(IOException e)
{
FMLLog.log(Level.ERROR, e, "Exception loading vanilla model aniamtion %s, skipping", armatureLocation);
return defaultModelBlockAnimation;
}
catch(JsonParseException e)
{
FMLLog.log(Level.ERROR, e, "Exception loading vanilla model aniamtion %s, skipping", armatureLocation);
return defaultModelBlockAnimation;
}
}
private IResourceManager manager;
private final AnimationStateMachine missing = new AnimationStateMachine(
ImmutableMap.<String, ITimeValue>of(),
ImmutableMap.of("missingno", (IClip)Clips.IdentityClip.instance),
ImmutableList.of("missingno"),
ImmutableMap.<String, String>of(),
"missingno");
{
missing.initialize();
}
private final Gson asmGson = new GsonBuilder()
.registerTypeAdapter(ImmutableList.class, JsonUtils.ImmutableListTypeAdapter.INSTANCE)
.registerTypeAdapter(ImmutableMap.class, JsonUtils.ImmutableMapTypeAdapter.INSTANCE)
.registerTypeAdapterFactory(Clips.CommonClipTypeAdapterFactory.INSTANCE)
//.registerTypeAdapterFactory(ClipProviders.CommonClipProviderTypeAdapterFactory.INSTANCE)
.registerTypeAdapterFactory(TimeValues.CommonTimeValueTypeAdapterFactory.INSTANCE)
.setPrettyPrinting()
.enableComplexMapKeySerialization()
.disableHtmlEscaping()
.create();
private static final class ClipResolver implements Function<String, IClip>
{
private AnimationStateMachine asm;
public IClip apply(String name)
{
return asm.getClips().get(name);
}
}
private static final class ParameterResolver implements Function<String, ITimeValue>
{
private final ImmutableMap<String, ITimeValue> customParameters;
private AnimationStateMachine asm;
public ParameterResolver(ImmutableMap<String, ITimeValue> customParameters)
{
this.customParameters = customParameters;
}
public ITimeValue apply(String name)
{
if(asm.getParameters().containsKey(name))
{
return asm.getParameters().get(name);
}
return customParameters.get(name);
}
}
private final Gson mbaGson = new GsonBuilder()
.registerTypeAdapter(ImmutableList.class, JsonUtils.ImmutableListTypeAdapter.INSTANCE)
.registerTypeAdapter(ImmutableMap.class, JsonUtils.ImmutableMapTypeAdapter.INSTANCE)
.setPrettyPrinting()
.enableComplexMapKeySerialization()
.disableHtmlEscaping()
.create();
private final ModelBlockAnimation defaultModelBlockAnimation = new ModelBlockAnimation(ImmutableMap.<String, ImmutableMap<String, float[]>>of(), ImmutableMap.<String, ModelBlockAnimation.MBClip>of());
/**
* Iternal hook, do not use.
*/
public static void setClientPartialTickTime(float clientPartialTickTime) {
Animation.INSTANCE.clientPartialTickTime = clientPartialTickTime;
}
/**
* Iternal hook, do not use.
*/
public void onResourceManagerReload(IResourceManager manager)
{
this.manager = manager;
}
}
@@ -1,108 +0,0 @@
package net.minecraftforge.client.model.animation;
import java.util.List;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.IModelState;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.client.model.pipeline.VertexLighterFlat;
import net.minecraftforge.client.model.pipeline.WorldRendererConsumer;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
/**
* ModelBase that works with the Forge model system and animations.
* Some quirks are still left, deprecated for the moment.
*/
@Deprecated
public class AnimationModelBase<T extends Entity & IAnimationProvider> extends ModelBase implements IEventHandler<T>
{
private final VertexLighterFlat lighter;
private final IModel model;
public AnimationModelBase(IModel model, VertexLighterFlat lighter)
{
this.model = model;
this.lighter = lighter;
}
@SuppressWarnings("unchecked")
@Override
public void render(Entity entity, float limbSwing, float limbSwingSpeed, float timeAlive, float yawHead, float rotationPitch, float scale)
{
if(!(entity instanceof IAnimationProvider))
{
throw new ClassCastException("AnimationModelBase expects IAnimationProvider");
}
Pair<IModelState, Iterable<Event>> pair = ((IAnimationProvider)entity).asm().apply(timeAlive / 20);
handleEvents((T)entity, timeAlive / 20, pair.getRight());
IBakedModel bakedModel = model.bake(pair.getLeft(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
BlockPos pos = new BlockPos(entity.posX, entity.posY + entity.height, entity.posZ);
RenderHelper.disableStandardItemLighting();
GlStateManager.pushMatrix();
GlStateManager.rotate(180, 0, 0, 1);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-0.5, -1.5, -0.5);
lighter.setParent(new WorldRendererConsumer(worldRenderer));
lighter.setWorld(entity.worldObj);
lighter.setBlock(Blocks.air);
lighter.setBlockPos(pos);
boolean empty = true;
List<BakedQuad> quads = bakedModel.getGeneralQuads();
if(!quads.isEmpty())
{
lighter.updateBlockInfo();
empty = false;
for(BakedQuad quad : quads)
{
quad.pipe(lighter);
}
}
for(EnumFacing side : EnumFacing.values())
{
quads = bakedModel.getFaceQuads(side);
if(!quads.isEmpty())
{
if(empty) lighter.updateBlockInfo();
empty = false;
for(BakedQuad quad : quads)
{
quad.pipe(lighter);
}
}
}
// debug quad
/*worldRenderer.pos(0, 1, 0).color(0xFF, 0xFF, 0xFF, 0xFF).tex(0, 0).lightmap(240, 0).endVertex();
worldRenderer.pos(0, 1, 1).color(0xFF, 0xFF, 0xFF, 0xFF).tex(0, 1).lightmap(240, 0).endVertex();
worldRenderer.pos(1, 1, 1).color(0xFF, 0xFF, 0xFF, 0xFF).tex(1, 1).lightmap(240, 0).endVertex();
worldRenderer.pos(1, 1, 0).color(0xFF, 0xFF, 0xFF, 0xFF).tex(1, 0).lightmap(240, 0).endVertex();*/
worldRenderer.setTranslation(0, 0, 0);
tessellator.draw();
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
}
public void handleEvents(T instance, float time, Iterable<Event> pastEvents) {}
}
@@ -1,169 +0,0 @@
package net.minecraftforge.client.model.animation;
import java.util.concurrent.TimeUnit;
import net.minecraftforge.client.model.IModelState;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple;
import com.google.common.base.Predicate;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.gson.JsonParseException;
import com.google.gson.annotations.SerializedName;
class AnimationStateMachine implements IAnimationStateMachine
{
private final ImmutableMap<String, ITimeValue> parameters;
private final ImmutableMap<String, IClip> clips;
private final ImmutableList<String> states;
private final ImmutableMap<String, String> transitions;
@SerializedName("start_state")
private final String startState;
private transient boolean shouldHandleSpecialEvents;
private transient String currentStateName;
private transient IClip currentState;
private transient float lastPollTime;
private static final LoadingCache<Triple<? extends IClip, Float, Float>, Pair<IModelState, Iterable<Event>>> clipCache = CacheBuilder.newBuilder()
.maximumSize(100)
.expireAfterWrite(100, TimeUnit.MILLISECONDS)
.build(new CacheLoader<Triple<? extends IClip, Float, Float>, Pair<IModelState, Iterable<Event>>>()
{
public Pair<IModelState, Iterable<Event>> load(Triple<? extends IClip, Float, Float> key) throws Exception
{
return Clips.apply(key.getLeft(), key.getMiddle(), key.getRight());
}
});
public AnimationStateMachine(ImmutableMap<String, ITimeValue> parameters, ImmutableMap<String, IClip> clips, ImmutableList<String> states, ImmutableMap<String, String> transitions, String startState)
{
this.parameters = parameters;
this.clips = clips;
this.states = states;
this.transitions = transitions;
this.startState = startState;
}
/**
* Used during resolution of parameter references.
*/
ImmutableMap<String, ITimeValue> getParameters()
{
return parameters;
}
/**
* Used during resolution of clip references.
*/
ImmutableMap<String, IClip> getClips()
{
return clips;
}
/**
* post-loading initialization hook.
*/
void initialize()
{
if(parameters == null)
{
throw new JsonParseException("Animation State Machine should contain \"parameters\" key.");
}
if(clips == null)
{
throw new JsonParseException("Animation State Machine should contain \"clips\" key.");
}
if(states == null)
{
throw new JsonParseException("Animation State Machine should contain \"states\" key.");
}
if(transitions == null)
{
throw new JsonParseException("Animation State Machine should contain \"transitions\" key.");
}
shouldHandleSpecialEvents = true;
lastPollTime = Float.NEGATIVE_INFINITY;
// setting the starting state
IClip state = clips.get(startState);
if(!clips.containsKey(startState) || !states.contains(startState))
{
throw new IllegalStateException("unknown state: " + startState);
}
currentStateName = startState;
currentState = state;
}
public Pair<IModelState, Iterable<Event>> apply(float time)
{
if(lastPollTime == Float.NEGATIVE_INFINITY)
{
lastPollTime = time;
}
Pair<IModelState, Iterable<Event>> pair = clipCache.getUnchecked(Triple.of(currentState, lastPollTime, time));
lastPollTime = time;
boolean shouldFilter = false;
if(shouldHandleSpecialEvents)
{
for(Event event : ImmutableList.copyOf(pair.getRight()).reverse())
{
if(event.event().startsWith("!"))
{
shouldFilter = true;
if(event.event().startsWith("!transition:"))
{
String newState = event.event().substring("!transition:".length());
transition(newState);
}
else
{
System.out.println("Unknown special event \"" + event.event() + "\", ignoring");
}
}
}
}
if(!shouldFilter)
{
return pair;
}
return Pair.of(pair.getLeft(), Iterables.filter(pair.getRight(), new Predicate<Event>()
{
public boolean apply(Event event)
{
return !event.event().startsWith("!");
}
}));
}
public void transition(String newState)
{
IClip nc = clips.get(newState);
if(!clips.containsKey(newState) || !states.contains(newState))
{
throw new IllegalStateException("unknown state: " + newState);
}
if(!transitions.get(currentStateName).equals(newState))
{
throw new IllegalArgumentException("no transition from current clip \"" + currentStateName + "\" to the clip \"" + newState + "\" found.");
}
currentStateName = newState;
currentState = nc;
}
public String currentState()
{
return currentStateName;
}
public void shouldHandleSpecialEvents(boolean value)
{
shouldHandleSpecialEvents = true;
}
}
@@ -1,79 +0,0 @@
package net.minecraftforge.client.model.animation;
import java.util.concurrent.TimeUnit;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.model.IModelState;
import net.minecraftforge.client.model.ISmartBlockModel;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.Properties;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
/**
* Generic TileEntitySpecialRenderer that works with the Forge model system and animations.
*/
public class AnimationTESR<T extends TileEntity & IAnimationProvider> extends FastTESR<T> implements IEventHandler<T>
{
protected static BlockRendererDispatcher blockRenderer;
protected static final LoadingCache<Pair<IExtendedBlockState, IModelState>, IBakedModel> modelCache = CacheBuilder.newBuilder().maximumSize(10).expireAfterWrite(100, TimeUnit.MILLISECONDS).build(new CacheLoader<Pair<IExtendedBlockState, IModelState>, IBakedModel>()
{
public IBakedModel load(Pair<IExtendedBlockState, IModelState> key) throws Exception
{
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(key.getLeft().getClean());
if(model instanceof ISmartBlockModel)
{
model = ((ISmartBlockModel)model).handleBlockState(key.getLeft().withProperty(Properties.AnimationProperty, key.getRight()));
}
return model;
}
});
protected static IBakedModel getModel(IExtendedBlockState state, IModelState modelState)
{
return modelCache.getUnchecked(Pair.of(state, modelState));
}
public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, WorldRenderer renderer)
{
if(blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos pos = te.getPos();
IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
IBlockState state = world.getBlockState(pos);
if(state.getPropertyNames().contains(Properties.StaticProperty))
{
state = state.withProperty(Properties.StaticProperty, false);
}
if(state instanceof IExtendedBlockState)
{
IExtendedBlockState exState = (IExtendedBlockState)state;
if(exState.getUnlistedNames().contains(Properties.AnimationProperty))
{
float time = Animation.getWorldTime(getWorld(), partialTick);
Pair<IModelState, Iterable<Event>> pair = te.asm().apply(time);
handleEvents(te, time, pair.getRight());
IBakedModel model = getModel(exState, pair.getLeft());
renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
blockRenderer.getBlockModelRenderer().renderModel(world, model, state, pos, renderer, false);
}
}
}
public void handleEvents(T te, float time, Iterable<Event> pastEvents) {}
}
@@ -1,538 +0,0 @@
package net.minecraftforge.client.model.animation;
import java.io.IOException;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.IModelPart;
import net.minecraftforge.client.model.IModelState;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.model.TRSRTransformation;
import net.minecraftforge.fml.common.FMLLog;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
/**
* Various implementations of IClip, and utility methods.
*/
public final class Clips
{
/**
* Clip that does nothing.
*/
public static enum IdentityClip implements IClip, IStringSerializable
{
instance;
public IJointClip apply(IJoint joint)
{
return JointClips.IdentityJointClip.instance;
}
public Iterable<Event> pastEvents(float lastPollTime, float time)
{
return ImmutableSet.<Event>of();
}
public String getName()
{
return "identity";
}
}
/**
* Retrieves the clip from the model.
*/
public static IClip getModelClipNode(ResourceLocation modelLocation, String clipName)
{
IModel model;
try
{
model = ModelLoaderRegistry.getModel(modelLocation);
if(model instanceof IAnimatedModel)
{
Optional<? extends IClip> clip = ((IAnimatedModel)model).getClip(clipName);
if(clip.isPresent())
{
return new ModelClip(clip.get(), modelLocation, clipName);
}
FMLLog.getLogger().error("Unable to find clip " + clipName + " in the model " + modelLocation);
}
}
catch (IOException e)
{
FMLLog.getLogger().error("Unable to load model" + modelLocation + " while loading clip " + clipName, e);
}
// FIXME: missing clip?
return new ModelClip(IdentityClip.instance, modelLocation, clipName);
}
/**
* Wrapper for model clips; useful for debugging and serialization;
*/
public static final class ModelClip implements IClip
{
private final IClip childClip;
private final ResourceLocation modelLocation;
private final String clipName;
public ModelClip(IClip childClip, ResourceLocation modelLocation, String clipName)
{
this.childClip = childClip;
this.modelLocation = modelLocation;
this.clipName = clipName;
}
public IJointClip apply(IJoint joint)
{
return childClip.apply(joint);
}
public Iterable<Event> pastEvents(float lastPollTime, float time)
{
return childClip.pastEvents(lastPollTime, time);
}
@Override
public int hashCode()
{
return Objects.hashCode(modelLocation, clipName);
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ModelClip other = (ModelClip) obj;
return Objects.equal(modelLocation, other.modelLocation) && Objects.equal(clipName, other.clipName);
}
}
/**
* Clip with custom parameterization of the time.
*/
public static final class TimeClip implements IClip
{
private final IClip childClip;
private final ITimeValue time;
public TimeClip(IClip childClip, ITimeValue time)
{
this.childClip = childClip;
this.time = time;
}
public IJointClip apply(final IJoint joint)
{
return new IJointClip()
{
private final IJointClip parent = childClip.apply(joint);
public TRSRTransformation apply(float time)
{
return parent.apply(TimeClip.this.time.apply(time));
}
};
}
public Iterable<Event> pastEvents(float lastPollTime, float time)
{
return childClip.pastEvents(this.time.apply(lastPollTime), this.time.apply(time));
}
@Override
public int hashCode()
{
return Objects.hashCode(childClip, time);
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TimeClip other = (TimeClip) obj;
return Objects.equal(childClip, other.childClip) && Objects.equal(time, other.time);
}
}
/**
* Spherical linear blend between 2 clips.
*/
public static final class SlerpClip implements IClip
{
private final IClip from;
private final IClip to;
private final ITimeValue input;
private final ITimeValue progress;
public SlerpClip(IClip from, IClip to, ITimeValue input, ITimeValue progress)
{
this.from = from;
this.to = to;
this.input = input;
this.progress = progress;
}
public IJointClip apply(IJoint joint)
{
IJointClip fromClip = from.apply(joint);
IJointClip toClip = to.apply(joint);
return blendClips(joint, fromClip, toClip, input, progress);
}
public Iterable<Event> pastEvents(float lastPollTime, float time)
{
float clipLastPollTime = input.apply(lastPollTime);
float clipTime = input.apply(time);
return Iterables.mergeSorted(ImmutableSet.of(
from.pastEvents(clipLastPollTime, clipTime),
to.pastEvents(clipLastPollTime, clipTime)
), Ordering.<Event>natural());
}
@Override
public int hashCode()
{
return Objects.hashCode(from, to, input, progress);
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SlerpClip other = (SlerpClip) obj;
return Objects.equal(from, other.from) &&
Objects.equal(to, other.to) &&
Objects.equal(input, other.input) &&
Objects.equal(progress, other.progress);
}
}
/*public static class AdditiveLerpClip implements IClip
{
private final IClip base;
private final IClip add;
private final IParameter progress;
public AdditiveLerpClip(IClip base, IClip add, IParameter progress)
{
this.base = base;
this.add = add;
this.progress = progress;
}
public IJointClip apply(IJoint joint)
{
throw new NotImplementedException("AdditiveLerpClip.apply");
}
}*/
private static IJointClip blendClips(final IJoint joint, final IJointClip fromClip, final IJointClip toClip, final ITimeValue input, final ITimeValue progress)
{
return new IJointClip()
{
public TRSRTransformation apply(float time)
{
float clipTime = input.apply(time);
return fromClip.apply(clipTime).slerp(toClip.apply(clipTime), MathHelper.clamp_float(progress.apply(time), 0, 1));
}
};
}
/**
* IModelState wrapper for a Clip, sampled at specified time.
*/
public static Pair<IModelState, Iterable<Event>> apply(final IClip clip, final float lastPollTime, final float time)
{
return Pair.<IModelState, Iterable<Event>>of(new IModelState()
{
public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> part)
{
if(!part.isPresent() || !(part.get() instanceof IJoint))
{
return Optional.absent();
}
IJoint joint = (IJoint)part.get();
if(!joint.getParent().isPresent())
{
return Optional.of(clip.apply(joint).apply(time).compose(joint.getInvBindPose()));
}
return Optional.of(clip.apply(joint.getParent().get()).apply(time).compose(clip.apply(joint).apply(time)).compose(joint.getInvBindPose()));
}
}, clip.pastEvents(lastPollTime, time));
}
/**
* Clip + Event, triggers when parameter becomes non-negative.
*/
public static final class TriggerClip implements IClip
{
private final IClip clip;
private final ITimeValue parameter;
private final String event;
public TriggerClip(IClip clip, ITimeValue parameter, String event)
{
this.clip = clip;
this.parameter = parameter;
this.event = event;
}
public IJointClip apply(IJoint joint)
{
return clip.apply(joint);
}
public Iterable<Event> pastEvents(float lastPollTime, float time)
{
if(parameter.apply(lastPollTime) < 0 && parameter.apply(time) >= 0)
{
return Iterables.mergeSorted(ImmutableSet.of(
clip.pastEvents(lastPollTime, time),
ImmutableSet.of(new Event(event, 0))
), Ordering.<Event>natural());
}
return clip.pastEvents(lastPollTime, time);
}
}
/**
* Reference to another clip.
* Should only exist during debugging.
*/
public static final class ClipReference implements IClip, IStringSerializable
{
private final String clipName;
private final Function<String, IClip> clipResolver;
private IClip clip;
public ClipReference(String clipName, Function<String, IClip> clipResolver)
{
this.clipName = clipName;
this.clipResolver = clipResolver;
}
private void resolve()
{
if(clip == null)
{
if(clipResolver != null)
{
clip = clipResolver.apply(clipName);
}
if(clip == null)
{
throw new IllegalArgumentException("Couldn't resolve clip " + clipName);
}
}
}
public IJointClip apply(final IJoint joint)
{
resolve();
return clip.apply(joint);
}
public Iterable<Event> pastEvents(float lastPollTime, float time)
{
resolve();
return clip.pastEvents(lastPollTime, time);
}
public String getName()
{
return clipName;
}
@Override
public int hashCode()
{
resolve();
return clip.hashCode();
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ClipReference other = (ClipReference) obj;
resolve();
other.resolve();
return Objects.equal(clip, other.clip);
}
}
public static enum CommonClipTypeAdapterFactory implements TypeAdapterFactory
{
INSTANCE;
private final ThreadLocal<Function<String, IClip>> clipResolver = new ThreadLocal<Function<String, IClip>>();
public void setClipResolver(Function<String, IClip> clipResolver)
{
this.clipResolver.set(clipResolver);
}
@SuppressWarnings("unchecked")
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type)
{
if(type.getRawType() != IClip.class)
{
return null;
}
final TypeAdapter<ITimeValue> parameterAdapter = gson.getAdapter(ITimeValue.class);
return (TypeAdapter<T>)new TypeAdapter<IClip>()
{
public void write(JsonWriter out, IClip clip) throws IOException
{
// IdentityClip + ClipReference
if(clip instanceof IStringSerializable)
{
out.value("#" + ((IStringSerializable)clip).getName());
return;
}
else if(clip instanceof TimeClip)
{
out.beginArray();
out.value("apply");
TimeClip timeClip = (TimeClip)clip;
write(out, timeClip.childClip);
parameterAdapter.write(out, timeClip.time);
out.endArray();
return;
}
else if(clip instanceof SlerpClip)
{
out.beginArray();
out.value("slerp");
SlerpClip slerpClip = (SlerpClip)clip;
write(out, slerpClip.from);
write(out, slerpClip.to);
parameterAdapter.write(out, slerpClip.input);
parameterAdapter.write(out, slerpClip.progress);
out.endArray();
return;
}
else if(clip instanceof TriggerClip)
{
out.beginArray();
out.value("trigger_positive");
TriggerClip triggerClip = (TriggerClip)clip;
write(out, triggerClip.clip);
parameterAdapter.write(out, triggerClip.parameter);
out.value(triggerClip.event);
out.endArray();
return;
}
else if(clip instanceof ModelClip)
{
ModelClip modelClip = (ModelClip)clip;
out.value(modelClip.modelLocation + "@" + modelClip.clipName);
return;
}
// TODO custom clip writing?
throw new NotImplementedException("unknown Clip to json: " + clip);
}
public IClip read(JsonReader in) throws IOException
{
switch(in.peek())
{
case BEGIN_ARRAY:
in.beginArray();
String type = in.nextString();
IClip clip;
// TimeClip
if("apply".equals(type))
{
clip = new TimeClip(read(in), parameterAdapter.read(in));
}
else if("slerp".equals(type))
{
clip = new SlerpClip(read(in), read(in), parameterAdapter.read(in), parameterAdapter.read(in));
}
else if("trigger_positive".equals(type))
{
clip = new TriggerClip(read(in), parameterAdapter.read(in), in.nextString());
}
else
{
throw new IOException("Unknown Clip type \"" + type + "\"");
}
in.endArray();
return clip;
case STRING:
String string = in.nextString();
// IdentityClip
if(string.equals("#identity"))
{
return IdentityClip.instance;
}
// Clip reference
if(string.startsWith("#"))
{
return new ClipReference(string.substring(1), clipResolver.get());
}
// ModelClip
else
{
int at = string.lastIndexOf('@');
String location = string.substring(0, at);
String clipName = string.substring(at + 1, string.length());
ResourceLocation model;
if(location.indexOf('#') != -1)
{
model = new ModelResourceLocation(location);
}
else
{
model = new ResourceLocation(location);
}
return getModelClipNode(model, clipName);
}
default:
throw new IOException("expected Clip, got " + in.peek());
}
}
};
}
}
}
@@ -1,46 +0,0 @@
package net.minecraftforge.client.model.animation;
import com.google.common.base.Objects;
/**
* Event stored in the clip
*/
public final class Event implements Comparable<Event>
{
private final String event;
private final float offset;
public Event(String event, float offset)
{
this.event = event;
this.offset = offset;
}
/**
* @return the name of the event.
*/
public String event()
{
return event;
}
/**
* @return how long ago the event happened, relative to the next event / first query time
*/
public float offset()
{
return offset;
}
public int compareTo(Event event)
{
return new Float(offset).compareTo(event.offset);
}
@Override
public String toString()
{
return Objects.toStringHelper(getClass()).add("event", event).add("offset", offset).toString();
}
}
@@ -1,49 +0,0 @@
package net.minecraftforge.client.model.animation;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.tileentity.TileEntity;
public abstract class FastTESR<T extends TileEntity> extends TileEntitySpecialRenderer<T>
{
@Override
public final void renderTileEntityAt(T te, double x, double y, double z, float partialTicks, int destroyStage)
{
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
this.bindTexture(TextureMap.locationBlocksTexture);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
{
GlStateManager.shadeModel(GL11.GL_SMOOTH);
}
else
{
GlStateManager.shadeModel(GL11.GL_FLAT);
}
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, worldRenderer);
worldRenderer.setTranslation(0, 0, 0);
tessellator.draw();
RenderHelper.enableStandardItemLighting();
}
@Override
public abstract void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, WorldRenderer worldRenderer);
}
@@ -1,13 +0,0 @@
package net.minecraftforge.client.model.animation;
import net.minecraftforge.client.model.IModel;
import com.google.common.base.Optional;
/**
* IModel that has animation data.
*/
public interface IAnimatedModel extends IModel
{
Optional<? extends IClip> getClip(String name);
}
@@ -1,12 +0,0 @@
package net.minecraftforge.client.model.animation;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
/**
* Something that can provide the Animation State Machine, for example and Entity or a Block
*/
public interface IAnimationProvider
{
public IAnimationStateMachine asm();
}
@@ -1,12 +0,0 @@
package net.minecraftforge.client.model.animation;
/**
* Clip for a rigged model.
*/
public interface IClip
{
IJointClip apply(IJoint joint);
Iterable<Event> pastEvents(float lastPollTime, float time);
}
@@ -1,10 +0,0 @@
package net.minecraftforge.client.model.animation;
/**
* Handler for animation events;
*/
public interface IEventHandler<T>
{
void handleEvents(T instance, float time, Iterable<Event> pastEvents);
}
@@ -1,16 +0,0 @@
package net.minecraftforge.client.model.animation;
import com.google.common.base.Optional;
import net.minecraftforge.client.model.IModelPart;
import net.minecraftforge.client.model.TRSRTransformation;
/**
* Model part that's a part of the hierarchical skeleton.
*/
public interface IJoint extends IModelPart
{
TRSRTransformation getInvBindPose();
Optional<? extends IJoint> getParent();
}
@@ -1,11 +0,0 @@
package net.minecraftforge.client.model.animation;
import net.minecraftforge.client.model.TRSRTransformation;
/**
* Returns Local joint pose; animation clip for specific model part.
*/
public interface IJointClip
{
TRSRTransformation apply(float time);
}
Loaded 100 of 225 files, more files were not shown because too many files have changed in this diff. Show more