Skip to content

Commit

Permalink
Misc code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed May 2, 2022
1 parent 41b108c commit a593be9
Show file tree
Hide file tree
Showing 136 changed files with 625 additions and 721 deletions.
56 changes: 29 additions & 27 deletions docs/GoogleStyle4Indents.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
<ANNO name="javax.annotation.Nonnull" />
<ANNO name="javax.annotation.Nullable" />
<ANNO name="javax.annotation.ParametersAreNonnullByDefault" />
<ANNO name="mcp.MethodsReturnNonnullByDefault" />
<ANNO name="mekanism.api.annotations.FieldsAreNonnullByDefault" />
<ANNO name="mekanism.api.annotations.NonNull" />
<ANNO name="net.minecraft.MethodsReturnNonnullByDefault" />
</REPEAT_ANNOTATIONS>
</JavaCodeStyleSettings>
<Objective-C>
Expand Down Expand Up @@ -97,7 +99,6 @@
</TypeScriptCodeStyleSettings>
<XML>
<option name="XML_ALIGN_ATTRIBUTES" value="false" />
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="CSS">
<indentOptions>
Expand All @@ -124,6 +125,9 @@
<option name="WHILE_BRACE_FORCE" value="3" />
<option name="FOR_BRACE_FORCE" value="3" />
</codeStyleSettings>
<codeStyleSettings language="Groovy">
<option name="RIGHT_MARGIN" value="170" />
</codeStyleSettings>
<codeStyleSettings language="HTML">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
Expand Down Expand Up @@ -274,7 +278,7 @@
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand Down Expand Up @@ -308,7 +312,7 @@
<AND>
<NAME>.*:.*Style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
Expand All @@ -320,7 +324,7 @@
<AND>
<NAME>.*:layout_width</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -331,7 +335,7 @@
<AND>
<NAME>.*:layout_height</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -342,7 +346,7 @@
<AND>
<NAME>.*:layout_weight</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -353,7 +357,7 @@
<AND>
<NAME>.*:layout_margin</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -364,7 +368,7 @@
<AND>
<NAME>.*:layout_marginTop</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -375,7 +379,7 @@
<AND>
<NAME>.*:layout_marginBottom</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -386,7 +390,7 @@
<AND>
<NAME>.*:layout_marginStart</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -397,7 +401,7 @@
<AND>
<NAME>.*:layout_marginEnd</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -408,7 +412,7 @@
<AND>
<NAME>.*:layout_marginLeft</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -419,7 +423,7 @@
<AND>
<NAME>.*:layout_marginRight</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -430,7 +434,7 @@
<AND>
<NAME>.*:layout_.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
Expand All @@ -442,7 +446,7 @@
<AND>
<NAME>.*:padding</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -453,7 +457,7 @@
<AND>
<NAME>.*:paddingTop</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -464,7 +468,7 @@
<AND>
<NAME>.*:paddingBottom</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -475,7 +479,7 @@
<AND>
<NAME>.*:paddingStart</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -486,7 +490,7 @@
<AND>
<NAME>.*:paddingEnd</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -497,7 +501,7 @@
<AND>
<NAME>.*:paddingLeft</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -508,7 +512,7 @@
<AND>
<NAME>.*:paddingRight</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
Expand All @@ -518,7 +522,7 @@
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
Expand All @@ -529,7 +533,7 @@
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/apk/res-auto</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/apk/res-auto</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
Expand All @@ -540,7 +544,7 @@
<match>
<AND>
<NAME>.*</NAME>
<XML_NAMESPACE>http://schemas.android.com/tools</XML_NAMESPACE>
<XML_NAMESPACE>https://schemas.android.com/tools</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
Expand All @@ -563,9 +567,7 @@
<codeStyleSettings language="protobuf">
<option name="RIGHT_MARGIN" value="80" />
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="2" />
<option name="TAB_SIZE" value="2" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void render(@Nonnull EntityBalloon balloon, float entityYaw, float partia
VertexConsumer builder = renderer.getBuffer(renderType);
PoseStack.Pose last = matrix.last();
for (BakedQuad quad : quads) {
float[] color = new float[]{1, 1, 1, 1};
float[] color = {1, 1, 1, 1};
if (quad.getTintIndex() == 0) {
EnumColor balloonColor = balloon.getColor();
color[0] = balloonColor.getColor(0);
Expand Down
63 changes: 23 additions & 40 deletions src/api/java/mekanism/api/RelativeSide.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,22 @@ public String getTranslationKey() {
* @return The direction representing which side of the block this RelativeSide is actually representing based on the direction it is facing.
*/
public Direction getDirection(@Nonnull Direction facing) {
if (this == FRONT) {
return facing;
} else if (this == BACK) {
return facing.getOpposite();
} else if (this == LEFT) {
if (facing == Direction.DOWN || facing == Direction.UP) {
return Direction.EAST;
}
return facing.getClockWise();
} else if (this == RIGHT) {
if (facing == Direction.DOWN || facing == Direction.UP) {
return Direction.WEST;
}
return facing.getCounterClockWise();
} else if (this == TOP) {
if (facing == Direction.DOWN) {
return Direction.NORTH;
} else if (facing == Direction.UP) {
return Direction.SOUTH;
}
return Direction.UP;
} else if (this == BOTTOM) {
if (facing == Direction.DOWN) {
return Direction.SOUTH;
} else if (facing == Direction.UP) {
return Direction.NORTH;
}
return Direction.DOWN;
}
//Fallback to north though we should never get here
return Direction.NORTH;
return switch (this) {
case FRONT -> facing;
case BACK -> facing.getOpposite();
case LEFT -> facing == Direction.DOWN || facing == Direction.UP ? Direction.EAST : facing.getClockWise();
case RIGHT -> facing == Direction.DOWN || facing == Direction.UP ? Direction.WEST : facing.getCounterClockWise();
case TOP -> switch (facing) {
case DOWN -> Direction.NORTH;
case UP -> Direction.SOUTH;
default -> Direction.UP;
};
case BOTTOM -> switch (facing) {
case DOWN -> Direction.SOUTH;
case UP -> Direction.NORTH;
default -> Direction.DOWN;
};
};
}

/**
Expand All @@ -94,15 +79,13 @@ public static RelativeSide fromDirections(@Nonnull Direction facing, @Nonnull Di
} else if (side == facing.getOpposite()) {
return BACK;
} else if (facing == Direction.DOWN || facing == Direction.UP) {
if (side == Direction.NORTH) {
return facing == Direction.DOWN ? TOP : BOTTOM;
} else if (side == Direction.SOUTH) {
return facing == Direction.DOWN ? BOTTOM : TOP;
} else if (side == Direction.WEST) {
return RIGHT;
} else if (side == Direction.EAST) {
return LEFT;
}
return switch (side) {
case NORTH -> facing == Direction.DOWN ? TOP : BOTTOM;
case SOUTH -> facing == Direction.DOWN ? BOTTOM : TOP;
case WEST -> RIGHT;
case EAST -> LEFT;
default -> throw new IllegalStateException("Case should have been caught earlier.");
};
} else if (side == Direction.DOWN) {
return BOTTOM;
} else if (side == Direction.UP) {
Expand Down
4 changes: 2 additions & 2 deletions src/api/java/mekanism/api/SerializerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ private static <CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack
if (chemical.isEmptyType()) {
throw new JsonSyntaxException("Invalid " + serializationKey + " type '" + resourceLocation + "'");
}
//noinspection unchecked
return (STACK) chemical.getStack(amount);
}

Expand Down Expand Up @@ -345,9 +346,8 @@ public static JsonElement serializeFluidStack(@Nonnull FluidStack stack) {
* @return Json representation.
*/
public static JsonElement serializeBoxedChemicalStack(@Nonnull BoxedChemicalStack stack) {
JsonObject json;
ChemicalType chemicalType = stack.getChemicalType();
json = switch (chemicalType) {
JsonObject json = switch (chemicalType) {
case GAS -> serializeGasStack((GasStack) stack.getChemicalStack());
case INFUSION -> serializeInfusionStack((InfusionStack) stack.getChemicalStack());
case PIGMENT -> serializePigmentStack((PigmentStack) stack.getChemicalStack());
Expand Down
6 changes: 2 additions & 4 deletions src/api/java/mekanism/api/chemical/Chemical.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import javax.annotation.ParametersAreNonnullByDefault;
import mekanism.api.chemical.attribute.ChemicalAttribute;
import mekanism.api.providers.IChemicalProvider;
import mekanism.api.text.IHasTextComponent;
import mekanism.api.text.IHasTranslationKey;
import mekanism.api.text.TextComponentUtil;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -23,8 +21,7 @@

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public abstract class Chemical<CHEMICAL extends Chemical<CHEMICAL>> extends ForgeRegistryEntry<CHEMICAL> implements IChemicalProvider<CHEMICAL>, IHasTextComponent,
IHasTranslationKey {
public abstract class Chemical<CHEMICAL extends Chemical<CHEMICAL>> extends ForgeRegistryEntry<CHEMICAL> implements IChemicalProvider<CHEMICAL> {

private final ChemicalTags<CHEMICAL> chemicalTags;
private final Map<Class<? extends ChemicalAttribute>, ChemicalAttribute> attributeMap;
Expand All @@ -46,6 +43,7 @@ protected Chemical(ChemicalBuilder<CHEMICAL, ?> builder, ChemicalTags<CHEMICAL>

@Nonnull
@Override
@SuppressWarnings("unchecked")
public CHEMICAL getChemical() {
return (CHEMICAL) this;
}
Expand Down
3 changes: 1 addition & 2 deletions src/api/java/mekanism/api/gear/ModuleData.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import mekanism.api.gear.config.ModuleConfigItemCreator;
import mekanism.api.providers.IItemProvider;
import mekanism.api.providers.IModuleDataProvider;
import mekanism.api.text.IHasTranslationKey;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.Util;
import net.minecraft.world.entity.player.Player;
Expand All @@ -19,7 +18,7 @@

@FieldsAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class ModuleData<MODULE extends ICustomModule<MODULE>> extends ForgeRegistryEntry<ModuleData<?>> implements IHasTranslationKey, IModuleDataProvider<MODULE> {
public class ModuleData<MODULE extends ICustomModule<MODULE>> extends ForgeRegistryEntry<ModuleData<?>> implements IModuleDataProvider<MODULE> {

private final NonNullSupplier<MODULE> supplier;
private final IItemProvider itemProvider;
Expand Down
Loading

0 comments on commit a593be9

Please sign in to comment.