Skip to content

Commit

Permalink
chore: tidy up BlockUtil and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ROMVoid95 committed Jul 25, 2023
1 parent 66f385d commit 2587ce6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
7 changes: 2 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ plugins {
id 'org.cadixdev.licenser' version '0.6.1'
id 'com.diffplug.spotless' version '6.13.0'
id 'net.minecraftforge.gradle' version '6.+'
id 'net.galacticraft.internal.legacy' version '1.0.3'
id 'net.galacticraft.changelog' version '1.0.4'
id 'net.galacticraft.internal.legacy' version '1.0.5'
id 'nexus-publishing' version '2.1'
}

Expand Down Expand Up @@ -133,7 +134,3 @@ modpublishing {
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}

build {
mustRunAfter(clean)
}
12 changes: 7 additions & 5 deletions etc/formatting/eclipse_formatter.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="22">
<profile kind="CodeFormatterProfile" name="Galacticraft" version="22">
<profiles version="23">
<profile kind="CodeFormatterProfile" name="Galacticraft" version="23">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
Expand All @@ -22,7 +22,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
Expand Down Expand Up @@ -99,7 +99,7 @@
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
Expand Down Expand Up @@ -158,12 +158,14 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
Expand Down Expand Up @@ -220,7 +222,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@noformat"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="17"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;

import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.oredict.OreDictionary;

import micdoodle8.mods.galacticraft.api.vector.BlockTuple;
Expand Down Expand Up @@ -80,7 +78,7 @@ public static BlockTuple getBlockTupleFromString(String string)
Block oldFormat = parseBlockFromOldConfigFormat(string);
if (oldFormat != null)
{
GalacticraftCore.logger.info("oldFormat: " + string);
GalacticraftCore.logger.debug("oldFormat: " + string);
return new BlockTuple(oldFormat, parseMetaFromOldConfigFormat(string));
}

Expand All @@ -89,12 +87,12 @@ public static BlockTuple getBlockTupleFromString(String string)
}

@Nullable
public static Block parseBlockFromOldConfigFormat(String string)
private static Block parseBlockFromOldConfigFormat(String string)
{
return Block.getBlockFromName(string);
}

public static int parseMetaFromOldConfigFormat(String string)
private static int parseMetaFromOldConfigFormat(String string)
{
int lastColon = string.lastIndexOf(':');
int meta = -1;
Expand All @@ -117,8 +115,9 @@ public static ItemStack getItemStackFromString(String string)

private static void addToBlockStackList(Resloc resloc, NonNullList<ItemStack> nnl)
{
Block block = ForgeRegistries.BLOCKS.getValue(resloc);
if (!Block.isEqualTo(block, Blocks.AIR))
GalacticraftCore.logger.debug("Attempting to locate Block with ResourceLocation: " + resloc.toString() + " | Input: " + resloc.rawInput);
Block block = Block.REGISTRY.getObject(resloc);
if (resloc.isBlock(block))
{
ItemStack i = resloc.toItemStack(block);
if (resloc.isWildcard() && i.getHasSubtypes())
Expand All @@ -128,8 +127,10 @@ private static void addToBlockStackList(Resloc resloc, NonNullList<ItemStack> nn
{
nnl.add(i);
}
} else
{
GalacticraftCore.logger.error("No block with ResourceLocation (" + resloc.rawInput + ") could be located. Skipping");
}
GalacticraftCore.logger.error("No block with ResourceLocation: (" + resloc.rawInput + ") could be located. Skipping");
}

private static ItemStack getItemStackFromResloc(Resloc resloc)
Expand Down Expand Up @@ -191,6 +192,11 @@ private void setMetaValue(String meta)
this.meta = (meta.equals("*")) ? OreDictionary.WILDCARD_VALUE : safeParse(meta);
}

public boolean isBlock(Block block)
{
return block.getRegistryName().equals(this);
}

private int safeParse(String str)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,9 @@ public static void syncConfig(boolean load)

try
{
prop = getConfig(Constants.CONFIG_CATEGORY_COMPATIBILITY, "External Sealable IDs", new String[] {Block.REGISTRY.getNameForObject(Blocks.GLASS_PANE) + ":0"});
prop.setComment("List non-opaque blocks from other mods (for example, special types of glass) that the Oxygen Sealer should recognize as solid seals. Format is BlockName or BlockName:metadata");
prop = getConfig(Constants.CONFIG_CATEGORY_COMPATIBILITY, "External Sealable IDs", new String[] {"glass_pane"});
prop.setComment(
"List non-opaque blocks from other mods (for example, special types of glass) that the Oxygen Sealer should recognize as solid seals. Format is 'modid:blockname:meta'\n'modid' is optional but will default to 'minecraft'\n'meta' can be '*' and will be all variants of that block if any");
prop.setLanguageKey("gc.configgui.sealable_i_ds").setRequiresMcRestart(true);
sealableIDs = prop.getStringList();
finishProp(prop);
Expand All @@ -478,7 +479,7 @@ public static void syncConfig(boolean load)

prop = getConfig(Constants.CONFIG_CATEGORY_COMPATIBILITY, "External Detectable IDs", new String[] {Block.REGISTRY.getNameForObject(Blocks.COAL_ORE).getPath(), Block.REGISTRY.getNameForObject(Blocks.DIAMOND_ORE).getPath(), Block.REGISTRY.getNameForObject(Blocks.GOLD_ORE)
.getPath(), Block.REGISTRY.getNameForObject(Blocks.IRON_ORE).getPath(), Block.REGISTRY.getNameForObject(Blocks.LAPIS_ORE).getPath(), Block.REGISTRY.getNameForObject(Blocks.REDSTONE_ORE).getPath(), Block.REGISTRY.getNameForObject(Blocks.LIT_REDSTONE_ORE).getPath()});
prop.setComment("List blocks from other mods that the Sensor Glasses should recognize as solid blocks. Format is BlockName or BlockName:metadata.");
prop.setComment("List blocks from other mods that the Sensor Glasses should recognize as solid blocks. Format is 'modid:blockname:meta'\n'modid' is optional but will default to 'minecraft'\n'meta' can be '*' and will be all variants of that block if any");
prop.setLanguageKey("gc.configgui.detectable_i_ds").setRequiresMcRestart(true);
detectableIDs = prop.getStringList();
finishProp(prop);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public void catching(Throwable t)

public void debug(String msg, Object... params)
{
if(ConfigManagerCore.enableDebug) {
if (ConfigManagerCore.enableDebug || GCCoreUtil.isDeobfuscated())
{
this.logger.info("[GCDebug] " + msg, params);
}
}
Expand Down

0 comments on commit 2587ce6

Please sign in to comment.