From 5231fc79365561dc74ba515ef0c64b99687fed7b Mon Sep 17 00:00:00 2001 From: Charles445 Date: Thu, 12 Nov 2020 16:28:52 -0600 Subject: [PATCH] Campfire Spit Blacklist/Whitelist, Bump Version Campfire Spit blacklist and whitelist support Bump to 0.3.4 --- build.gradle | 2 +- .../simpledifficulty/config/ModConfig.java | 12 +++++ .../tileentity/TileEntitySpit.java | 45 +++++++++++++------ 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 5e49487..0e72de7 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { apply plugin: 'net.minecraftforge.gradle.forge' -version = "1.12.2-0.3.3" +version = "1.12.2-0.3.4" group = "com.charles445.simpledifficulty" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "SimpleDifficulty" diff --git a/src/main/java/com/charles445/simpledifficulty/config/ModConfig.java b/src/main/java/com/charles445/simpledifficulty/config/ModConfig.java index f655081..daa15d1 100644 --- a/src/main/java/com/charles445/simpledifficulty/config/ModConfig.java +++ b/src/main/java/com/charles445/simpledifficulty/config/ModConfig.java @@ -1,6 +1,10 @@ package com.charles445.simpledifficulty.config; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + import com.charles445.simpledifficulty.SimpleDifficulty; import com.charles445.simpledifficulty.api.config.ClientConfig; import com.charles445.simpledifficulty.api.config.ClientOptions; @@ -115,6 +119,14 @@ public class ConfigMiscellaneous @Config.Name("CampfireSpitExperience") public boolean campfireSpitExperience = true; + @Config.Comment("Blacklisted items in the campfire spit (ex. minecraft:beef") + @Config.Name("CampfireSpitBlacklist") + public String[] campfireSpitBlacklist = new String[0]; + + @Config.Comment("Whether the campfire spit blacklist is a whitelist instead") + @Config.Name("CampfireSpitBlacklistIsWhitelist") + public boolean campfireSpitBlacklistIsWhitelist = false; + @Config.Comment("Whether Golden Apple Juice gives the golden apple effect") @Config.Name("GoldenAppleJuiceEffect") public boolean goldenAppleJuiceEffect = true; diff --git a/src/main/java/com/charles445/simpledifficulty/tileentity/TileEntitySpit.java b/src/main/java/com/charles445/simpledifficulty/tileentity/TileEntitySpit.java index 7908929..d47b412 100644 --- a/src/main/java/com/charles445/simpledifficulty/tileentity/TileEntitySpit.java +++ b/src/main/java/com/charles445/simpledifficulty/tileentity/TileEntitySpit.java @@ -136,24 +136,43 @@ public void handleRightClick(World world, BlockPos pos, IBlockState state, Entit //Deposit if(!withdrewToHand && isCookable(heldItemStack)) { - for(int i=0; i < items.getSlots(); i++) + //Check the blacklist + String heldItemName = heldItemStack.getItem().getRegistryName().toString(); + boolean isBlacklisted = false; + String[] spitBlacklist = ModConfig.server.miscellaneous.campfireSpitBlacklist; + for(int i = 0; i < spitBlacklist.length; i++) { - if(items.getStackInSlot(i).isEmpty()) + if(spitBlacklist[i].equals(heldItemName)) { - //Insert and break - items.insertItem(i, new ItemStack(heldItemStack.getItem(), 1, heldItemStack.getItemDamage()), false); - heldItemStack.shrink(1); - - //Reset Progress - //TODO individual slot progress? lol - progress = 0; - - if(!playedSound) - playedSound = playWorldSound(world, pos, true); - found = true; + isBlacklisted = true; break; } } + + //If it's in the blacklist, but it's a whitelist, then it's acceptable + //If it's not in the blacklist, and it's a blacklist, it's also acceptable + + if(isBlacklisted == ModConfig.server.miscellaneous.campfireSpitBlacklistIsWhitelist) + { + for(int i=0; i < items.getSlots(); i++) + { + if(items.getStackInSlot(i).isEmpty()) + { + //Insert and break + items.insertItem(i, new ItemStack(heldItemStack.getItem(), 1, heldItemStack.getItemDamage()), false); + heldItemStack.shrink(1); + + //Reset Progress + //TODO individual slot progress? lol + progress = 0; + + if(!playedSound) + playedSound = playWorldSound(world, pos, true); + found = true; + break; + } + } + } } if(!found && rawWithdraw && player.isSneaking())