From d510978446eb2de18ec71c9a617a1488550bacb2 Mon Sep 17 00:00:00 2001 From: tterrag Date: Tue, 24 Sep 2019 20:47:11 -0400 Subject: [PATCH] Add constructor to StairsBlock that accepts a state supplier --- .../minecraft/block/StairsBlock.java.patch | 40 +++++++++++++++++++ .../META-INF/fieldtomethodtransformers.js | 14 +++++++ 2 files changed, 54 insertions(+) create mode 100644 patches/minecraft/net/minecraft/block/StairsBlock.java.patch diff --git a/patches/minecraft/net/minecraft/block/StairsBlock.java.patch b/patches/minecraft/net/minecraft/block/StairsBlock.java.patch new file mode 100644 index 000000000..205efcfcb --- /dev/null +++ b/patches/minecraft/net/minecraft/block/StairsBlock.java.patch @@ -0,0 +1,40 @@ +--- a/net/minecraft/block/StairsBlock.java ++++ b/net/minecraft/block/StairsBlock.java +@@ -83,13 +83,24 @@ + return voxelshape; + } + ++ // Forge: Use the other constructor that takes a Supplier ++ @Deprecated + protected StairsBlock(BlockState p_i48321_1_, Block.Properties p_i48321_2_) { + super(p_i48321_2_); + this.func_180632_j(this.field_176227_L.func_177621_b().func_206870_a(field_176309_a, Direction.NORTH).func_206870_a(field_176308_b, Half.BOTTOM).func_206870_a(field_176310_M, StairsShape.STRAIGHT).func_206870_a(field_204513_t, Boolean.valueOf(false))); + this.field_150149_b = p_i48321_1_.func_177230_c(); + this.field_150151_M = p_i48321_1_; ++ this.stateSupplier = () -> p_i48321_1_; + } + ++ protected StairsBlock(java.util.function.Supplier state, Block.Properties properties) { ++ super(properties); ++ this.func_180632_j(this.field_176227_L.func_177621_b().func_206870_a(field_176309_a, Direction.NORTH).func_206870_a(field_176308_b, Half.BOTTOM).func_206870_a(field_176310_M, StairsShape.STRAIGHT).func_206870_a(field_204513_t, Boolean.valueOf(false))); ++ this.field_150149_b = Blocks.field_150350_a; // These are unused, fields are redirected ++ this.field_150151_M = Blocks.field_150350_a.func_176223_P(); ++ this.stateSupplier = state; ++ } ++ + public boolean func_220074_n(BlockState p_220074_1_) { + return true; + } +@@ -265,4 +276,12 @@ + public boolean func_196266_a(BlockState p_196266_1_, IBlockReader p_196266_2_, BlockPos p_196266_3_, PathType p_196266_4_) { + return false; + } ++ ++ private final java.util.function.Supplier stateSupplier; ++ private Block getModelBlock() { ++ return getModelState().func_177230_c(); ++ } ++ private BlockState getModelState() { ++ return stateSupplier.get(); ++ } + } diff --git a/src/main/resources/META-INF/fieldtomethodtransformers.js b/src/main/resources/META-INF/fieldtomethodtransformers.js index dfa2824a6..e928191b9 100644 --- a/src/main/resources/META-INF/fieldtomethodtransformers.js +++ b/src/main/resources/META-INF/fieldtomethodtransformers.js @@ -35,6 +35,20 @@ function initializeCoreMod() { asmapi.redirectFieldToMethod(classNode, fn, 'getFluid') // forge added method, doesn't need mapping return classNode; } + }, + 'stairsblock': { + 'target': { + 'type': 'CLASS', + 'name': 'net.minecraft.block.StairsBlock' + }, + 'transformer': function(classNode) { + var asmapi=Java.type('net.minecraftforge.coremod.api.ASMAPI') + var blockField = asmapi.mapField('field_150149_b') // modelBlock - remap to mcp if necessary + asmapi.redirectFieldToMethod(classNode, blockField, 'getModelBlock') // forge added method, doesn't need mapping + var stateField = asmapi.mapField('field_150151_M') // modelState - remap to mcp if necessary + asmapi.redirectFieldToMethod(classNode, stateField, 'getModelState') // forge added method, doesn't need mapping + return classNode; + } } } }