Placer replace check updated.

This commit is contained in:
stfwi 2021-04-24 10:04:46 +02:00
parent 700e039acb
commit c6529cf5ed
6 changed files with 37 additions and 14 deletions

View file

@ -5,4 +5,4 @@ version_minecraft=1.16.4
version_forge_minecraft=1.16.4-35.1.10 version_forge_minecraft=1.16.4-35.1.10
version_fml_mappings=20201028-1.16.3 version_fml_mappings=20201028-1.16.3
version_jei=1.16.4:7.6.1.63 version_jei=1.16.4:7.6.1.63
version_engineersdecor=1.1.13-b2 version_engineersdecor=1.1.13

View file

@ -1,6 +1,7 @@
{ {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/", "homepage": "https://www.curseforge.com/minecraft/mc-mods/engineers-decor/",
"1.16.4": { "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-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.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).", "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." "1.1.2-b1": "[U] Ported to MC1.16.2."
}, },
"promos": { "promos": {
"1.16.4-recommended": "1.1.12", "1.16.4-recommended": "1.1.13",
"1.16.4-latest": "1.1.13-b2" "1.16.4-latest": "1.1.13"
} }
} }

View file

@ -11,6 +11,9 @@ Mod sources for Minecraft version 1.16.x.
## Version history ## 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. - v1.1.13-b2 [F] Fixed explosion resistance values for standard blocks.
[F] Sandstone Ornated Clinker loot table fixed (ty czbuendel, Valen). [F] Sandstone Ornated Clinker loot table fixed (ty czbuendel, Valen).

View file

@ -87,6 +87,7 @@ public class ModConfig
public final ForgeConfigSpec.BooleanValue with_creative_mode_device_drops; public final ForgeConfigSpec.BooleanValue with_creative_mode_device_drops;
public final ForgeConfigSpec.BooleanValue with_experimental; public final ForgeConfigSpec.BooleanValue with_experimental;
public final ForgeConfigSpec.BooleanValue with_config_logging; public final ForgeConfigSpec.BooleanValue with_config_logging;
public final ForgeConfigSpec.BooleanValue with_debug_logging;
CommonConfig(ForgeConfigSpec.Builder builder) CommonConfig(ForgeConfigSpec.Builder builder)
{ {
@ -128,9 +129,13 @@ public class ModConfig
" to relocate them with contents and settings.") " to relocate them with contents and settings.")
.define("with_creative_mode_device_drops", false); .define("with_creative_mode_device_drops", false);
with_config_logging = builder 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.") .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(); builder.pop();
} }
} }
@ -552,6 +557,9 @@ public class ModConfig
public static boolean withoutRecipes() public static boolean withoutRecipes()
{ return false; } { return false; }
public static boolean withDebug()
{ return with_debug_logs_; }
//-------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------
// Cache // Cache
//-------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------
@ -560,6 +568,7 @@ public class ModConfig
private static HashSet<String> optouts_ = new HashSet<>(); private static HashSet<String> optouts_ = new HashSet<>();
private static boolean with_experimental_features_ = false; private static boolean with_experimental_features_ = false;
private static boolean with_config_logging_ = false; private static boolean with_config_logging_ = false;
private static boolean with_debug_logs_ = false;
public static boolean immersiveengineering_installed = false; public static boolean immersiveengineering_installed = false;
public static boolean without_direct_slab_pickup = false; public static boolean without_direct_slab_pickup = false;
public static boolean with_creative_mode_device_drops = 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_config_logging_ = COMMON.with_config_logging.get();
with_experimental_features_ = COMMON.with_experimental.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_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"); immersiveengineering_installed = Auxiliaries.isModLoaded("immersiveengineering");
updateOptouts(); updateOptouts();
if(!SERVER_CONFIG_SPEC.isLoaded()) return; if(!SERVER_CONFIG_SPEC.isLoaded()) return;

View file

@ -472,6 +472,7 @@ public class EdPlacer
Block block = Block.getBlockFromItem(item); Block block = Block.getBlockFromItem(item);
if(block == Blocks.AIR) { if(block == Blocks.AIR) {
if(item != null) { if(item != null) {
Auxiliaries.logDebug("Placer spit: No block for item " + item.getRegistryName().toString());
return spit_out(facing); // Item not accepted return spit_out(facing); // Item not accepted
} else { } else {
// try next slot // try next slot
@ -505,9 +506,11 @@ public class EdPlacer
} else { } else {
final BlockState current_placement_pos_state = world.getBlockState(placement_pos); final BlockState current_placement_pos_state = world.getBlockState(placement_pos);
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
final boolean replacable = current_placement_pos_state.getMaterial().isReplaceable() final boolean replacable = (current_placement_pos_state.getBlock().isReplaceable(current_placement_pos_state, Fluids.EMPTY)) && (
|| current_placement_pos_state.getBlock().isReplaceable(block.getDefaultState(), Fluids.EMPTY) world.isAirBlock(placement_pos) ||
|| 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) || ( if((!replacable) || (
(!world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(placement_pos), (Entity e)->{ (!world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(placement_pos), (Entity e)->{
if(e.canBeCollidedWith()) return true; if(e.canBeCollidedWith()) return true;
@ -518,13 +521,11 @@ public class EdPlacer
} }
return false; return false;
}).isEmpty()) }).isEmpty())
) )) {
) {
block = Blocks.AIR; block = Blocks.AIR;
no_space = true; no_space = true;
} }
} }
// println("PLACE " + current_stack + " --> " + block + " at " + placement_pos.subtract(pos) + "( item=" + item + ")"); // println("PLACE " + current_stack + " --> " + block + " at " + placement_pos.subtract(pos) + "( item=" + item + ")");
if(block != Blocks.AIR) { if(block != Blocks.AIR) {
try { try {
@ -542,6 +543,7 @@ public class EdPlacer
} }
final BlockState placement_state = (use_context==null) ? (block.getDefaultState()) : (block.getStateForPlacement(use_context)); final BlockState placement_state = (use_context==null) ? (block.getDefaultState()) : (block.getStateForPlacement(use_context));
if(placement_state == null) { if(placement_state == null) {
Auxiliaries.logDebug("Placer spit: No valid placement state for item " + item.getRegistryName().toString());
return spit_out(facing); return spit_out(facing);
} else if((use_context!=null) && (item instanceof BlockItem)) { } else if((use_context!=null) && (item instanceof BlockItem)) {
if(((BlockItem)item).tryPlace(use_context) != ActionResultType.FAIL) { 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()); if(stype != null) world.playSound(null, placement_pos, stype.getPlaceSound(), SoundCategory.BLOCKS, stype.getVolume()*0.6f, stype.getPitch());
} }
} else { } else {
Auxiliaries.logDebug("Placer spit: try-place and planting failed for item " + item.getRegistryName().toString());
return spit_out(facing); return spit_out(facing);
} }
} else { } else {

View file

@ -30,6 +30,8 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import wile.engineersdecor.ModConfig;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStream; import java.io.InputStream;
@ -105,6 +107,9 @@ public class Auxiliaries
public static final void logError(final String msg) public static final void logError(final String msg)
{ logger.error(msg); } { logger.error(msg); }
public static final void logDebug(final String msg)
{ if(ModConfig.withDebug()) logger.warn(msg); }
// ------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------
// Localization, text formatting // Localization, text formatting
// ------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------