-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Piston Block Blacklist tweak
- Loading branch information
Showing
8 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/mod/acgaming/universaltweaks/tweaks/blocks/piston/UTPistonBlockBlacklist.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package mod.acgaming.universaltweaks.tweaks.blocks.piston; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.util.ResourceLocation; | ||
import net.minecraftforge.fml.common.registry.ForgeRegistries; | ||
|
||
import mod.acgaming.universaltweaks.UniversalTweaks; | ||
import mod.acgaming.universaltweaks.config.UTConfigTweaks; | ||
|
||
public class UTPistonBlockBlacklist | ||
{ | ||
public static final List<Block> BLOCK_BLACKLIST = new ArrayList<>(); | ||
|
||
public static void initBlockBlacklist() | ||
{ | ||
BLOCK_BLACKLIST.clear(); | ||
try | ||
{ | ||
for (String string : UTConfigTweaks.BLOCKS.PISTON.utPistonBlockBlacklist) | ||
{ | ||
ResourceLocation resLoc = new ResourceLocation(string); | ||
if (ForgeRegistries.BLOCKS.containsKey(resLoc)) BLOCK_BLACKLIST.add(ForgeRegistries.BLOCKS.getValue(resLoc)); | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
UniversalTweaks.LOGGER.info("Piston block blacklist initialized"); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
.../mod/acgaming/universaltweaks/tweaks/blocks/piston/mixin/UTPistonBlockBlacklistMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package mod.acgaming.universaltweaks.tweaks.blocks.piston.mixin; | ||
|
||
import net.minecraft.block.BlockPistonBase; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
import mod.acgaming.universaltweaks.UniversalTweaks; | ||
import mod.acgaming.universaltweaks.config.UTConfigGeneral; | ||
import mod.acgaming.universaltweaks.tweaks.blocks.piston.UTPistonBlockBlacklist; | ||
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; | ||
|
||
@Mixin(BlockPistonBase.class) | ||
public abstract class UTPistonBlockBlacklistMixin | ||
{ | ||
@Inject(method = "canPush", at = @At("HEAD"), cancellable = true) | ||
private static void utPistonCanPush(IBlockState blockState, World world, BlockPos pos, EnumFacing facing, boolean destroyBlocks, EnumFacing enumFacing, CallbackInfoReturnable<Boolean> cir) | ||
{ | ||
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTPistonBlockBlacklist ::: Can push block check"); | ||
if (UTPistonBlockBlacklist.BLOCK_BLACKLIST.contains(blockState.getBlock())) cir.setReturnValue(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"package": "mod.acgaming.universaltweaks.tweaks.blocks.piston.mixin", | ||
"refmap": "universaltweaks.refmap.json", | ||
"minVersion": "0.8", | ||
"compatibilityLevel": "JAVA_8", | ||
"mixins": ["UTPistonBlockBlacklistMixin"] | ||
} |