Skip to content

Commit

Permalink
Drawers no longer spill items by default (toggleable in config). Pack…
Browse files Browse the repository at this point in the history
…ing tape is redundant when this option is on, but ehh...
  • Loading branch information
jaquadro committed Sep 4, 2019
1 parent 7171032 commit 0ab80d4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx3G

minecraft_base_version=1.12
minecraft_version=1.12.2
mod_version=5.3.9
mod_version=5.4.0
chameleon_version=4.1.0
chameleon_max_version=5.0.0

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/storagedrawers/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ storagedrawers.config.prop.enableFramedDrawers=Enable Framed Drawers
storagedrawers.config.prop.enableFramedDrawers.tooltip=Drawers with custom materials.
storagedrawers.config.prop.defaultQuantify=Quantity Visible by Default
storagedrawers.config.prop.defaultQuantify.tooltip=Drawers display quantity numbers when placed.
storagedrawers.config.prop.keepContentsOnBreak=Keep Contents on Break
storagedrawers.config.prop.keepContentsOnBreak.tooltip=Drawers always keep their items and upgrades when broken.

storagedrawers.config.addons=Addons
storagedrawers.config.addons.tooltip=Configure global addon pack settings.
Expand Down
17 changes: 15 additions & 2 deletions src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public boolean removedByPlayer (IBlockState state, World world, BlockPos pos, En
public void breakBlock (World world, BlockPos pos, IBlockState state) {
TileEntityDrawers tile = getTileEntity(world, pos);

if (tile != null && !tile.isSealed()) {
if (tile != null && !tile.isSealed() && !StorageDrawers.config.cache.keepContentsOnBreak) {
for (int i = 0; i < tile.upgrades().getSlotCount(); i++) {
ItemStack stack = tile.upgrades().getUpgrade(i);
if (!stack.isEmpty()) {
Expand Down Expand Up @@ -530,7 +530,20 @@ protected ItemStack getMainDrop (IBlockAccess world, BlockPos pos, IBlockState s
if (data == null)
data = new NBTTagCompound();

if (tile.isSealed()) {
boolean hasContents = false;
if (StorageDrawers.config.cache.keepContentsOnBreak) {
for (int i = 0; i < tile.getGroup().getDrawerCount(); i++) {
IDrawer drawer = tile.getGroup().getDrawer(i);
if (drawer != null && !drawer.isEmpty())
hasContents = true;
}
for (int i = 0; i < tile.upgrades().getSlotCount(); i++) {
if (!tile.upgrades().getUpgrade(i).isEmpty())
hasContents = true;
}
}

if (tile.isSealed() || (StorageDrawers.config.cache.keepContentsOnBreak && hasContents)) {
NBTTagCompound tiledata = new NBTTagCompound();
tile.writeToNBT(tiledata);
data.setTag("tile", tiledata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class ConfigCache {
public boolean stackRemainderWaila;
public boolean registerExtraCompRules;
public boolean defaultQuantify;
public boolean keepContentsOnBreak;
public String[] compRules;
public String[] oreWhitelist;
public String[] oreBlacklist;
Expand Down Expand Up @@ -157,6 +158,7 @@ public void syncConfig () {
"Writes additional log messages while using the mod. Mainly for debug purposes. Should be kept disabled unless instructed otherwise.")
.setLanguageKey(LANG_PREFIX + "prop.enableDebugLogging").getBoolean();
cache.defaultQuantify = config.get(Configuration.CATEGORY_GENERAL, "defaultQuantify", false).setLanguageKey(LANG_PREFIX + "prop.defaultQuantify").getBoolean();
cache.keepContentsOnBreak = config.get(Configuration.CATEGORY_GENERAL, "keepContentsOnBreak", true).setLanguageKey(LANG_PREFIX + "prop.keepContentsOnBreak").getBoolean();

//cache.enableAE2Integration = config.get(sectionIntegration.getQualifiedName(), "enableAE2", true).setLanguageKey(LANG_PREFIX + "integration.enableAE2").setRequiresMcRestart(true).getBoolean();
cache.enableWailaIntegration = config.get(sectionIntegration.getQualifiedName(), "enableWaila", true).setLanguageKey(LANG_PREFIX + "integration.enableWaila").setRequiresMcRestart(true).getBoolean();
Expand Down

0 comments on commit 0ab80d4

Please sign in to comment.