From c6529cf5ed9de7811c2499beadea1321b6ceb8c7 Mon Sep 17 00:00:00 2001 From: stfwi Date: Sat, 24 Apr 2021 10:04:46 +0200 Subject: [PATCH] Placer replace check updated. --- gradle.properties | 2 +- meta/update.json | 5 +++-- readme.md | 3 +++ .../java/wile/engineersdecor/ModConfig.java | 15 +++++++++++-- .../wile/engineersdecor/blocks/EdPlacer.java | 21 +++++++++++-------- .../libmc/detail/Auxiliaries.java | 5 +++++ 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/gradle.properties b/gradle.properties index 0921eed..a682a87 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ version_minecraft=1.16.4 version_forge_minecraft=1.16.4-35.1.10 version_fml_mappings=20201028-1.16.3 version_jei=1.16.4:7.6.1.63 -version_engineersdecor=1.1.13-b2 +version_engineersdecor=1.1.13 diff --git a/meta/update.json b/meta/update.json index 8e09128..2b20155 100644 --- a/meta/update.json +++ b/meta/update.json @@ -1,6 +1,7 @@ { "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "1.16.4": { + "1.1.13": "[R] Release build v1.1.13.\n[A] Added debug logging feature.", "1.1.13-b2": "[F] Fixed explosion resistance values for standard blocks.\n[F] Sandstone Ornated Clinker loot table fixed (ty czbuendel, Valen).", "1.1.13-b1": "[F] Hotfix Electrical Furnace inventory import from Storage Drawers (issue #174, ty anto-fire/IchigoGames).", "1.1.12": "[F] Chisels&Bits compatibility addressed (issue #172, ty rodg88).\n[F] Labeled Crate drop list made stateless (issue #173, ty HopsandBarley && Harmonised).", @@ -34,7 +35,7 @@ "1.1.2-b1": "[U] Ported to MC1.16.2." }, "promos": { - "1.16.4-recommended": "1.1.12", - "1.16.4-latest": "1.1.13-b2" + "1.16.4-recommended": "1.1.13", + "1.16.4-latest": "1.1.13" } } \ No newline at end of file diff --git a/readme.md b/readme.md index b02bf0c..941301d 100644 --- a/readme.md +++ b/readme.md @@ -11,6 +11,9 @@ Mod sources for Minecraft version 1.16.x. ## Version history + - v1.1.13 [R] Release build v1.1.13. + [A] Added debug logging feature. + - v1.1.13-b2 [F] Fixed explosion resistance values for standard blocks. [F] Sandstone Ornated Clinker loot table fixed (ty czbuendel, Valen). diff --git a/src/main/java/wile/engineersdecor/ModConfig.java b/src/main/java/wile/engineersdecor/ModConfig.java index ca9d0a7..af99135 100644 --- a/src/main/java/wile/engineersdecor/ModConfig.java +++ b/src/main/java/wile/engineersdecor/ModConfig.java @@ -87,6 +87,7 @@ public class ModConfig public final ForgeConfigSpec.BooleanValue with_creative_mode_device_drops; public final ForgeConfigSpec.BooleanValue with_experimental; public final ForgeConfigSpec.BooleanValue with_config_logging; + public final ForgeConfigSpec.BooleanValue with_debug_logging; CommonConfig(ForgeConfigSpec.Builder builder) { @@ -128,9 +129,13 @@ public class ModConfig " to relocate them with contents and settings.") .define("with_creative_mode_device_drops", false); with_config_logging = builder - .translation(MODID + ".config.with_config_logging") + .translation(MODID + ".config.with_debug_logging") .comment("Enable detailed logging of the config values and resulting calculations in each mod feature config.") - .define("with_config_logging", false); + .define("with_debug_logging", false); + with_debug_logging = builder + .translation(MODID + ".config.with_debug_logging") + .comment("Enable debug log messages for trouble shooting. Don't activate if not really needed, this can spam the log file.") + .define("with_debug_logging", false); builder.pop(); } } @@ -552,6 +557,9 @@ public class ModConfig public static boolean withoutRecipes() { return false; } + public static boolean withDebug() + { return with_debug_logs_; } + //-------------------------------------------------------------------------------------------------------------------- // Cache //-------------------------------------------------------------------------------------------------------------------- @@ -560,6 +568,7 @@ public class ModConfig private static HashSet optouts_ = new HashSet<>(); private static boolean with_experimental_features_ = false; private static boolean with_config_logging_ = false; + private static boolean with_debug_logs_ = false; public static boolean immersiveengineering_installed = false; public static boolean without_direct_slab_pickup = false; public static boolean with_creative_mode_device_drops = false; @@ -713,7 +722,9 @@ public class ModConfig { with_config_logging_ = COMMON.with_config_logging.get(); with_experimental_features_ = COMMON.with_experimental.get(); + with_debug_logs_ = COMMON.with_debug_logging.get(); if(with_experimental_features_) LOGGER.info("Config: EXPERIMENTAL FEATURES ENABLED."); + if(with_debug_logs_) LOGGER.info("Config: DEBUG LOGGING ENABLED, WARNING, THIS MAY SPAM THE LOG."); immersiveengineering_installed = Auxiliaries.isModLoaded("immersiveengineering"); updateOptouts(); if(!SERVER_CONFIG_SPEC.isLoaded()) return; diff --git a/src/main/java/wile/engineersdecor/blocks/EdPlacer.java b/src/main/java/wile/engineersdecor/blocks/EdPlacer.java index 9b918ef..a80f95c 100644 --- a/src/main/java/wile/engineersdecor/blocks/EdPlacer.java +++ b/src/main/java/wile/engineersdecor/blocks/EdPlacer.java @@ -472,6 +472,7 @@ public class EdPlacer Block block = Block.getBlockFromItem(item); if(block == Blocks.AIR) { if(item != null) { + Auxiliaries.logDebug("Placer spit: No block for item " + item.getRegistryName().toString()); return spit_out(facing); // Item not accepted } else { // try next slot @@ -505,9 +506,11 @@ public class EdPlacer } else { final BlockState current_placement_pos_state = world.getBlockState(placement_pos); @SuppressWarnings("deprecation") - final boolean replacable = current_placement_pos_state.getMaterial().isReplaceable() - || current_placement_pos_state.getBlock().isReplaceable(block.getDefaultState(), Fluids.EMPTY) - || world.isAirBlock(placement_pos); + final boolean replacable = (current_placement_pos_state.getBlock().isReplaceable(current_placement_pos_state, Fluids.EMPTY)) && ( + world.isAirBlock(placement_pos) || + (current_placement_pos_state.getBlock() instanceof FlowingFluidBlock) || + (current_placement_pos_state.getMaterial().isReplaceable() && (!current_placement_pos_state.getMaterial().isSolid())) + ); if((!replacable) || ( (!world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(placement_pos), (Entity e)->{ if(e.canBeCollidedWith()) return true; @@ -518,13 +521,11 @@ public class EdPlacer } return false; }).isEmpty()) - ) - ) { - block = Blocks.AIR; - no_space = true; + )) { + block = Blocks.AIR; + no_space = true; + } } - } - // println("PLACE " + current_stack + " --> " + block + " at " + placement_pos.subtract(pos) + "( item=" + item + ")"); if(block != Blocks.AIR) { try { @@ -542,6 +543,7 @@ public class EdPlacer } final BlockState placement_state = (use_context==null) ? (block.getDefaultState()) : (block.getStateForPlacement(use_context)); if(placement_state == null) { + Auxiliaries.logDebug("Placer spit: No valid placement state for item " + item.getRegistryName().toString()); return spit_out(facing); } else if((use_context!=null) && (item instanceof BlockItem)) { if(((BlockItem)item).tryPlace(use_context) != ActionResultType.FAIL) { @@ -553,6 +555,7 @@ public class EdPlacer if(stype != null) world.playSound(null, placement_pos, stype.getPlaceSound(), SoundCategory.BLOCKS, stype.getVolume()*0.6f, stype.getPitch()); } } else { + Auxiliaries.logDebug("Placer spit: try-place and planting failed for item " + item.getRegistryName().toString()); return spit_out(facing); } } else { diff --git a/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java b/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java index 4d7bf8a..f4c4b01 100644 --- a/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java +++ b/src/main/java/wile/engineersdecor/libmc/detail/Auxiliaries.java @@ -30,6 +30,8 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.apache.logging.log4j.Logger; import org.lwjgl.glfw.GLFW; +import wile.engineersdecor.ModConfig; + import javax.annotation.Nullable; import java.io.BufferedReader; import java.io.InputStream; @@ -105,6 +107,9 @@ public class Auxiliaries public static final void logError(final String msg) { logger.error(msg); } + public static final void logDebug(final String msg) + { if(ModConfig.withDebug()) logger.warn(msg); } + // ------------------------------------------------------------------------------------------------------------------- // Localization, text formatting // -------------------------------------------------------------------------------------------------------------------