diff --git a/build.gradle b/build.gradle index 494aaa8e7..4d877827c 100644 --- a/build.gradle +++ b/build.gradle @@ -4,13 +4,16 @@ import groovy.json.JsonSlurper buildscript { repositories { maven { url = 'https://files.minecraftforge.net/maven' } + maven { url = 'https://repo.spongepowered.org/maven' } mavenCentral() } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true + classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' } } apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'org.spongepowered.mixin' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. version = project.property('mod.version') + "-" + project.property('minecraft.version') @@ -19,6 +22,10 @@ archivesBaseName = "furniture" sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' +mixin { + add sourceSets.main, "cfm.refmap.json" +} + // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } @@ -30,6 +37,7 @@ minecraft { workingDirectory project.file('run') property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' property 'forge.logging.console.level', 'debug' + arg '-mixin.config=cfm.mixins.json' mods { cfm { source sourceSets.main @@ -41,6 +49,7 @@ minecraft { workingDirectory project.file('run') property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' property 'forge.logging.console.level', 'debug' + arg '-mixin.config=cfm.mixins.json' mods { cfm { source sourceSets.main @@ -92,7 +101,8 @@ jar { "Implementation-Title" : project.name, "Implementation-Version" : "${version}", "Implementation-Vendor" : project.property('mod.author'), - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), + "MixinConfigs": "cfm.mixins.json" ]) } } diff --git a/src/main/java/com/mrcrayfish/furniture/mixin/client/BlockMixin.java b/src/main/java/com/mrcrayfish/furniture/mixin/client/BlockMixin.java new file mode 100644 index 000000000..a1137e0a1 --- /dev/null +++ b/src/main/java/com/mrcrayfish/furniture/mixin/client/BlockMixin.java @@ -0,0 +1,29 @@ +package com.mrcrayfish.furniture.mixin.client; + +import com.mrcrayfish.furniture.block.BlindsBlock; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +/** + * Author: MrCrayfish + */ +@Mixin(Block.class) +public class BlockMixin +{ + @Inject(method = "shouldSideBeRendered", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/math/shapes/VoxelShapes;compare(Lnet/minecraft/util/math/shapes/VoxelShape;Lnet/minecraft/util/math/shapes/VoxelShape;Lnet/minecraft/util/math/shapes/IBooleanFunction;)Z"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) + private static void shouldRenderSideWithBlinds(BlockState blockState, IBlockReader blockAccess, BlockPos pos, Direction dir, CallbackInfoReturnable cir, BlockPos offsetPos, BlockState offsetState) + { + if(offsetState.getBlock() instanceof BlindsBlock) + { + cir.setReturnValue(true); + } + } +} diff --git a/src/main/resources/cfm.mixins.json b/src/main/resources/cfm.mixins.json new file mode 100644 index 000000000..40efc1666 --- /dev/null +++ b/src/main/resources/cfm.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "package": "com.mrcrayfish.furniture.mixin", + "compatibilityLevel": "JAVA_8", + "minVersion": "0.8", + "refmap": "cfm.refmap.json", + "client": [ + "client.BlockMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file