diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bdb0cab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4b05a78 --- /dev/null +++ b/.gitignore @@ -0,0 +1,216 @@ +################# +## Eclipse +################# +.gradle +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml +*.publishproj + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +#packages/ + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +############# +## Windows detritus +############# + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac crap +.DS_Store + + +############# +## Python +############# + +*.py[cod] + +# Packages +*.egg +*.egg-info +dist/ +build/ +eggs/ +parts/ +var/ +sdist/ +develop-eggs/ +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg diff --git a/.gitmodules b/.gitmodules index 4dfba1b..12d77fe 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "ASMHelper"] - path = ASMHelper + path = squeek url = https://github.com/squeek502/ASMHelper diff --git a/ASMHelper b/ASMHelper deleted file mode 160000 index 91441be..0000000 --- a/ASMHelper +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 91441be539c9ba048dcfeaaa1182d0e23707f540 diff --git a/blargerist/cake/blockphysics/BlockPhysics.java b/blargerist/cake/blockphysics/BlockPhysics.java index bb6ed53..156f051 100644 --- a/blargerist/cake/blockphysics/BlockPhysics.java +++ b/blargerist/cake/blockphysics/BlockPhysics.java @@ -1,26 +1,19 @@ package blargerist.cake.blockphysics; - + import net.minecraftforge.common.MinecraftForge; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.Mod.Instance; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import blargerist.cake.blockphysics.events.BPEventHandler; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; -import cpw.mods.fml.common.registry.EntityRegistry; -import cpw.mods.fml.relauncher.Side; @Mod(modid = ModInfo.MODID, version = ModInfo.VERSION, dependencies = "", acceptableRemoteVersions = "*") public class BlockPhysics { - + @Instance("BlockPhysics") public static BlockPhysics instance; @@ -32,7 +25,7 @@ public void preInit(FMLPreInitializationEvent event) //FMLCommonHandler.instance().bus().register(new BPEventHandler()); } - @EventHandler + @EventHandler public void init(FMLInitializationEvent event) { } diff --git a/blargerist/cake/blockphysics/ModConfig.java b/blargerist/cake/blockphysics/ModConfig.java index 3ca4842..90a325f 100644 --- a/blargerist/cake/blockphysics/ModConfig.java +++ b/blargerist/cake/blockphysics/ModConfig.java @@ -12,9 +12,9 @@ public class ModConfig { private static Configuration config; - + public static ConfigCategory categoryMap = new ConfigCategory(null); - + public static int fallRange; //public static int fallRenderRange; //public static int maxMovingBlocks; diff --git a/blargerist/cake/blockphysics/ModInfo.java b/blargerist/cake/blockphysics/ModInfo.java index aa84b40..7456cd4 100644 --- a/blargerist/cake/blockphysics/ModInfo.java +++ b/blargerist/cake/blockphysics/ModInfo.java @@ -6,6 +6,6 @@ public final class ModInfo { public static final String MODID = "BlockPhysics"; - public static final String VERSION = "0.931b"; + public static final String VERSION = "0.932b"; public static final Logger Log = LogManager.getLogger(MODID); } \ No newline at end of file diff --git a/blargerist/cake/blockphysics/asm/ASMPlugin.java b/blargerist/cake/blockphysics/asm/ASMPlugin.java index de8bd1e..20fc48f 100644 --- a/blargerist/cake/blockphysics/asm/ASMPlugin.java +++ b/blargerist/cake/blockphysics/asm/ASMPlugin.java @@ -1,10 +1,11 @@ package blargerist.cake.blockphysics.asm; import java.util.Map; + +import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import squeek.asmhelper.ObfHelper; -import cpw.mods.fml.relauncher.IFMLLoadingPlugin; -@IFMLLoadingPlugin.MCVersion("1.7.10") +@IFMLLoadingPlugin.MCVersion("1.8") @IFMLLoadingPlugin.SortingIndex(1001) @IFMLLoadingPlugin.TransformerExclusions("blargerist.cake.blockphysics") public class ASMPlugin implements IFMLLoadingPlugin diff --git a/blargerist/cake/blockphysics/asm/modules/ModuleBlockFalling.java b/blargerist/cake/blockphysics/asm/modules/ModuleBlockFalling.java index 4c42fcd..867f6ad 100644 --- a/blargerist/cake/blockphysics/asm/modules/ModuleBlockFalling.java +++ b/blargerist/cake/blockphysics/asm/modules/ModuleBlockFalling.java @@ -1,15 +1,38 @@ package blargerist.cake.blockphysics.asm.modules; -import static org.objectweb.asm.Opcodes.*; +import static org.objectweb.asm.Opcodes.ALOAD; +import static org.objectweb.asm.Opcodes.ASM4; +import static org.objectweb.asm.Opcodes.GETFIELD; +import static org.objectweb.asm.Opcodes.GOTO; +import static org.objectweb.asm.Opcodes.IADD; +import static org.objectweb.asm.Opcodes.ICONST_0; +import static org.objectweb.asm.Opcodes.ICONST_1; +import static org.objectweb.asm.Opcodes.IFEQ; +import static org.objectweb.asm.Opcodes.ILOAD; +import static org.objectweb.asm.Opcodes.INSTANCEOF; +import static org.objectweb.asm.Opcodes.INVOKESTATIC; +import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL; +import static org.objectweb.asm.Opcodes.PUTFIELD; +import static org.objectweb.asm.Opcodes.RETURN; +import net.minecraft.launchwrapper.Launch; + import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Label; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.FieldVisitor; -import org.objectweb.asm.tree.*; +import org.objectweb.asm.tree.AbstractInsnNode; +import org.objectweb.asm.tree.ClassNode; +import org.objectweb.asm.tree.FieldInsnNode; +import org.objectweb.asm.tree.FieldNode; +import org.objectweb.asm.tree.InsnList; +import org.objectweb.asm.tree.InsnNode; +import org.objectweb.asm.tree.JumpInsnNode; +import org.objectweb.asm.tree.LabelNode; +import org.objectweb.asm.tree.MethodInsnNode; +import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.TypeInsnNode; +import org.objectweb.asm.tree.VarInsnNode; + import squeek.asmhelper.ASMHelper; -import blargerist.cake.blockphysics.BlockPhysics; import blargerist.cake.blockphysics.ModInfo; import blargerist.cake.blockphysics.asm.IClassTransformerModule; import blargerist.cake.blockphysics.asm.RemoveMethodAdapter; @@ -44,7 +67,7 @@ public boolean canBeDisabled() public byte[] transform(String name, String transformedName, byte[] bytes) { ClassNode classNode = ASMHelper.readClassFromBytes(bytes); - + boolean developmentEnvironment = (Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment"); if (transformedName.equals("net.minecraft.block.BlockFalling")) { ModInfo.Log.info("Transforming class: " + transformedName); @@ -55,41 +78,79 @@ public byte[] transform(String name, String transformedName, byte[] bytes) return cw.toByteArray(); } else if (transformedName.equals("net.minecraft.world.WorldServer")) - { + { ModInfo.Log.info("Transforming class: " + transformedName); - MethodNode methodNode = ASMHelper.findMethodNodeOfClass(classNode, "func_72955_a", "(Z)Z"); + MethodNode methodNode; + + String methodName; + if (developmentEnvironment) + { + methodName = "tickUpdates"; + } + else + { + methodName = "func_72955_a"; + } + methodNode = ASMHelper.findMethodNodeOfClass(classNode, methodName, "(Z)Z"); if (methodNode != null) { - injectTickUpdatesHook(methodNode); + injectTickUpdatesHook(methodNode, developmentEnvironment); } else throw new RuntimeException("Could not find tickUpdates method in " + transformedName); - methodNode = ASMHelper.findMethodNodeOfClass(classNode, "func_147454_a", "(IIILnet/minecraft/block/Block;II)V"); + if (developmentEnvironment) + { + methodName = "updateBlockTick"; + } + else + { + methodName = "func_175654_a"; + } + methodNode = ASMHelper.findMethodNodeOfClass(classNode, + methodName, + "(Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/Block;II)V"); if (methodNode != null) { - injectScheduleBlockUpdateWithPriorityHook(methodNode); + injectScheduleBlockUpdateWithPriorityHook(methodNode, developmentEnvironment); } else throw new RuntimeException("Could not find scheduleBlockUpdateWithPriority method in " + transformedName); - - methodNode = ASMHelper.findMethodNodeOfClass(classNode, "func_147456_g", "()V"); + + if (developmentEnvironment) + { + methodName = "updateBlocks"; + } + else + { + methodName = "func_147456_g"; + } + methodNode = ASMHelper.findMethodNodeOfClass(classNode, methodName, "()V"); if (methodNode != null) { - injectfunc_147456_gHook(methodNode); + injectfunc_147456_gHook(methodNode, developmentEnvironment); } else - throw new RuntimeException("Could not find func_147456_g method in " + transformedName); - + throw new RuntimeException("Could not find updateBlocks method in " + transformedName); + return ASMHelper.writeClassToBytes(classNode); } else if (transformedName.equals("net.minecraft.block.Block")) { + String methodName; + if (developmentEnvironment) + { + methodName = "onNeighborBlockChange"; + } + else + { + methodName = "func_176204_a"; + } ModInfo.Log.info("Transforming class: " + transformedName); - MethodNode methodNode = ASMHelper.findMethodNodeOfClass(classNode, "func_149695_a", "(Lnet/minecraft/world/World;IIILnet/minecraft/block/Block;)V"); + MethodNode methodNode = ASMHelper.findMethodNodeOfClass(classNode, methodName , "(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;Lnet/minecraft/block/Block;)V"); if (methodNode != null) { - transformOnNeighborBlockChange(methodNode); + transformOnNeighborBlockChange(methodNode, developmentEnvironment); } else throw new RuntimeException("Could not find onNeighborBlockChange method in " + transformedName); @@ -98,11 +159,20 @@ else if (transformedName.equals("net.minecraft.block.Block")) } else if (transformedName.equals("net.minecraft.entity.item.EntityFallingBlock")) { + String methodName; + if (developmentEnvironment) + { + methodName = "onUpdate"; + } + else + { + methodName = "func_70071_h_"; + } ModInfo.Log.info("Transforming class: " + transformedName); - MethodNode methodNode = ASMHelper.findMethodNodeOfClass(classNode, "func_70071_h_", "()V"); + MethodNode methodNode = ASMHelper.findMethodNodeOfClass(classNode, methodName, "()V"); if (methodNode != null) { - insertEntityFallingBlockOnUpdateHook(methodNode); + insertEntityFallingBlockOnUpdateHook(methodNode, developmentEnvironment); } else throw new RuntimeException("Could not find onUpdate method in " + transformedName); @@ -110,15 +180,17 @@ else if (transformedName.equals("net.minecraft.entity.item.EntityFallingBlock")) methodNode = ASMHelper.findMethodNodeOfClass(classNode, "", "(Lnet/minecraft/world/World;)V"); if (methodNode != null) { - insertFrustumNoClip1(methodNode); + insertFrustumNoClip1(methodNode, developmentEnvironment); } else throw new RuntimeException("Could not find method in " + transformedName); - methodNode = ASMHelper.findMethodNodeOfClass(classNode, "", "(Lnet/minecraft/world/World;DDDLnet/minecraft/block/Block;I)V"); + methodNode = ASMHelper.findMethodNodeOfClass(classNode, + "", + "(Lnet/minecraft/world/World;DDDLnet/minecraft/block/state/IBlockState;)V"); if (methodNode != null) { - insertFrustumNoClip2(methodNode); + insertFrustumNoClip2(methodNode, developmentEnvironment); } else throw new RuntimeException("Could not find method in " + transformedName); @@ -127,11 +199,20 @@ else if (transformedName.equals("net.minecraft.entity.item.EntityFallingBlock")) } else if (transformedName.equals("net.minecraft.entity.Entity")) { + String methodName; + if (developmentEnvironment) + { + methodName = "moveEntity"; + } + else + { + methodName = "func_70091_d"; + } ModInfo.Log.info("Transforming class: " + transformedName); - MethodNode methodNode = ASMHelper.findMethodNodeOfClass(classNode, "func_70091_d", "(DDD)V"); + MethodNode methodNode = ASMHelper.findMethodNodeOfClass(classNode, methodName, "(DDD)V"); if (methodNode != null) { - injectIfBlockFalling(methodNode); + injectIfBlockFalling(methodNode, developmentEnvironment); } else throw new RuntimeException("Could not find moveEntity method in " + transformedName); @@ -150,7 +231,7 @@ public void verifyMethodAdded(ClassNode classNode, String name, String desc) } else throw new RuntimeException("Could not create method: " + name + desc + " in " + classNode.name); } - +/* public void verifyFieldAdded(ClassNode classNode, String name, String desc) { FieldNode fieldNode = ASMHelper.findFieldNodeOfClass(classNode, name, desc); @@ -160,11 +241,23 @@ public void verifyFieldAdded(ClassNode classNode, String name, String desc) } else throw new RuntimeException("Could not create field: " + name + desc + " in " + classNode.name); } - - public void injectTickUpdatesHook(MethodNode method) +*/ + public void injectTickUpdatesHook(MethodNode method, boolean developmentEnvironment) { + String functionName; + if (developmentEnvironment) + { + functionName = "updateTick"; + } + else + { + functionName = "func_180650_b"; + } InsnList toFind = new InsnList(); - toFind.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/block/Block", "func_149674_a", "(Lnet/minecraft/world/World;IIILjava/util/Random;)V", false)); + toFind.add(new MethodInsnNode(INVOKEVIRTUAL, + "net/minecraft/block/Block", + functionName, + "(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;Ljava/util/Random;)V", false)); AbstractInsnNode target = ASMHelper.find(method.instructions, toFind); if (target == null) @@ -172,23 +265,64 @@ public void injectTickUpdatesHook(MethodNode method) InsnList toInject = new InsnList(); toInject.add(new VarInsnNode(ALOAD, 0)); - toInject.add(new VarInsnNode(ALOAD, 4)); - toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/NextTickListEntry", "field_77183_a", "I")); - toInject.add(new VarInsnNode(ALOAD, 4)); - toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/NextTickListEntry", "field_77181_b", "I")); - toInject.add(new VarInsnNode(ALOAD, 4)); - toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/NextTickListEntry", "field_77182_c", "I")); + + // Weird? + if (developmentEnvironment) + { + toInject.add(new VarInsnNode(ALOAD, 3)); + } + else + { + toInject.add(new VarInsnNode(ALOAD, 4)); + } + + String fieldName; + if (developmentEnvironment) + { + fieldName = "position"; + } + else + { + fieldName = "field_180282_a"; + } + + toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/NextTickListEntry", fieldName, "Lnet/minecraft/util/BlockPos;")); toInject.add(new VarInsnNode(ALOAD, 0)); - toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/WorldServer", "field_73012_v", "Ljava/util/Random;")); - toInject.add(new MethodInsnNode(INVOKESTATIC, "blargerist/cake/blockphysics/events/BPEventHandler", "onUpdateBlock", "(Lnet/minecraft/world/World;IIILjava/util/Random;)V", false)); + if (developmentEnvironment) + { + fieldName = "rand"; + } + else + { + fieldName = "field_73012_v"; + } + + toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/WorldServer", fieldName, "Ljava/util/Random;")); + toInject.add(new MethodInsnNode(INVOKESTATIC, + "blargerist/cake/blockphysics/events/BPEventHandler", + "onUpdateBlock", + "(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Ljava/util/Random;)V", false)); method.instructions.insert(target, toInject); } - public void injectScheduleBlockUpdateWithPriorityHook(MethodNode method) - { + public void injectScheduleBlockUpdateWithPriorityHook(MethodNode method, boolean developmentEnvironment) + { + String functionName; + if (developmentEnvironment) + { + functionName = "updateTick"; + } + else + { + functionName = "func_180650_b"; + } InsnList toFind = new InsnList(); - toFind.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/block/Block", "func_149674_a", "(Lnet/minecraft/world/World;IIILjava/util/Random;)V", false)); + toFind.add(new MethodInsnNode(INVOKEVIRTUAL, + "net/minecraft/block/Block", + functionName, + "(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;Ljava/util/Random;)V", false)); + AbstractInsnNode target = ASMHelper.find(method.instructions, toFind); if (target == null) @@ -196,66 +330,121 @@ public void injectScheduleBlockUpdateWithPriorityHook(MethodNode method) InsnList toInject = new InsnList(); toInject.add(new VarInsnNode(ALOAD, 0)); - toInject.add(new VarInsnNode(ALOAD, 7)); - toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/NextTickListEntry", "field_77183_a", "I")); - toInject.add(new VarInsnNode(ALOAD, 7)); - toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/NextTickListEntry", "field_77181_b", "I")); - toInject.add(new VarInsnNode(ALOAD, 7)); - toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/NextTickListEntry", "field_77182_c", "I")); + toInject.add(new VarInsnNode(ALOAD, 5)); + String fieldName; + if (developmentEnvironment) + { + fieldName = "position"; + } + else + { + fieldName = "field_180282_a"; + } + + toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/NextTickListEntry", fieldName, "Lnet/minecraft/util/BlockPos;")); toInject.add(new VarInsnNode(ALOAD, 0)); - toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/WorldServer", "field_73012_v", "Ljava/util/Random;")); - toInject.add(new MethodInsnNode(INVOKESTATIC, "blargerist/cake/blockphysics/events/BPEventHandler", "onUpdateBlock", "(Lnet/minecraft/world/World;IIILjava/util/Random;)V", false)); + if (developmentEnvironment) + { + fieldName = "rand"; + } + else + { + fieldName = "field_73012_v"; + } + toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/WorldServer", fieldName, "Ljava/util/Random;")); + toInject.add(new MethodInsnNode(INVOKESTATIC, + "blargerist/cake/blockphysics/events/BPEventHandler", + "onUpdateBlock", + "(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Ljava/util/Random;)V", + false)); method.instructions.insert(target, toInject); } - public void injectfunc_147456_gHook(MethodNode method) - { - InsnList toFind = new InsnList(); - toFind.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/block/Block", "func_149674_a", "(Lnet/minecraft/world/World;IIILjava/util/Random;)V", false)); - AbstractInsnNode target = ASMHelper.find(method.instructions, toFind); + public void injectfunc_147456_gHook(MethodNode method, boolean developmentEnvironment) + { + String functionName; + if (developmentEnvironment) + { + functionName = "randomTick"; + } + else + { + functionName = "func_180645_a"; + } + InsnList toFind = new InsnList(); + toFind.add(new MethodInsnNode(INVOKEVIRTUAL, + "net/minecraft/block/Block", + functionName, + "(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/state/IBlockState;Ljava/util/Random;)V", false)); + + AbstractInsnNode target = ASMHelper.find(method.instructions, toFind); if (target == null) throw new RuntimeException("Unexpected instruction pattern in WorldServer.func_147456_g"); InsnList toInject = new InsnList(); - toInject.add(new VarInsnNode(ALOAD, 0)); + toInject.add(new VarInsnNode(ALOAD, 0)); + toInject.add(new VarInsnNode(ALOAD, 19)); + +/* toInject.add(new VarInsnNode(ILOAD, 16)); toInject.add(new VarInsnNode(ILOAD, 5)); toInject.add(new InsnNode(IADD)); toInject.add(new VarInsnNode(ILOAD, 18)); - toInject.add(new VarInsnNode(ALOAD, 13)); - toInject.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/world/chunk/storage/ExtendedBlockStorage", "func_76662_d", "()I", false)); + toInject.add(new VarInsnNode(ALOAD, 11)); + toInject.add(new MethodInsnNode(INVOKEVIRTUAL, + "net/minecraft/world/chunk/storage/ExtendedBlockStorage", + "getYLocation", + "()I", + false)); toInject.add(new InsnNode(IADD)); toInject.add(new VarInsnNode(ILOAD, 17)); toInject.add(new VarInsnNode(ILOAD, 6)); toInject.add(new InsnNode(IADD)); +*/ toInject.add(new VarInsnNode(ALOAD, 0)); - toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/WorldServer", "field_73012_v", "Ljava/util/Random;")); - toInject.add(new MethodInsnNode(INVOKESTATIC, "blargerist/cake/blockphysics/events/BPEventHandler", "onUpdateBlock", "(Lnet/minecraft/world/World;IIILjava/util/Random;)V", false)); + String fieldName; + if (developmentEnvironment) + { + fieldName = "rand"; + } + else + { + fieldName = "field_73012_v"; + } + toInject.add(new FieldInsnNode(GETFIELD, "net/minecraft/world/WorldServer", fieldName, "Ljava/util/Random;")); + toInject.add(new MethodInsnNode(INVOKESTATIC, + "blargerist/cake/blockphysics/events/BPEventHandler", + "onUpdateBlock", + "(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Ljava/util/Random;)V", false)); method.instructions.insert(target, toInject); } - public void transformOnNeighborBlockChange(MethodNode method) + public void transformOnNeighborBlockChange(MethodNode method, boolean developmentEnvironment) { - AbstractInsnNode target = ASMHelper.findLastInstructionWithOpcode(method, RETURN); + AbstractInsnNode target = ASMHelper.findLastInstructionWithOpcode(method, RETURN); if (target == null) throw new RuntimeException("Unexpected instruction pattern in Block.onNeighborBlockChange"); InsnList toInject = new InsnList(); toInject.add(new VarInsnNode(ALOAD, 1)); - toInject.add(new VarInsnNode(ILOAD, 2)); - toInject.add(new VarInsnNode(ILOAD, 3)); - toInject.add(new VarInsnNode(ILOAD, 4)); - toInject.add(new VarInsnNode(ALOAD, 5)); - toInject.add(new MethodInsnNode(INVOKESTATIC, "blargerist/cake/blockphysics/events/BPEventHandler", "onNeighborBlockChange", "(Lnet/minecraft/world/World;IIILnet/minecraft/block/Block;)V", false)); + toInject.add(new VarInsnNode(ALOAD, 2)); + //toInject.add(new VarInsnNode(ALOAD, 3)); + toInject.add(new VarInsnNode(ALOAD, 4)); + //toInject.add(new VarInsnNode(ALOAD, 5)); + toInject.add(new MethodInsnNode(INVOKESTATIC, + "blargerist/cake/blockphysics/events/BPEventHandler", + "onNeighborBlockChange", + "(Lnet/minecraft/world/World;Lnet/minecraft/util/BlockPos;Lnet/minecraft/block/Block;)V", false)); method.instructions.insertBefore(target, toInject); + } - public void insertEntityFallingBlockOnUpdateHook(MethodNode method) + public void insertEntityFallingBlockOnUpdateHook(MethodNode method, boolean developmentEnvironment) { AbstractInsnNode target = ASMHelper.findFirstInstruction(method); @@ -264,13 +453,16 @@ public void insertEntityFallingBlockOnUpdateHook(MethodNode method) InsnList toInject = new InsnList(); toInject.add(new VarInsnNode(ALOAD, 0)); - toInject.add(new MethodInsnNode(INVOKESTATIC, "blargerist/cake/blockphysics/util/EntityMove", "onUpdate", "(Lnet/minecraft/entity/item/EntityFallingBlock;)V", false)); + toInject.add(new MethodInsnNode(INVOKESTATIC, + "blargerist/cake/blockphysics/util/EntityMove", + "onUpdate", + "(Lnet/minecraft/entity/item/EntityFallingBlock;)V", false)); toInject.add(new InsnNode(RETURN)); method.instructions.insertBefore(target, toInject); } - public void insertFrustumNoClip1(MethodNode method) + public void insertFrustumNoClip1(MethodNode method, boolean developmentEnvironment) { AbstractInsnNode target = ASMHelper.findLastInstructionWithOpcode(method, RETURN); @@ -280,7 +472,16 @@ public void insertFrustumNoClip1(MethodNode method) InsnList toInject = new InsnList(); toInject.add(new VarInsnNode(ALOAD, 0)); toInject.add(new InsnNode(ICONST_0)); - toInject.add(new FieldInsnNode(PUTFIELD, "net/minecraft/entity/item/EntityFallingBlock", "field_70158_ak", "Z")); + String fieldName; + if (developmentEnvironment) + { + fieldName = "ignoreFrustumCheck"; + } + else + { + fieldName = "field_70158_ak"; + } + toInject.add(new FieldInsnNode(PUTFIELD, "net/minecraft/entity/item/EntityFallingBlock", fieldName, "Z")); //toInject.add(new VarInsnNode(ALOAD, 0)); //toInject.add(new InsnNode(ICONST_1)); //toInject.add(new FieldInsnNode(PUTFIELD, "net/minecraft/entity/item/EntityFallingBlock", "field_70145_X", "Z")); @@ -288,7 +489,7 @@ public void insertFrustumNoClip1(MethodNode method) method.instructions.insertBefore(target, toInject); } - public void insertFrustumNoClip2(MethodNode method) + public void insertFrustumNoClip2(MethodNode method, boolean developmentEnvironment) { AbstractInsnNode target = ASMHelper.findLastInstructionWithOpcode(method, RETURN); @@ -298,19 +499,46 @@ public void insertFrustumNoClip2(MethodNode method) InsnList toInject = new InsnList(); toInject.add(new VarInsnNode(ALOAD, 0)); toInject.add(new InsnNode(ICONST_0)); - toInject.add(new FieldInsnNode(PUTFIELD, "net/minecraft/entity/item/EntityFallingBlock", "field_70158_ak", "Z")); + String fieldName; + if (developmentEnvironment) + { + fieldName = "ignoreFrustumCheck"; + } + else + { + fieldName = "field_70158_ak"; + } + toInject.add(new FieldInsnNode(PUTFIELD, "net/minecraft/entity/item/EntityFallingBlock", fieldName, "Z")); toInject.add(new VarInsnNode(ALOAD, 0)); toInject.add(new InsnNode(ICONST_1)); - toInject.add(new FieldInsnNode(PUTFIELD, "net/minecraft/entity/item/EntityFallingBlock", "field_70145_X", "Z")); + if (developmentEnvironment) + { + fieldName = "noClip"; + } + else + { + fieldName = "field_70145_X"; + } + toInject.add(new FieldInsnNode(PUTFIELD, "net/minecraft/entity/item/EntityFallingBlock", fieldName, "Z")); method.instructions.insertBefore(target, toInject); } - public void injectIfBlockFalling(MethodNode method) + public void injectIfBlockFalling(MethodNode method, boolean developmentEnvironment) { InsnList toFind = new InsnList(); toFind.add(new VarInsnNode(ALOAD, 0)); - toFind.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/entity/Entity", "func_145775_I", "()V", false)); + String functionName; + if (developmentEnvironment) + { + functionName = "doBlockCollisions"; + } + else + { + functionName = "func_145775_I"; + } + + toFind.add(new MethodInsnNode(INVOKEVIRTUAL, "net/minecraft/entity/Entity", functionName, "()V", false)); AbstractInsnNode start = ASMHelper.find(method.instructions, toFind); AbstractInsnNode end = ASMHelper.move(start, 1); @@ -324,7 +552,11 @@ public void injectIfBlockFalling(MethodNode method) LabelNode label1 = new LabelNode(); firstInject.add(new JumpInsnNode(IFEQ, label1)); firstInject.add(new VarInsnNode(ALOAD, 0)); - firstInject.add(new MethodInsnNode(INVOKESTATIC, "blargerist/cake/blockphysics/util/EntityMove", "checkEntityBlockCollisions", "(Lnet/minecraft/entity/Entity;)V", false)); + firstInject.add(new MethodInsnNode(INVOKESTATIC, + "blargerist/cake/blockphysics/util/EntityMove", + "checkEntityBlockCollisions", + "(Lnet/minecraft/entity/Entity;)V", + false)); LabelNode label2 = new LabelNode(); firstInject.add(new JumpInsnNode(GOTO, label2)); firstInject.add(label1); diff --git a/blargerist/cake/blockphysics/events/BPEventHandler.java b/blargerist/cake/blockphysics/events/BPEventHandler.java index a60bc93..b6eea0f 100644 --- a/blargerist/cake/blockphysics/events/BPEventHandler.java +++ b/blargerist/cake/blockphysics/events/BPEventHandler.java @@ -1,39 +1,35 @@ package blargerist.cake.blockphysics.events; import java.util.ArrayList; -import java.util.Iterator; import java.util.Random; + import net.minecraft.block.Block; -import net.minecraft.block.BlockFalling; -import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityFallingBlock; import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; +import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.event.world.BlockEvent.PlaceEvent; -import blargerist.cake.blockphysics.ModInfo; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import blargerist.cake.blockphysics.util.BlockMove; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class BPEventHandler { static ArrayList tickingBlocks = new ArrayList(); - public static void onNeighborBlockChange(World world, int x, int y, int z, Block blockNeighbor) + public static void onNeighborBlockChange(World world, BlockPos blockPos, Block blockNeighbor) { if (!world.isRemote) { - Block block = world.getBlock(x, y, z); + Block block = world.getBlockState(blockPos).getBlock(); Material material = block.getMaterial(); - String blockName = Block.blockRegistry.getNameForObject(block); - if (material == Material.air || block.getBlockHardness(world, x, y, z) == -1.0F || material.isLiquid() || material.isReplaceable() || material == Material.plants || material == Material.portal) + if (material == Material.air || + block.getBlockHardness(world, blockPos) == -1.0F || + material.isLiquid() || + material.isReplaceable() || + material == Material.plants || + material == Material.portal) { return; } @@ -41,38 +37,43 @@ public static void onNeighborBlockChange(World world, int x, int y, int z, Block if (!tickingBlocks.contains(block)) { tickingBlocks.add(block); - world.scheduleBlockUpdate(x, y, z, block, block.tickRate(world)); + world.scheduleUpdate(blockPos, block, block.tickRate(world)); tickingBlocks.remove(block); } } } - @SubscribeEvent - public void onPlayerBlockPlace(PlaceEvent event) - { - event.world.scheduleBlockUpdate(event.x, event.y, event.z, event.block, event.block.tickRate(event.world)); - } + @SubscribeEvent + public void onPlayerBlockPlace(PlaceEvent event) + { + event.world.scheduleUpdate(event.pos, event.state.getBlock(), event.state.getBlock().tickRate(event.world)); + } - public static void onUpdateBlock(World world, int x, int y, int z, Random random) + public static void onUpdateBlock(World world, BlockPos blockPos, Random random) { if (!world.isRemote) { - Block block = world.getBlock(x, y, z); - String blockName = Block.blockRegistry.getNameForObject(block); + Block block = world.getBlockState(blockPos).getBlock(); Material material = block.getMaterial(); - if (material == Material.air || block.getBlockHardness(world, x, y, z) == -1.0F || material.isLiquid() || material.isReplaceable() || material == Material.plants || material == Material.portal) + if (material == Material.air || + block.getBlockHardness(world, blockPos) == -1.0F || + material.isLiquid() || + material.isReplaceable() || + material == Material.plants || + material == Material.portal) { return; } - BlockMove.fall(world, x, y, z); + BlockMove.fall(world, blockPos); } } public static boolean func_149831_e(World p_149831_0_, int p_149831_1_, int p_149831_2_, int p_149831_3_) { - Block block = p_149831_0_.getBlock(p_149831_1_, p_149831_2_, p_149831_3_); + BlockPos blockPos = new BlockPos(p_149831_1_, p_149831_2_, p_149831_3_); + Block block = p_149831_0_.getBlockState(blockPos).getBlock(); - if (block.isAir(p_149831_0_, p_149831_1_, p_149831_2_, p_149831_3_)) + if (block.isAir(p_149831_0_, blockPos)) { return true; } @@ -89,6 +90,7 @@ else if (block == Blocks.fire) public static void onFragileBlockCollision(Entity entity, int x, int y, int z) { - entity.worldObj.setBlockToAir(x, y, z); + BlockPos blockPos = new BlockPos(x, y, z); + entity.worldObj.setBlockToAir(blockPos); } } \ No newline at end of file diff --git a/blargerist/cake/blockphysics/util/BlockMove.java b/blargerist/cake/blockphysics/util/BlockMove.java index fd3faa5..cf667a5 100644 --- a/blargerist/cake/blockphysics/util/BlockMove.java +++ b/blargerist/cake/blockphysics/util/BlockMove.java @@ -1,33 +1,40 @@ package blargerist.cake.blockphysics.util; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityFallingBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.util.BlockPos; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import blargerist.cake.blockphysics.ModConfig; -import blargerist.cake.blockphysics.ModInfo; public class BlockMove { private static Random rand = new Random(); - public static void fall(World world, int x, int y, int z) + public static void fall(World world, BlockPos inBlockPos) { + int x = inBlockPos.getX(); + int y = inBlockPos.getY(); + int z = inBlockPos.getZ(); + if (!world.isRemote) { if (playersWithinRange(world, x, y, z)) { byte b0 = 32; - - if (world.checkChunksExist(x - b0, y - b0, z - b0, x + b0, y + b0, z + b0)) - { - Block block = world.getBlock(x, y, z); - String blockName = Block.blockRegistry.getNameForObject(block); - int meta = world.getBlockMetadata(x, y, z); + BlockPos start = new BlockPos (x - b0, y - b0, z - b0); + BlockPos end = new BlockPos(x + b0, y + b0, z + b0); + if (world.isAreaLoaded(start, end)) + { + Block block = world.getBlockState(inBlockPos).getBlock(); + String blockName = Block.blockRegistry.getNameForObject(block).toString(); + int meta = world.getBlockState(inBlockPos).getBlock().getMetaFromState(world.getBlockState(inBlockPos)); BlockDef blockDef = DefinitionMaps.getBlockDef(blockName, meta); if (blockDef.canMove) @@ -36,7 +43,7 @@ public static void fall(World world, int x, int y, int z) //TODO use an array to store blocks in the area as they are required, to cut down on use of world.getblock if (!floating(world, x, y, z, moveDef.floatingRadius, moveDef.floatingBlock, moveDef.floatingMeta)) { - int canFall = canMoveTo(world, x, y - 1, z, blockDef.mass / 10); + int canFall = canMoveTo(world,x, y - 1 , z, blockDef.mass / 10); if (canFall != 0 && (moveDef.moveType == 1 || moveDef.moveType == 2)) { @@ -58,12 +65,17 @@ public static void fall(World world, int x, int y, int z) { if (!moveDef.branch || !branch(world, x, y, z, blockName, meta)) { - EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block, meta); - entityfallingblock.func_145806_a(blockDef.hurts); + EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, + (double) ((float) x + 0.5F), + (double) ((float) y + 0.5F), + (double) ((float) z + 0.5F), + block.getStateFromMeta(meta)); + entityfallingblock.setHurtEntities (blockDef.hurts); entityfallingblock.noClip = false; if (canFall == 2) { - world.setBlockToAir(x, y - 1, z); + BlockPos blockPosDownOne = new BlockPos(x, y - 1, z); + world.setBlockToAir(blockPosDownOne); } world.spawnEntityInWorld(entityfallingblock); return; @@ -73,7 +85,8 @@ public static void fall(World world, int x, int y, int z) } } } - }} + } + } } } else if (canFall == 0 && moveDef.moveType == 2 && moveDef.slideChance >= (rand.nextInt(100) + 1)) @@ -151,74 +164,56 @@ else if (canFall == 0 && moveDef.moveType == 2 && moveDef.slideChance >= (rand.n if (!moveDef.branch || !branch(world, x, y, z, blockName, meta)) { String direction = slideDirs[rand.nextInt(length)]; + double motionX = 0; + double motionZ = 0; if (direction.equals("north")) { - EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block, meta); - entityfallingblock.func_145806_a(blockDef.hurts); - entityfallingblock.motionZ = 0.135; - world.spawnEntityInWorld(entityfallingblock); - return; + motionZ = 0.135; } else if (direction.equals("south")) { - EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block, meta); - entityfallingblock.func_145806_a(blockDef.hurts); - entityfallingblock.motionZ = -0.135; - world.spawnEntityInWorld(entityfallingblock); - return; + motionZ = -0.135; } else if (direction.equals("east")) { - EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block, meta); - entityfallingblock.func_145806_a(blockDef.hurts); - entityfallingblock.motionX = 0.135; - world.spawnEntityInWorld(entityfallingblock); - return; + motionX = 0.135; } else if (direction.equals("west")) { - EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block, meta); - entityfallingblock.func_145806_a(blockDef.hurts); - entityfallingblock.motionX = -0.135; - world.spawnEntityInWorld(entityfallingblock); - return; + motionX = -0.135; } else if (direction.equals("northeast")) { - EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block, meta); - entityfallingblock.func_145806_a(blockDef.hurts); - entityfallingblock.motionZ = 0.135; - entityfallingblock.motionX = 0.135; - world.spawnEntityInWorld(entityfallingblock); - return; + motionZ = 0.135; + motionX = 0.135; } else if (direction.equals("northwest")) { - EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block, meta); - entityfallingblock.func_145806_a(blockDef.hurts); - entityfallingblock.motionZ = 0.135; - entityfallingblock.motionX = -0.135; - world.spawnEntityInWorld(entityfallingblock); - return; + motionZ = 0.135; + motionX = -0.135; } else if (direction.equals("southeast")) { - EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block, meta); - entityfallingblock.func_145806_a(blockDef.hurts); - entityfallingblock.motionZ = -0.135; - entityfallingblock.motionX = 0.135; - world.spawnEntityInWorld(entityfallingblock); - return; + motionZ = -0.135; + motionX = 0.135; } else if (direction.equals("southwest")) { - EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), (double) ((float) z + 0.5F), block, meta); - entityfallingblock.func_145806_a(blockDef.hurts); - entityfallingblock.motionZ = -0.135; - entityfallingblock.motionX = -0.135; - world.spawnEntityInWorld(entityfallingblock); - return; + motionZ = -0.135; + motionX = -0.135; } + + EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, + (double) ((float) x + 0.5F), + (double) ((float) y + 0.5F), + (double) ((float) z + 0.5F), + block.getStateFromMeta(meta)); + entityfallingblock.motionZ = motionZ; + entityfallingblock.motionX = motionX; + entityfallingblock.setHurtEntities (blockDef.hurts); + world.spawnEntityInWorld(entityfallingblock); + return; + } } } @@ -242,18 +237,20 @@ else if (moveDef.moveType == 3) public static int canMoveTo(World world, int x, int y, int z, int mass) { - Block block = world.getBlock(x, y, z); + BlockPos blockPos = new BlockPos(x, y, z); + Block block = world.getBlockState(blockPos).getBlock(); if (block == Blocks.air) { return 1; } - if (block.getBlockHardness(world, x, y, z) == -1) + if (block.getBlockHardness(world, blockPos) == -1) { return 0; } - String blockName = Block.blockRegistry.getNameForObject(block); - int meta = world.getBlockMetadata(x, y, z); - BlockDef blockDef = DefinitionMaps.getBlockDef(blockName, meta); + Object blockName = Block.blockRegistry.getNameForObject(block); + String blockNameString = blockName.toString(); + int meta = world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)); + BlockDef blockDef = DefinitionMaps.getBlockDef(blockNameString, meta); if ((blockDef.fragile > 0 && blockDef.strength < mass)) { return 2; @@ -284,7 +281,15 @@ private static boolean floating(World world, int x, int y, int z, int radius, St { for (int zz = z - radius; zz <= z + radius; zz++) { - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(xx, yy, zz)), world.getBlockMetadata(xx, yy, zz), blockName, meta)) + BlockPos blockPos = new BlockPos(xx, yy, zz); + Block block = world.getBlockState(blockPos).getBlock(); + + String otherBlockName = Block.blockRegistry.getNameForObject(block).toString(); + int otherMeta = world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)); + if (sameBlock(otherBlockName, + otherMeta, + blockName, + meta)) { return true; } @@ -306,8 +311,9 @@ private static boolean hanging(World world, int x, int y, int z, int hanging, St for (int i = y; i < hanging; i++) { - blockName2 = Block.blockRegistry.getNameForObject(world.getBlock(x, i, z)); - meta2 = world.getBlockMetadata(x, i, z); + BlockPos blockPos = new BlockPos(x, i, z); + blockName2 = Block.blockRegistry.getNameForObject(world.getBlockState(blockPos).getBlock()).toString(); + meta2 = world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)); if (DefinitionMaps.getBlockDef(blockName2, meta2).supportiveBlock) { return true; @@ -333,8 +339,9 @@ private static boolean attached(World world, int x, int y, int z, int attached, for (i = 1; i <= attached; i++) { - blockName2 = Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z)); - meta2 = world.getBlockMetadata(x + i, y, z); + BlockPos blockPos = new BlockPos(x + 1, y, z); + blockName2 = Block.blockRegistry.getNameForObject(world.getBlockState(blockPos).getBlock()).toString(); + meta2 = world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)); if (DefinitionMaps.getBlockDef(blockName2, meta2).supportiveBlock) { return true; @@ -347,8 +354,9 @@ else if (!sameBlock(blockName, meta, blockName2, meta2)) for (i = 1; i <= attached; i++) { - blockName2 = Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z)); - meta2 = world.getBlockMetadata(x - i, y, z); + BlockPos blockPos = new BlockPos(x - i, y, z); + blockName2 = (String) Block.blockRegistry.getNameForObject(world.getBlockState(blockPos).getBlock()); + meta2 = world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)); if (DefinitionMaps.getBlockDef(blockName2, meta2).supportiveBlock) { return true; @@ -361,8 +369,9 @@ else if (!sameBlock(blockName, meta, blockName2, meta2)) for (i = 1; i <= attached; i++) { - blockName2 = Block.blockRegistry.getNameForObject(world.getBlock(x, y, z + i)); - meta2 = world.getBlockMetadata(x, y, z + i); + BlockPos blockPos = new BlockPos(x, y, z + i); + blockName2 = (String) Block.blockRegistry.getNameForObject(world.getBlockState(blockPos).getBlock()); + meta2 = world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)); if (DefinitionMaps.getBlockDef(blockName2, meta2).supportiveBlock) { return true; @@ -375,8 +384,9 @@ else if (!sameBlock(blockName, meta, blockName2, meta2)) for (i = 1; i <= attached; i++) { - blockName2 = Block.blockRegistry.getNameForObject(world.getBlock(x, y, z - i)); - meta2 = world.getBlockMetadata(x, y, z - i); + BlockPos blockPos = new BlockPos(x, y, z - i); + blockName2 = (String) Block.blockRegistry.getNameForObject(world.getBlockState(blockPos).getBlock()); + meta2 = world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)); if (DefinitionMaps.getBlockDef(blockName2, meta2).supportiveBlock) { return true; @@ -399,9 +409,9 @@ private static boolean nCorbel(World world, int x, int y, int z, int nCorbel) for (i = 1; i <= nCorbel; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z)), world.getBlockMetadata(x - i, y, z)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y, z)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y - 1, z)), world.getBlockMetadata(x - i, y - 1, z)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y - 1, z)) { return true; } @@ -413,9 +423,9 @@ private static boolean nCorbel(World world, int x, int y, int z, int nCorbel) } for (i = 1; i <= nCorbel; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z)), world.getBlockMetadata(x + i, y, z)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y, z)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y - 1, z)), world.getBlockMetadata(x + i, y - 1, z)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y - 1, z)) { return true; } @@ -427,9 +437,9 @@ private static boolean nCorbel(World world, int x, int y, int z, int nCorbel) } for (i = 1; i <= nCorbel; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z + i)), world.getBlockMetadata(x, y, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x, y, z + i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z + i)), world.getBlockMetadata(x, y - 1, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x, y - 1, z + i)) { return true; } @@ -441,9 +451,9 @@ private static boolean nCorbel(World world, int x, int y, int z, int nCorbel) } for (i = 1; i <= nCorbel; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z - i)), world.getBlockMetadata(x, y, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x, y, z - i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z - i)), world.getBlockMetadata(x, y - 1, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x, y - 1, z - i)) { return true; } @@ -466,9 +476,9 @@ private static boolean corbel(World world, int x, int y, int z, int corbel, Stri for (i = 1; i <= corbel; i++) { - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z)), world.getBlockMetadata(x + i, y, z), blockName, meta)) + if (sameBlock(world, x + i, y, z, blockName, meta)) { - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y - 1, z)), world.getBlockMetadata(x + i, y - 1, z), blockName, meta)) + if (sameBlock(world, x + i, y - 1, z, blockName, meta)) { return true; } @@ -480,9 +490,9 @@ private static boolean corbel(World world, int x, int y, int z, int corbel, Stri } for (i = 1; i <= corbel; i++) { - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z)), world.getBlockMetadata(x - i, y, z), blockName, meta)) + if (sameBlock(world, x - i, y, z, blockName, meta)) { - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y - 1, z)), world.getBlockMetadata(x - i, y - 1, z), blockName, meta)) + if (sameBlock(world, x - i, y - 1, z, blockName, meta)) { return true; } @@ -494,9 +504,9 @@ private static boolean corbel(World world, int x, int y, int z, int corbel, Stri } for (i = 1; i <= corbel; i++) { - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z + i)), world.getBlockMetadata(x, y, z + i), blockName, meta)) + if (sameBlock(world, x, y, z + i, blockName, meta)) { - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z + i)), world.getBlockMetadata(x, y - 1, z + i), blockName, meta)) + if (sameBlock(world, x, y - 1, z + i, blockName, meta)) { return true; } @@ -508,9 +518,9 @@ private static boolean corbel(World world, int x, int y, int z, int corbel, Stri } for (i = 1; i <= corbel; i++) { - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z - i)), world.getBlockMetadata(x, y, z - i), blockName, meta)) + if (sameBlock(world, x, y, z - i, blockName, meta)) { - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z - i)), world.getBlockMetadata(x, y - 1, z - i), blockName, meta)) + if (sameBlock(world, x, y - 1, z - i, blockName, meta)) { return true; } @@ -525,19 +535,23 @@ private static boolean corbel(World world, int x, int y, int z, int corbel, Stri private static boolean ceiling(World world, int x, int y, int z) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y, z)), world.getBlockMetadata(x - 1, y, z)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y, z)), world.getBlockMetadata(x + 1, y, z)).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y, z) && + isSupportiveBlock(world, x + 1, y, z)) { return true; } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z - 1)), world.getBlockMetadata(x, y, z - 1)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z + 1)), world.getBlockMetadata(x, y, z + 1)).supportiveBlock) + if (isSupportiveBlock(world, x, y, z - 1) && + isSupportiveBlock(world, x, y, z + 1)) { return true; } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y, z - 1)), world.getBlockMetadata(x - 1, y, z - 1)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y, z + 1)), world.getBlockMetadata(x + 1, y, z + 1)).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y, z - 1) && + isSupportiveBlock(world, x + 1, y, z + 1)) { return true; } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y, z + 1)), world.getBlockMetadata(x - 1, y, z + 1)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y, z - 1)), world.getBlockMetadata(x + 1, y, z - 1)).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y, z + 1) && + isSupportiveBlock(world, x + 1, y, z - 1)) { return true; } @@ -550,9 +564,11 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) { return false; } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y, z)), world.getBlockMetadata(x - 1, y, z)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y, z)), world.getBlockMetadata(x + 1, y, z)).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y, z) && + isSupportiveBlock(world, x + 1, y, z)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y - 1, z)), world.getBlockMetadata(x - 1, y - 1, z)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y - 1, z)), world.getBlockMetadata(x + 1, y - 1, z)).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y - 1, z) && + isSupportiveBlock(world, x + 1, y - 1, z)) { return true; } @@ -561,9 +577,9 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) int i; for (i = 2; i <= smallArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z)), world.getBlockMetadata(x - i, y, z)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y, z)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y - 1, z)), world.getBlockMetadata(x - i, y - 1, z)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y - 1, z)) { return true; } @@ -575,9 +591,9 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) } for (i = 2; i <= smallArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z)), world.getBlockMetadata(x + i, y, z)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y, z)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y - 1, z)), world.getBlockMetadata(x + i, y - 1, z)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y - 1, z)) { return true; } @@ -589,9 +605,11 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) } } } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z - 1)), world.getBlockMetadata(x, y, z - 1)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z + 1)), world.getBlockMetadata(x, y, z + 1)).supportiveBlock) + if (isSupportiveBlock(world, x, y, z - 1) && + isSupportiveBlock(world, x, y, z + 1)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z - 1)), world.getBlockMetadata(x, y - 1, z - 1)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z + 1)), world.getBlockMetadata(x, y - 1, z + 1)).supportiveBlock) + if (isSupportiveBlock(world, x, y - 1, z - 1) && + isSupportiveBlock(world, x, y - 1, z + 1)) { return true; } @@ -600,9 +618,9 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) int i; for (i = 2; i <= smallArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z - i)), world.getBlockMetadata(x, y, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x, y, z - i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z - i)), world.getBlockMetadata(x, y - 1, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x, y - 1, z - i)) { return true; } @@ -614,9 +632,9 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) } for (i = 2; i <= smallArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z + i)), world.getBlockMetadata(x, y, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x, y, z + i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z + i)), world.getBlockMetadata(x, y - 1, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x, y - 1, z + i)) { return true; } @@ -628,9 +646,11 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) } } } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y, z + 1)), world.getBlockMetadata(x - 1, y, z + 1)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y, z - 1)), world.getBlockMetadata(x + 1, y, z - 1)).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y, z + 1) && + isSupportiveBlock(world, x + 1, y, z - 1)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y - 1, z + 1)), world.getBlockMetadata(x - 1, y - 1, z + 1)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y - 1, z - 1)), world.getBlockMetadata(x + 1, y - 1, z - 1)).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y - 1, z + 1) && + isSupportiveBlock(world, x + 1, y - 1, z - 1)) { return true; } @@ -639,9 +659,9 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) int i; for (i = 2; i <= smallArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z + i)), world.getBlockMetadata(x - i, y, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y, z + i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y - 1, z + i)), world.getBlockMetadata(x - i, y - 1, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y - 1, z + i)) { return true; } @@ -653,9 +673,9 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) } for (i = 2; i <= smallArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z - i)), world.getBlockMetadata(x + i, y, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y, z - i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y - 1, z - i)), world.getBlockMetadata(x + i, y - 1, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y - 1, z - i)) { return true; } @@ -667,9 +687,11 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) } } } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y, z + 1)), world.getBlockMetadata(x + 1, y, z + 1)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y, z - 1)), world.getBlockMetadata(x - 1, y, z - 1)).supportiveBlock) + if (isSupportiveBlock(world, x + 1, y, z + 1) && + isSupportiveBlock(world, x - 1, y, z - 1)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y - 1, z + 1)), world.getBlockMetadata(x + 1, y - 1, z + 1)).supportiveBlock && DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y - 1, z - 1)), world.getBlockMetadata(x - 1, y - 1, z - 1)).supportiveBlock) + if (isSupportiveBlock(world, x + 1, y - 1, z + 1) && + isSupportiveBlock(world, x - 1, y - 1, z - 1)) { return true; } @@ -678,9 +700,9 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) int i; for (i = 2; i <= smallArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z + i)), world.getBlockMetadata(x + i, y, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y, z + i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y - 1, z + i)), world.getBlockMetadata(x + i, y - 1, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y - 1, z + i)) { return true; } @@ -692,9 +714,9 @@ private static boolean smallArc(World world, int x, int y, int z, int smallArc) } for (i = 2; i <= smallArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z - i)), world.getBlockMetadata(x - i, y, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y, z - i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y - 1, z - i)), world.getBlockMetadata(x - i, y - 1, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y - 1, z - i)) { return true; } @@ -715,16 +737,16 @@ private static boolean bigArc(World world, int x, int y, int z, int bigArc) { return false; } - if (!DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y + 1, z)), world.getBlockMetadata(x, y + 1, z)).supportiveBlock) + if (!isSupportiveBlock(world, x, y + 1, z)) { int i; - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y + 1, z)), world.getBlockMetadata(x + 1, y + 1, z)).supportiveBlock) + if (isSupportiveBlock(world, x + 1, y + 1, z)) { for (i = 1; i <= bigArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z)), world.getBlockMetadata(x - i, y, z)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y, z)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y - 1, z)), world.getBlockMetadata(x - i, y - 1, z)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y - 1, z)) { return true; } @@ -735,13 +757,13 @@ private static boolean bigArc(World world, int x, int y, int z, int bigArc) } } } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y + 1, z)), world.getBlockMetadata(x - 1, y + 1, z)).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y + 1, z)) { for (i = 1; i <= bigArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z)), world.getBlockMetadata(x + i, y, z)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y, z)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y - 1, z)), world.getBlockMetadata(x + i, y - 1, z)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y - 1, z)) { return true; } @@ -752,13 +774,13 @@ private static boolean bigArc(World world, int x, int y, int z, int bigArc) } } } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y + 1, z + 1)), world.getBlockMetadata(x, y + 1, z + 1)).supportiveBlock) + if (isSupportiveBlock(world, x, y + 1, z + 1)) { for (i = 1; i <= bigArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z - i)), world.getBlockMetadata(x, y, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x, y, z - i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z - i)), world.getBlockMetadata(x, y - 1, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x, y - 1, z - i)) { return true; } @@ -769,13 +791,13 @@ private static boolean bigArc(World world, int x, int y, int z, int bigArc) } } } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y + 1, z - 1)), world.getBlockMetadata(x, y + 1, z - 1)).supportiveBlock) + if (isSupportiveBlock(world, x, y + 1, z - 1)) { for (i = 1; i <= bigArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y, z + i)), world.getBlockMetadata(x, y, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x, y, z + i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z + i)), world.getBlockMetadata(x, y - 1, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x, y - 1, z + i)) { return true; } @@ -786,13 +808,13 @@ private static boolean bigArc(World world, int x, int y, int z, int bigArc) } } } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y + 1, z + 1)), world.getBlockMetadata(x + 1, y + 1, z + 1)).supportiveBlock) + if (isSupportiveBlock(world, x + 1, y + 1, z + 1)) { for (i = 1; i <= bigArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z - i)), world.getBlockMetadata(x - i, y, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y, z - i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y - 1, z - i)), world.getBlockMetadata(x - i, y - 1, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y - 1, z - i)) { return true; } @@ -803,13 +825,13 @@ private static boolean bigArc(World world, int x, int y, int z, int bigArc) } } } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y + 1, z - 1)), world.getBlockMetadata(x - 1, y + 1, z - 1)).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y + 1, z - 1)) { for (i = 1; i <= bigArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z + i)), world.getBlockMetadata(x + i, y, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y, z + i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y - 1, z + i)), world.getBlockMetadata(x + i, y - 1, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y - 1, z + i)) { return true; } @@ -820,13 +842,13 @@ private static boolean bigArc(World world, int x, int y, int z, int bigArc) } } } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y + 1, z - 1)), world.getBlockMetadata(x + 1, y + 1, z - 1)).supportiveBlock) + if (isSupportiveBlock(world, x + 1, y + 1, z - 1)) { for (i = 1; i <= bigArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z + i)), world.getBlockMetadata(x - i, y, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y, z + i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - i, y - 1, z + i)), world.getBlockMetadata(x - i, y - 1, z + i)).supportiveBlock) + if (isSupportiveBlock(world, x - i, y - 1, z + i)) { return true; } @@ -837,13 +859,13 @@ private static boolean bigArc(World world, int x, int y, int z, int bigArc) } } } - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y + 1, z + 1)), world.getBlockMetadata(x - 1, y + 1, z + 1)).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y + 1, z + 1)) { for (i = 1; i <= bigArc; i++) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z - i)), world.getBlockMetadata(x + i, y, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y, z - i)) { - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(world.getBlock(x + i, y - 1, z - i)), world.getBlockMetadata(x + i, y - 1, z - i)).supportiveBlock) + if (isSupportiveBlock(world, x + i, y - 1, z - i)) { return true; } @@ -860,35 +882,35 @@ private static boolean bigArc(World world, int x, int y, int z, int bigArc) private static boolean branch(World world, int x, int y, int z, String blockName, int meta) { - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y - 1, z)), world.getBlockMetadata(x + 1, y - 1, z), blockName, meta)) + if (sameBlock(world, x + 1, y - 1, z, blockName, meta)) { return true; } - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y - 1, z)), world.getBlockMetadata(x - 1, y - 1, z), blockName, meta)) + if (sameBlock(world, x - 1, y - 1, z, blockName, meta)) { return true; } - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z + 1)), world.getBlockMetadata(x, y - 1, z + 1), blockName, meta)) + if (sameBlock(world, x, y - 1, z + 1, blockName, meta)) { return true; } - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z - 1)), world.getBlockMetadata(x, y - 1, z - 1), blockName, meta)) + if (sameBlock(world, x, y - 1, z - 1, blockName, meta)) { return true; } - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y - 1, z + 1)), world.getBlockMetadata(x + 1, y - 1, z + 1), blockName, meta)) + if (sameBlock(world, x + 1, y - 1, z + 1, blockName, meta)) { return true; } - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y - 1, z - 1)), world.getBlockMetadata(x - 1, y - 1, z - 1), blockName, meta)) + if (sameBlock(world, x - 1, y - 1, z - 1, blockName, meta)) { return true; } - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y - 1, z + 1)), world.getBlockMetadata(x - 1, y - 1, z + 1), blockName, meta)) + if (sameBlock(world, x - 1, y - 1, z + 1, blockName, meta)) { return true; } - if (sameBlock(Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y - 1, z - 1)), world.getBlockMetadata(x + 1, y - 1, z - 1), blockName, meta)) + if (sameBlock(world, x + 1, y - 1, z - 1, blockName, meta)) { return true; } @@ -902,48 +924,34 @@ private static boolean tree(World world, int x, int y, int z, int tree, String b return false; } - String blockName2; - int meta2; int i; - String blockName3; - int meta3; int i2; for (i = 1; i <= tree; i++) { - blockName2 = Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z)); - meta2 = world.getBlockMetadata(x + i, y, z); - if (DefinitionMaps.getBlockDef(blockName2, meta2).supportiveBlock) + if (isSupportiveBlock(world, x + i, y, z)) { return true; } - else if (!sameBlock(blockName, meta, blockName2, meta2)) + else if (!sameBlock(world, x + i, y, z, blockName, meta)) { break; } else { - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x + i, y + 1, z)); - meta3 = world.getBlockMetadata(x + i, y + 1, z); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x + i, y + 1, z)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x + i, y + 1, z)); - meta3 = world.getBlockMetadata(x + i, y - 1, z); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x + i, y - 1, z)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z + 1)); - meta3 = world.getBlockMetadata(x + i, y, z + 1); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x + i, y, z + 1)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x + i, y, z - 1)); - meta3 = world.getBlockMetadata(x + i, y, z - 1); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x + i, y, z - 1)) { return true; } @@ -952,39 +960,29 @@ else if (!sameBlock(blockName, meta, blockName2, meta2)) for (i = 1; i <= tree; i++) { - blockName2 = Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z)); - meta2 = world.getBlockMetadata(x - i, y, z); - if (DefinitionMaps.getBlockDef(blockName2, meta2).supportiveBlock) + if (isSupportiveBlock(world, x - i, y, z)) { return true; } - else if (!sameBlock(blockName, meta, blockName2, meta2)) + else if (!sameBlock(world, x - i, y, z, blockName, meta)) { break; } else { - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x - i, y + 1, z)); - meta3 = world.getBlockMetadata(x - i, y + 1, z); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x - i, y + 1, z)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x - i, y - 1, z)); - meta3 = world.getBlockMetadata(x - i, y - 1, z); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x - i, y - 1, z)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z + 1)); - meta3 = world.getBlockMetadata(x - i, y, z + 1); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x - i, y, z + 1)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x - i, y, z - 1)); - meta3 = world.getBlockMetadata(x - i, y, z - 1); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x - i, y, z - 1)) { return true; } @@ -993,39 +991,29 @@ else if (!sameBlock(blockName, meta, blockName2, meta2)) for (i = 1; i <= tree; i++) { - blockName2 = Block.blockRegistry.getNameForObject(world.getBlock(x, y, z + i)); - meta2 = world.getBlockMetadata(x, y, z + i); - if (DefinitionMaps.getBlockDef(blockName2, meta2).supportiveBlock) + if (isSupportiveBlock(world, x, y, z + i)) { return true; } - else if (!sameBlock(blockName, meta, blockName2, meta2)) + else if (!sameBlock(world, x, y, z + i, blockName, meta)) { break; } else { - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x, y + 1, z + i)); - meta3 = world.getBlockMetadata(x, y + 1, z + i); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x, y + 1, z + i)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z + i)); - meta3 = world.getBlockMetadata(x, y - 1, z + i); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x, y - 1, z + i)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y, z + i)); - meta3 = world.getBlockMetadata(x + 1, y, z + i); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x + 1, y, z + i)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y, z + i)); - meta3 = world.getBlockMetadata(x - 1, y, z + i); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y, z + i)) { return true; } @@ -1034,39 +1022,29 @@ else if (!sameBlock(blockName, meta, blockName2, meta2)) for (i = 1; i <= tree; i++) { - blockName2 = Block.blockRegistry.getNameForObject(world.getBlock(x, y, z - i)); - meta2 = world.getBlockMetadata(x, y, z - i); - if (DefinitionMaps.getBlockDef(blockName2, meta2).supportiveBlock) + if (isSupportiveBlock(world, x, y, z - i)) { return true; } - else if (!sameBlock(blockName, meta, blockName2, meta2)) + else if (!sameBlock(world, x, y, z - i, blockName, meta)) { break; } else { - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x, y + 1, z - i)); - meta3 = world.getBlockMetadata(x, y + 1, z - i); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x, y + 1, z - i)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x, y - 1, z - i)); - meta3 = world.getBlockMetadata(x, y - 1, z - i); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x, y - 1, z - i)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x + 1, y, z - i)); - meta3 = world.getBlockMetadata(x + 1, y, z - i); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x + 1, y, z - i)) { return true; } - blockName3 = Block.blockRegistry.getNameForObject(world.getBlock(x - 1, y, z - i)); - meta3 = world.getBlockMetadata(x - 1, y, z - i); - if (DefinitionMaps.getBlockDef(blockName3, meta3).supportiveBlock) + if (isSupportiveBlock(world, x - 1, y, z - i)) { return true; } @@ -1074,7 +1052,17 @@ else if (!sameBlock(blockName, meta, blockName2, meta2)) } return false; } - + private static boolean sameBlock(World world, int x, int y, int z, String name, int meta) + { + BlockPos blockPos = new BlockPos(x, y, z); + IBlockState blockState = world.getBlockState(blockPos); + Block block = blockState.getBlock(); + int blockMeta = block.getMetaFromState(blockState); + String blockName = Block.blockRegistry.getNameForObject(block).toString(); + + return sameBlock(blockName, blockMeta, name, meta); + } + private static boolean sameBlock(String blockName, int blockMetadata, String name, int meta) { if (blockName.equals(name)) @@ -1087,6 +1075,17 @@ private static boolean sameBlock(String blockName, int blockMetadata, String nam return blockName.equals(name) && blockMetadata == meta; } + private static boolean isSupportiveBlock(World world,int x,int y,int z) + { + BlockPos blockPos = new BlockPos(x, y, z); + IBlockState blockState = world.getBlockState(blockPos); + Block block = blockState.getBlock(); + int blockMeta = block.getMetaFromState(blockState); + String blockName = Block.blockRegistry.getNameForObject(block).toString(); + + return DefinitionMaps.getBlockDef(blockName, blockMeta).supportiveBlock; + } + private static int iunno(int i) { while (i > 3) diff --git a/blargerist/cake/blockphysics/util/EntityMove.java b/blargerist/cake/blockphysics/util/EntityMove.java index a42706a..87ab20a 100644 --- a/blargerist/cake/blockphysics/util/EntityMove.java +++ b/blargerist/cake/blockphysics/util/EntityMove.java @@ -1,34 +1,34 @@ package blargerist.cake.blockphysics.util; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import blargerist.cake.blockphysics.ModInfo; -import blargerist.cake.blockphysics.events.BPEventHandler; + import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.ITileEntityProvider; -import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityFallingBlock; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.launchwrapper.Launch; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; +import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; import net.minecraft.util.MathHelper; import net.minecraft.util.ReportedException; +import blargerist.cake.blockphysics.ModInfo; +import blargerist.cake.blockphysics.events.BPEventHandler; public class EntityMove { public static void onUpdate(EntityFallingBlock entity) { - if (entity.func_145805_f().getMaterial() == Material.air) + if (entity.getBlock().getBlock().getMaterial() == net.minecraft.block.material.Material.air) { entity.setDead(); } @@ -37,7 +37,7 @@ public static void onUpdate(EntityFallingBlock entity) entity.prevPosX = entity.posX; entity.prevPosY = entity.posY; entity.prevPosZ = entity.posZ; - ++entity.field_145812_b; + ++entity.fallTime; entity.motionY -= 0.03999999910593033D; entity.moveEntity(entity.motionX, entity.motionY, entity.motionZ); entity.motionX *= 0.9800000190734863D; @@ -49,49 +49,69 @@ public static void onUpdate(EntityFallingBlock entity) int i = MathHelper.floor_double(entity.posX); int j = MathHelper.floor_double(entity.posY); int k = MathHelper.floor_double(entity.posZ); + BlockPos blockPos = new BlockPos(i,j,k); - if (entity.field_145812_b == 1) + if (entity.fallTime == 1) { - if (entity.worldObj.getBlock(i, j, k) != entity.func_145805_f()) + if (entity.worldObj.getBlockState(blockPos) != entity.getBlock()) { entity.setDead(); return; } - entity.worldObj.setBlockToAir(i, j, k); + entity.worldObj.setBlockToAir(blockPos); } - else if (entity.field_145812_b == 4) + else if (entity.fallTime == 4) { entity.noClip = false; } - - if (BlockMove.canMoveTo(entity.worldObj, i, j - 1, k, DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(entity.func_145805_f()), entity.field_145814_a).mass) == 2) + String blockName = Block.blockRegistry.getNameForObject(entity.getBlock().getBlock()).toString(); + int blockMeta = entity.getBlock().getBlock().getMetaFromState(entity.getBlock()); + BlockDef blockDef = DefinitionMaps.getBlockDef(blockName, blockMeta); + if (BlockMove.canMoveTo(entity.worldObj, + i, + j - 1, + k, + blockDef.mass) == 2) { - entity.worldObj.setBlockToAir(i, j - 1, k); + entity.worldObj.setBlockToAir(blockPos.down()); } if (entity.onGround) { if (entity.motionX < 0.0025 && entity.motionX > -0.0025 && entity.motionZ < 0.0025 && entity.motionZ > -0.0025) { + boolean developmentEnvironment = (Boolean)Launch.blackboard.get("fml.deobfuscatedEnvironment"); if (entity.posX > Math.round(entity.posX)) { - ModInfo.Log.info("Entity posX > " + entity.posX); + if (developmentEnvironment) + { + ModInfo.Log.info("Entity posX > " + entity.posX); + } entity.motionX = 0.07; } else if (entity.posX < Math.round(entity.posX)) { - ModInfo.Log.info("Entity posX < " + entity.posX); + if (developmentEnvironment) + { + ModInfo.Log.info("Entity posX < " + entity.posX); + } entity.motionX = -0.07; } if (entity.posZ > Math.round(entity.posZ)) { - ModInfo.Log.info("Entity posZ > " + entity.posZ); + if (developmentEnvironment) + { + ModInfo.Log.info("Entity posZ > " + entity.posZ); + } entity.motionZ = 0.07; } else if (entity.posZ < Math.round(entity.posZ)) { - ModInfo.Log.info("Entity posZ < " + entity.posZ); + if (developmentEnvironment) + { + ModInfo.Log.info("Entity posZ < " + entity.posZ); + } entity.motionZ = -0.07; } } @@ -99,32 +119,44 @@ else if (entity.posZ < Math.round(entity.posZ)) entity.motionZ *= 0.899999988079071D; entity.motionY *= -0.5D; - if (entity.worldObj.getBlock(i, j, k) != Blocks.piston_extension) + blockPos = new BlockPos(i,j,k); + if (entity.worldObj.getBlockState(blockPos).getBlock() != net.minecraft.init.Blocks.piston_extension) { - if (entity.worldObj.canPlaceEntityOnSide(entity.func_145805_f(), i, j, k, true, 1, (Entity)null, (ItemStack)null) && !BlockFalling.func_149831_e(entity.worldObj, i, j - 1, k) && entity.worldObj.setBlock(i, j, k, entity.func_145805_f(), entity.field_145814_a, 3)) + if (entity.worldObj.canBlockBePlaced( + entity.getBlock().getBlock(), + blockPos, + true, + EnumFacing.DOWN, + (Entity)null, + (ItemStack)null) && + !BlockFalling.canFallInto(entity.worldObj, new BlockPos(i, j - 1, k)) && + entity.worldObj.setBlockState(blockPos, entity.getBlock(), 3)) { entity.setDead(); - if (entity.func_145805_f() instanceof BlockFalling) + if (entity.getBlock() instanceof BlockFalling) { - ((BlockFalling)entity.func_145805_f()).func_149828_a(entity.worldObj, i, j, k, entity.field_145814_a); + ((BlockFalling)entity.getBlock()).onNeighborBlockChange(entity.worldObj, + blockPos, + entity.worldObj.getBlockState(blockPos), + entity.worldObj.getBlockState(blockPos).getBlock()); } - if (entity.field_145810_d != null && entity.func_145805_f() instanceof ITileEntityProvider) + if (entity.tileEntityData != null && entity.getBlock().getBlock() instanceof ITileEntityProvider) { - TileEntity tileentity = entity.worldObj.getTileEntity(i, j, k); + TileEntity tileentity = entity.worldObj.getTileEntity(blockPos); if (tileentity != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); tileentity.writeToNBT(nbttagcompound); - Iterator iterator = entity.field_145810_d.func_150296_c().iterator(); + Iterator iterator = entity.tileEntityData.getKeySet().iterator(); while (iterator.hasNext()) { String s = (String)iterator.next(); - NBTBase nbtbase = entity.field_145810_d.getTag(s); + NBTBase nbtbase = entity.tileEntityData.getTag(s); if (!s.equals("x") && !s.equals("y") && !s.equals("z")) { @@ -137,18 +169,24 @@ else if (entity.posZ < Math.round(entity.posZ)) } } } - else if (entity.field_145813_c && (entity.field_145812_b > 600 || (entity.field_145812_b > 200 && entity.onGround))) + else if (entity.shouldDropItem && (entity.fallTime > 600 || (entity.fallTime > 200 && entity.onGround))) { entity.setDead(); - entity.entityDropItem(new ItemStack(entity.func_145805_f(), 1, entity.func_145805_f().damageDropped(entity.field_145814_a)), 0.0F); + entity.entityDropItem(new ItemStack(entity.getBlock().getBlock(), + 1, + entity.getBlock().getBlock().damageDropped(entity.getBlock())), + 0.0F); } } } - else if (entity.field_145812_b > 100 && !entity.worldObj.isRemote && (j < 1 || j > 256)) + else if (entity.fallTime > 100 && !entity.worldObj.isRemote && (j < 1 || j > 256)) { - if (entity.field_145813_c) + if (entity.shouldDropItem) { - entity.entityDropItem(new ItemStack(entity.func_145805_f(), 1, entity.func_145805_f().damageDropped(entity.field_145814_a)), 0.0F); + entity.entityDropItem(new ItemStack(entity.getBlock().getBlock(), + 1, + entity.getBlock().getBlock().damageDropped(entity.getBlock())), + 0.0F); } entity.setDead(); @@ -161,15 +199,15 @@ public void moveEntity(EntityFallingBlock entity, double p_70091_1_, double p_70 { if (entity.noClip) { - entity.boundingBox.offset(p_70091_1_, p_70091_3_, p_70091_5_); - entity.posX = (entity.boundingBox.minX + entity.boundingBox.maxX) / 2.0D; - entity.posY = entity.boundingBox.minY + (double)entity.yOffset - (double)entity.ySize; - entity.posZ = (entity.boundingBox.minZ + entity.boundingBox.maxZ) / 2.0D; + entity.getBoundingBox().offset(p_70091_1_, p_70091_3_, p_70091_5_); + entity.posX = (entity.getBoundingBox().minX + entity.getBoundingBox().maxX) / 2.0D; + entity.posY = entity.getBoundingBox().minY + (double)entity.getYOffset() - (double)entity.height; + entity.posZ = (entity.getBoundingBox().minZ + entity.getBoundingBox().maxZ) / 2.0D; } else { entity.worldObj.theProfiler.startSection("move"); - entity.ySize *= 0.4F; + entity.height *= 0.4F; double d3 = entity.posX; double d4 = entity.posY; double d5 = entity.posZ; @@ -177,18 +215,18 @@ public void moveEntity(EntityFallingBlock entity, double p_70091_1_, double p_70 double d6 = p_70091_1_; double d7 = p_70091_3_; double d8 = p_70091_5_; - AxisAlignedBB axisalignedbb = entity.boundingBox.copy(); + AxisAlignedBB axisalignedbb = entity.getBoundingBox(); - List list = entity.worldObj.getCollidingBoundingBoxes(entity, entity.boundingBox.addCoord(p_70091_1_, p_70091_3_, p_70091_5_)); + List list = entity.worldObj.getCollidingBoundingBoxes(entity, entity.getBoundingBox().addCoord(p_70091_1_, p_70091_3_, p_70091_5_)); for (int i = 0; i < list.size(); ++i) { - p_70091_3_ = ((AxisAlignedBB)list.get(i)).calculateYOffset(entity.boundingBox, p_70091_3_); + p_70091_3_ = ((AxisAlignedBB)list.get(i)).calculateYOffset(entity.getBoundingBox(), p_70091_3_); } - entity.boundingBox.offset(0.0D, p_70091_3_, 0.0D); + entity.getBoundingBox().offset(0.0D, p_70091_3_, 0.0D); - if (!entity.field_70135_K && d7 != p_70091_3_) + if (d7 != p_70091_3_) { p_70091_5_ = 0.0D; p_70091_3_ = 0.0D; @@ -200,12 +238,12 @@ public void moveEntity(EntityFallingBlock entity, double p_70091_1_, double p_70 for (j = 0; j < list.size(); ++j) { - p_70091_1_ = ((AxisAlignedBB)list.get(j)).calculateXOffset(entity.boundingBox, p_70091_1_); + p_70091_1_ = ((AxisAlignedBB)list.get(j)).calculateXOffset(entity.getBoundingBox(), p_70091_1_); } - entity.boundingBox.offset(p_70091_1_, 0.0D, 0.0D); + entity.getBoundingBox().offset(p_70091_1_, 0.0D, 0.0D); - if (!entity.field_70135_K && d6 != p_70091_1_) + if ( d6 != p_70091_1_) { p_70091_5_ = 0.0D; p_70091_3_ = 0.0D; @@ -214,12 +252,12 @@ public void moveEntity(EntityFallingBlock entity, double p_70091_1_, double p_70 for (j = 0; j < list.size(); ++j) { - p_70091_5_ = ((AxisAlignedBB)list.get(j)).calculateZOffset(entity.boundingBox, p_70091_5_); + p_70091_5_ = ((AxisAlignedBB)list.get(j)).calculateZOffset(entity.getBoundingBox(), p_70091_5_); } - entity.boundingBox.offset(0.0D, 0.0D, p_70091_5_); + entity.getBoundingBox().offset(0.0D, 0.0D, p_70091_5_); - if (!entity.field_70135_K && d8 != p_70091_5_) + if ( d8 != p_70091_5_) { p_70091_5_ = 0.0D; p_70091_3_ = 0.0D; @@ -231,7 +269,7 @@ public void moveEntity(EntityFallingBlock entity, double p_70091_1_, double p_70 int k; double d12; - if (entity.stepHeight > 0.0F && flag1 && entity.ySize < 0.05F && (d6 != p_70091_1_ || d8 != p_70091_5_)) + if (entity.stepHeight > 0.0F && flag1 && entity.height < 0.05F && (d6 != p_70091_1_ || d8 != p_70091_5_)) { d12 = p_70091_1_; d10 = p_70091_3_; @@ -239,18 +277,25 @@ public void moveEntity(EntityFallingBlock entity, double p_70091_1_, double p_70 p_70091_1_ = d6; p_70091_3_ = (double)entity.stepHeight; p_70091_5_ = d8; - AxisAlignedBB axisalignedbb1 = entity.boundingBox.copy(); - entity.boundingBox.setBB(axisalignedbb); - list = entity.worldObj.getCollidingBoundingBoxes(entity, entity.boundingBox.addCoord(d6, p_70091_3_, d8)); + AxisAlignedBB axisalignedbb1 = entity.getBoundingBox(); + entity.getBlock().getBlock().setBlockBounds( + (float)axisalignedbb.minX, + (float)axisalignedbb.minY, + (float)axisalignedbb.minZ, + (float)axisalignedbb.maxX, + (float)axisalignedbb.maxY, + (float)axisalignedbb.maxZ); + + list = entity.worldObj.getCollidingBoundingBoxes(entity, entity.getBoundingBox().addCoord(d6, p_70091_3_, d8)); for (k = 0; k < list.size(); ++k) { - p_70091_3_ = ((AxisAlignedBB)list.get(k)).calculateYOffset(entity.boundingBox, p_70091_3_); + p_70091_3_ = ((AxisAlignedBB)list.get(k)).calculateYOffset(entity.getBoundingBox(), p_70091_3_); } - entity.boundingBox.offset(0.0D, p_70091_3_, 0.0D); + entity.getBoundingBox().offset(0.0D, p_70091_3_, 0.0D); - if (!entity.field_70135_K && d7 != p_70091_3_) + if ( d7 != p_70091_3_) { p_70091_5_ = 0.0D; p_70091_3_ = 0.0D; @@ -259,12 +304,12 @@ public void moveEntity(EntityFallingBlock entity, double p_70091_1_, double p_70 for (k = 0; k < list.size(); ++k) { - p_70091_1_ = ((AxisAlignedBB)list.get(k)).calculateXOffset(entity.boundingBox, p_70091_1_); + p_70091_1_ = ((AxisAlignedBB)list.get(k)).calculateXOffset(entity.getBoundingBox(), p_70091_1_); } - entity.boundingBox.offset(p_70091_1_, 0.0D, 0.0D); + entity.getBoundingBox().offset(p_70091_1_, 0.0D, 0.0D); - if (!entity.field_70135_K && d6 != p_70091_1_) + if ( d6 != p_70091_1_) { p_70091_5_ = 0.0D; p_70091_3_ = 0.0D; @@ -273,19 +318,19 @@ public void moveEntity(EntityFallingBlock entity, double p_70091_1_, double p_70 for (k = 0; k < list.size(); ++k) { - p_70091_5_ = ((AxisAlignedBB)list.get(k)).calculateZOffset(entity.boundingBox, p_70091_5_); + p_70091_5_ = ((AxisAlignedBB)list.get(k)).calculateZOffset(entity.getBoundingBox(), p_70091_5_); } - entity.boundingBox.offset(0.0D, 0.0D, p_70091_5_); + entity.getBoundingBox().offset(0.0D, 0.0D, p_70091_5_); - if (!entity.field_70135_K && d8 != p_70091_5_) + if ( d8 != p_70091_5_) { p_70091_5_ = 0.0D; p_70091_3_ = 0.0D; p_70091_1_ = 0.0D; } - if (!entity.field_70135_K && d7 != p_70091_3_) + if ( d7 != p_70091_3_) { p_70091_5_ = 0.0D; p_70091_3_ = 0.0D; @@ -297,10 +342,10 @@ public void moveEntity(EntityFallingBlock entity, double p_70091_1_, double p_70 for (k = 0; k < list.size(); ++k) { - p_70091_3_ = ((AxisAlignedBB)list.get(k)).calculateYOffset(entity.boundingBox, p_70091_3_); + p_70091_3_ = ((AxisAlignedBB)list.get(k)).calculateYOffset(entity.getBoundingBox(), p_70091_3_); } - entity.boundingBox.offset(0.0D, p_70091_3_, 0.0D); + entity.getBoundingBox().offset(0.0D, p_70091_3_, 0.0D); } if (d12 * d12 + d11 * d11 >= p_70091_1_ * p_70091_1_ + p_70091_5_ * p_70091_5_) @@ -308,15 +353,21 @@ public void moveEntity(EntityFallingBlock entity, double p_70091_1_, double p_70 p_70091_1_ = d12; p_70091_3_ = d10; p_70091_5_ = d11; - entity.boundingBox.setBB(axisalignedbb1); + entity.getBlock().getBlock().setBlockBounds( + (float)axisalignedbb1.minX, + (float)axisalignedbb1.minY, + (float)axisalignedbb1.minZ, + (float)axisalignedbb1.maxX, + (float)axisalignedbb1.maxY, + (float)axisalignedbb1.maxZ); } } entity.worldObj.theProfiler.endSection(); entity.worldObj.theProfiler.startSection("rest"); - entity.posX = (entity.boundingBox.minX + entity.boundingBox.maxX) / 2.0D; - entity.posY = entity.boundingBox.minY + (double)entity.yOffset - (double)entity.ySize; - entity.posZ = (entity.boundingBox.minZ + entity.boundingBox.maxZ) / 2.0D; + entity.posX = (entity.getBoundingBox().minX + entity.getBoundingBox().maxX) / 2.0D; + entity.posY = entity.getBoundingBox().minY + (double)entity.getYOffset() - (double)entity.height; + entity.posZ = (entity.getBoundingBox().minZ + entity.getBoundingBox().maxZ) / 2.0D; entity.isCollidedHorizontally = d6 != p_70091_1_ || d8 != p_70091_5_; entity.isCollidedVertically = d7 != p_70091_3_; entity.onGround = d7 != p_70091_3_ && d7 < 0.0D; @@ -375,14 +426,35 @@ else if (p_70064_1_ < 0.0D) public static void checkEntityBlockCollisions(Entity entity) { - int i = MathHelper.floor_double(entity.boundingBox.minX + 0.001D); - int j = MathHelper.floor_double(entity.boundingBox.minY + 0.001D); - int k = MathHelper.floor_double(entity.boundingBox.minZ + 0.001D); - int l = MathHelper.floor_double(entity.boundingBox.maxX - 0.001D); - int i1 = MathHelper.floor_double(entity.boundingBox.maxY - 0.001D); - int j1 = MathHelper.floor_double(entity.boundingBox.maxZ - 0.001D); - - if (entity.worldObj.checkChunksExist(i, j, k, l, i1, j1)) + if (entity.getBoundingBox() == null) + { + return; + } + int i = MathHelper.floor_double(entity.getBoundingBox().minX + 0.001D); + int j = MathHelper.floor_double(entity.getBoundingBox().minY + 0.001D); + int k = MathHelper.floor_double(entity.getBoundingBox().minZ + 0.001D); + int l = MathHelper.floor_double(entity.getBoundingBox().maxX - 0.001D); + int i1 = MathHelper.floor_double(entity.getBoundingBox().maxY - 0.001D); + int j1 = MathHelper.floor_double(entity.getBoundingBox().maxZ - 0.001D); + + byte b0 = 32; + boolean chunksExist = true; + for (int iIncrement = i; iIncrement <= l; iIncrement++) + { + for (int jIncrement = j; jIncrement <= i1; jIncrement++) + { + if (!entity.worldObj.getChunkProvider().chunkExists(i + iIncrement, j + jIncrement)) + { + chunksExist = false; + break; + } + } + if (!chunksExist) + { + break; + } + } + if (chunksExist) { for (int k1 = i; k1 <= l; ++k1) { @@ -390,26 +462,28 @@ public static void checkEntityBlockCollisions(Entity entity) { for (int i2 = k; i2 <= j1; ++i2) { - Block block = entity.worldObj.getBlock(k1, l1, i2); + BlockPos blockPos = new BlockPos(k1, l1, i2); + IBlockState blockState = entity.worldObj.getBlockState(blockPos); + Block block = blockState.getBlock(); - int meta = entity.worldObj.getBlockMetadata(k1, l1, i2); - String blockName = Block.blockRegistry.getNameForObject(block); - if (DefinitionMaps.getBlockDef(Block.blockRegistry.getNameForObject(block), entity.worldObj.getBlockMetadata(k1, l1, i2)).fragile > 0) + int meta = block.getMetaFromState(blockState); + String blockName = Block.blockRegistry.getNameForObject(block).toString(); + if (DefinitionMaps.getBlockDef(blockName, meta).fragile > 0) { ModInfo.Log.info("Block Fragile: " + blockName); - BPEventHandler.onFragileBlockCollision(entity, k1, l1, i2); + BPEventHandler.onFragileBlockCollision(entity, k1, l1, i2); } else { try { - block.onEntityCollidedWithBlock(entity.worldObj, k1, l1, i2, entity); + block.onEntityCollidedWithBlock(entity.worldObj, blockPos, entity); } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Colliding entity with block"); + CrashReport crashreport = CrashReport.makeCrashReport(throwable , "Colliding entity with block"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being collided with"); - CrashReportCategory.func_147153_a(crashreportcategory, k1, l1, i2, block, entity.worldObj.getBlockMetadata(k1, l1, i2)); + CrashReportCategory.addBlockInfo(crashreportcategory, blockPos, block, meta); throw new ReportedException(crashreport); } } diff --git a/build.gradle b/build.gradle index 52a74a6..37e9f3e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,73 +1,99 @@ buildscript { - repositories { - mavenCentral() - maven { - name = "forge" - url = "http://files.minecraftforge.net/maven" - } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" - } - } - dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' - } + repositories { + mavenCentral() + maven { + name = "forge" + url = "http://files.minecraftforge.net/maven" + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } + } + dependencies { + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + } } apply plugin: 'forge' +version = "1.8-0.932b" +group = project.projectDir.name.toLowerCase() +archivesBaseName = "BlockPhysics" minecraft { - version = "1.7.10-10.13.2.1230" + version = "1.8-11.14.1.1337" + runDir = "eclipse" + + // the mappings can be changed at any time, and must be in the following format. + // snapshot_YYYYMMDD snapshot are built nightly. + // stable_# stables are built at the discretion of the MCP team. + // Use non-default mappings at your own risk. they may not allways work. + // simply re-run your setup task after changing the mappings to update your workspace. + mappings = "snapshot_20141130" } -group = project.projectDir.name.toLowerCase() -archivesBaseName = "BlockPhysics-mc" + project.minecraft.version +dependencies { + // you may put jars on which you depend on in ./libs + // or you may define them like so.. + //compile "some.group:artifact:version:classifier" + //compile "some.group:artifact:version" + compile group: 'junit', name: 'junit', version: '4.11' + + // real examples + //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env + //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env + + // for more info... + // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html + // http://www.gradle.org/docs/current/userguide/dependency_management.html +} sourceSets.main{ - java { - srcDirs 'java', 'apis', 'ASMHelper/java' - } - resources { - srcDirs 'resources' - } + java { + srcDirs 'java', 'apis', 'ASMHelper/java' + } + resources { + srcDirs 'resources' + } } dependencies { - compile fileTree(dir: 'libs', include: '*.jar,*.zip') + compile fileTree(dir: 'libs', include: '*.jar,*.zip') } jar { - manifest { - attributes 'FMLCorePlugin': 'blargerist.cake.blockphysics.asm.ASMPlugin' - attributes 'FMLCorePluginContainsFMLMod': 'true' - } + manifest { + attributes 'FMLCorePlugin': 'blargerist.cake.blockphysics.asm.ASMPlugin' + attributes 'FMLCorePluginContainsFMLMod': 'true' + } } + // variable substitution in java files task processSourceMainJava(type:Copy) { - inputs.property "vars", project.version + project.minecraft.version - from('java') - { - include '**/ModInfo.java' - include '**/package-info.java' - expand 'version':project.version, 'mcversion':project.minecraft.version - } - into project.buildDir.getPath()+"/sources/java" + inputs.property "vars", project.version + project.minecraft.version + from('java') + { + include '**/ModInfo.java' + include '**/package-info.java' + expand 'version':project.version, 'mcversion':project.minecraft.version + } + into project.buildDir.getPath()+"/sources/java" } // correct task ordering afterEvaluate { project -> - sourceMainJava.finalizedBy(processSourceMainJava) + sourceMainJava.finalizedBy(processSourceMainJava) } processResources { - inputs.property "vars", project.version + project.minecraft.version - from(sourceSets.main.resources.srcDirs) { - include '**/*.info' - expand 'version':project.version, 'mcversion':project.minecraft.version - } - from(sourceSets.main.resources.srcDirs) { - exclude '**/*.info' - } + inputs.property "vars", project.version + project.minecraft.version + from(sourceSets.main.resources.srcDirs) { + include '**/*.info' + expand 'version':project.version, 'mcversion':project.minecraft.version + } + + from(sourceSets.main.resources.srcDirs) { + exclude '**/*.info' + } } \ No newline at end of file diff --git a/mcmod.info b/mcmod.info index 3ab7c1f..c7713af 100644 --- a/mcmod.info +++ b/mcmod.info @@ -3,11 +3,11 @@ "modid": "BlockPhysics", "name": "BlockPhysics", "description": "Adds physics to blocks. Originally by id_miner.", - "version": "0.931b", - "mcversion": "${mcversion}", + "version": "0.932b", + "mcversion": "1.8", "url": "", "updateUrl": "", - "authorList": ["Blargerist"], + "authorList": ["Blargerist","Bigwave"], "credits": "Originally by id_miner. All the props to him!", "logoFile": "", "screenshots": [],