Skip to content

Commit 9d9efbf

Browse files
committed
Code cleanup.
1 parent ea409fd commit 9d9efbf

221 files changed

Lines changed: 15865 additions & 7848 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/src/main/java/sunsetsatellite/catalyst/Catalyst.java

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.mojang.nbt.tags.CompoundTag;
44
import com.mojang.nbt.tags.Tag;
55
import net.fabricmc.api.ModInitializer;
6-
import net.minecraft.core.Global;
76
import net.minecraft.core.block.Block;
87
import net.minecraft.core.block.BlockLogic;
98
import net.minecraft.core.block.Blocks;
@@ -64,19 +63,19 @@ public void connectSignals() {
6463
DIMENSION_SAVE_SIGNAL.connect(NetworkManager.LoadSaveListener.INSTANCE);
6564
}
6665

67-
public static <K,V> Map<K,V> mapOf(K[] keys, V[] values){
68-
if(keys.length != values.length){
66+
public static <K, V> Map<K, V> mapOf(K[] keys, V[] values) {
67+
if (keys.length != values.length) {
6968
throw new IllegalArgumentException("Arrays differ in size!");
7069
}
71-
HashMap<K,V> map = new HashMap<>();
70+
HashMap<K, V> map = new HashMap<>();
7271
for (int i = 0; i < keys.length; i++) {
73-
map.put(keys[i],values[i]);
72+
map.put(keys[i], values[i]);
7473
}
7574
return map;
7675
}
7776

78-
public static <T,V> T[] arrayFill(T[] array,V value){
79-
Arrays.fill(array,value);
77+
public static <T, V> T[] arrayFill(T[] array, V value) {
78+
Arrays.fill(array, value);
8079
return array;
8180
}
8281

@@ -94,44 +93,44 @@ public static double map(double valueCoord,
9493
}
9594

9695
@SafeVarargs
97-
public static <T> List<T> listOf(T... values){
96+
public static <T> List<T> listOf(T... values) {
9897
return new ArrayList<>(Arrays.asList(values));
9998
}
10099

101100
@SafeVarargs
102-
public static <T> Set<T> setOf(T... values){
101+
public static <T> Set<T> setOf(T... values) {
103102
return new HashSet<>(Arrays.asList(values));
104103
}
105104

106-
public static <T,U> List<Pair<T,U>> zip(List<T> first, List<U> second){
107-
List<Pair<T,U>> list = new ArrayList<>();
105+
public static <T, U> List<Pair<T, U>> zip(List<T> first, List<U> second) {
106+
List<Pair<T, U>> list = new ArrayList<>();
108107
List<?> shortest = first.size() < second.size() ? first : second;
109108
for (int i = 0; i < shortest.size(); i++) {
110-
list.add(Pair.of(first.get(i),second.get(i)));
109+
list.add(Pair.of(first.get(i), second.get(i)));
111110
}
112111
return list;
113112
}
114113

115-
public static CompoundTag compoundOf(String[] keys, Object... values){
114+
public static CompoundTag compoundOf(String[] keys, Object... values) {
116115
CompoundTag tag = new CompoundTag();
117116

118117
tag.setValue(
119118
mapOf(keys,
120-
zip(listOf(keys),listOf(values))
119+
zip(listOf(keys), listOf(values))
121120
.stream()
122121
.map(pair -> tagOf(pair.getLeft(), pair.getRight()))
123122
.toArray(Tag[]::new))
124123
);
125124
return tag;
126125
}
127126

128-
public static <T> Tag<T> tagOf(T value){
127+
public static <T> Tag<T> tagOf(T value) {
129128
Tag<T> tag = (Tag<T>) Tag.createTagOfType(value.getClass());
130129
tag.setValue(value);
131130
return tag;
132131
}
133132

134-
public static <T> Tag<T> tagOf(String name, T value){
133+
public static <T> Tag<T> tagOf(String name, T value) {
135134
Tag<T> tag = (Tag<T>) Tag.createTagOfType(value.getClass());
136135
tag.setValue(value);
137136
tag.setName(name);
@@ -142,10 +141,10 @@ public static <T> Tag<T> tagOf(String name, T value){
142141
* @param values The values to be checked
143142
* @return Returns the smallest of <code>values</code>
144143
*/
145-
public static long multiMin(long... values){
144+
public static long multiMin(long... values) {
146145
long min = Long.MAX_VALUE;
147146
for (long value : values) {
148-
if(value < min){
147+
if (value < min) {
149148
min = value;
150149
}
151150
}
@@ -163,62 +162,62 @@ public static ArrayList<ItemStack> condenseItemList(List<ItemStack> list) {
163162
found = true;
164163
}
165164
}
166-
if(!found) stacks.add(stack.copy());
165+
if (!found) stacks.add(stack.copy());
167166
}
168167
}
169168
return stacks;
170169
}
171170

172-
public static @UnmodifiableView List<ItemStack> collectStacks(Container inv){
173-
if(inv == null) return Collections.emptyList();
171+
public static @UnmodifiableView List<ItemStack> collectStacks(Container inv) {
172+
if (inv == null) return Collections.emptyList();
174173
ArrayList<ItemStack> stacks = new ArrayList<>();
175174

176175
for (int i = 0; i < inv.getContainerSize(); i++) {
177-
stacks.add(i,inv.getItem(i));
176+
stacks.add(i, inv.getItem(i));
178177
}
179178

180179
return Collections.unmodifiableList(stacks);
181180
}
182181

183-
public static @UnmodifiableView List<ItemStack> collectAndCondenseStacks(Container inv){
182+
public static @UnmodifiableView List<ItemStack> collectAndCondenseStacks(Container inv) {
184183
return condenseItemList(collectStacks(inv));
185184
}
186185

187-
public static Pair<Direction, BlockSection> getBlockSurfaceClickPosition(World world, Player player, Side side, Vec2f clickPosition){
186+
public static Pair<Direction, BlockSection> getBlockSurfaceClickPosition(World world, Player player, Side side, Vec2f clickPosition) {
188187
Direction dir = Direction.getDirectionFromSide(side.getId());
189-
return Pair.of(dir,BlockSection.getClosestBlockSection(clickPosition));
188+
return Pair.of(dir, BlockSection.getClosestBlockSection(clickPosition));
190189
}
191190

192191
public static Side calculatePlayerFacing(float rotation) {
193192
return Side.values()[(2 + ((MathHelper.floor((double) ((rotation * 4F) / 360F) + 0.5D) + 2) & 3))];
194193
}
195194

196-
public static void displayGui(Player player, Container inventory, int slotIndex, boolean isArmor, String id){
197-
((IMpGui)player).catalyst$displayCustomGUI(inventory, slotIndex, isArmor, id);
195+
public static void displayGui(Player player, Container inventory, int slotIndex, boolean isArmor, String id) {
196+
((IMpGui) player).catalyst$displayCustomGUI(inventory, slotIndex, isArmor, id);
198197
}
199198

200199

201-
public static void displayGui(Player player, TileEntity tileEntity, String id){
202-
((IMpGui)player).catalyst$displayCustomGUI(tileEntity, id);
200+
public static void displayGui(Player player, TileEntity tileEntity, String id) {
201+
((IMpGui) player).catalyst$displayCustomGUI(tileEntity, id);
203202
}
204203

205-
public static void displayGui(Player player, TileEntity tileEntity, String id, CompoundTag data){
206-
((IMpGui)player).catalyst$displayCustomGUI(tileEntity, id, data);
204+
public static void displayGui(Player player, TileEntity tileEntity, String id, CompoundTag data) {
205+
((IMpGui) player).catalyst$displayCustomGUI(tileEntity, id, data);
207206
}
208207

209-
public static <T> T blockLogic(Block<? extends BlockLogic> block, Class<T> clazz){
210-
if(Block.hasLogicClass(block, clazz)) return (T) block.getLogic();
208+
public static <T> T blockLogic(Block<? extends BlockLogic> block, Class<T> clazz) {
209+
if (Block.hasLogicClass(block, clazz)) return (T) block.getLogic();
211210
else return null;
212211
}
213212

214-
public static <T> T blockLogic(int id, Class<T> clazz){
215-
if(Block.hasLogicClass(Blocks.blocksList[id], clazz)) return (T) Blocks.blocksList[id].getLogic();
213+
public static <T> T blockLogic(int id, Class<T> clazz) {
214+
if (Block.hasLogicClass(Blocks.blocksList[id], clazz)) return (T) Blocks.blocksList[id].getLogic();
216215
else return null;
217216
}
218217

219-
public static <T> boolean listContains(List<T> list, T o, BiFunction<T,T,Boolean> equals){
218+
public static <T> boolean listContains(List<T> list, T o, BiFunction<T, T, Boolean> equals) {
220219
for (T obj : list) {
221-
if(equals.apply(o,obj)){
220+
if (equals.apply(o, obj)) {
222221
return true;
223222
}
224223
}
@@ -238,42 +237,42 @@ public static byte[] HSBtoRGB(float hue, float saturation, float brightness) {
238237
float f6 = brightness * (1.0F - saturation * f4);
239238
float f7 = brightness * (1.0F - saturation * (1.0F - f4));
240239
switch ((int) f3) {
241-
case 0 :
240+
case 0:
242241
red = (byte) (brightness * 255F + 0.5F);
243242
green = (byte) (f7 * 255F + 0.5F);
244243
blue = (byte) (f5 * 255F + 0.5F);
245244
break;
246-
case 1 :
245+
case 1:
247246
red = (byte) (f6 * 255F + 0.5F);
248247
green = (byte) (brightness * 255F + 0.5F);
249248
blue = (byte) (f5 * 255F + 0.5F);
250249
break;
251-
case 2 :
250+
case 2:
252251
red = (byte) (f5 * 255F + 0.5F);
253252
green = (byte) (brightness * 255F + 0.5F);
254253
blue = (byte) (f7 * 255F + 0.5F);
255254
break;
256-
case 3 :
255+
case 3:
257256
red = (byte) (f5 * 255F + 0.5F);
258257
green = (byte) (f6 * 255F + 0.5F);
259258
blue = (byte) (brightness * 255F + 0.5F);
260259
break;
261-
case 4 :
260+
case 4:
262261
red = (byte) (f7 * 255F + 0.5F);
263262
green = (byte) (f5 * 255F + 0.5F);
264263
blue = (byte) (brightness * 255F + 0.5F);
265264
break;
266-
case 5 :
265+
case 5:
267266
red = (byte) (brightness * 255F + 0.5F);
268267
green = (byte) (f5 * 255F + 0.5F);
269268
blue = (byte) (f6 * 255F + 0.5F);
270269
break;
271270
}
272271
}
273-
return new byte[]{red,green,blue};
272+
return new byte[]{red, green, blue};
274273
}
275274

276-
public static int random(Random random, int min, int max){
277-
return random.nextInt(max-min+1)+min;
275+
public static int random(Random random, int min, int max) {
276+
return random.nextInt(max - min + 1) + min;
278277
}
279278
}

core/src/main/java/sunsetsatellite/catalyst/CatalystClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void beforeClientStart() {
3232

3333
@Override
3434
public void afterClientStart() {
35-
if(!Global.isServer){
35+
if (!Global.isServer) {
3636
optionsPage = new OptionsPage("gui.options.page.catalyst", Items.DUST_REDSTONE.getDefaultStack());
3737
IKeybinds gameSettings = (IKeybinds) Minecraft.getMinecraft().gameSettings;
3838
coreCategory = new OptionsCategory("gui.options.page.catalyst.category.core");

core/src/main/java/sunsetsatellite/catalyst/core/mixin/BlockModelStandardMixin.java

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,38 @@
2121
import java.nio.FloatBuffer;
2222

2323

24-
@Mixin(value = BlockModelStandard.class,remap = false)
24+
@Mixin(value = BlockModelStandard.class, remap = false)
2525
public abstract class BlockModelStandardMixin extends BlockModel<BlockLogic> implements IColorOverride, IFullbright {
2626

2727
private boolean overrideColor = false;
28-
@Unique
29-
private Vec4f colorOverride = new Vec4f(1);
30-
@Unique
31-
private boolean fullbright = false;
28+
@Unique
29+
private Vec4f colorOverride = new Vec4f(1);
30+
@Unique
31+
private boolean fullbright = false;
3232

33-
private BlockModelStandardMixin(Block<BlockLogic> block) {
34-
super(block);
35-
}
33+
private BlockModelStandardMixin(Block<BlockLogic> block) {
34+
super(block);
35+
}
3636

37-
@Inject(method = "renderBlockOnInventory", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/model/BlockModelStandard;getBlockBoundsForItemRender()Lnet/minecraft/core/util/phys/AABB;"))
38-
public void renderBlockOnInventory(Tessellator tessellator, int metadata, float brightness, float alpha, Integer lightmapCoordinate, CallbackInfo ci) {
37+
@Inject(method = "renderBlockOnInventory", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/block/model/BlockModelStandard;getBlockBoundsForItemRender()Lnet/minecraft/core/util/phys/AABB;"))
38+
public void renderBlockOnInventory(Tessellator tessellator, int metadata, float brightness, float alpha, Integer lightmapCoordinate, CallbackInfo ci) {
3939
FloatBuffer buffer = BufferUtils.createFloatBuffer(16);
4040
GL11.glGetFloatv(GL11.GL_CURRENT_COLOR, buffer);
41-
if(overrideColor) GL11.glColor4d(colorOverride.x * buffer.get(0),colorOverride.y * buffer.get(1),colorOverride.z * buffer.get(2),colorOverride.w * buffer.get(3));
42-
}
41+
if (overrideColor)
42+
GL11.glColor4d(colorOverride.x * buffer.get(0), colorOverride.y * buffer.get(1), colorOverride.z * buffer.get(2), colorOverride.w * buffer.get(3));
43+
}
4344

44-
@Inject(method = "renderBlockWithBounds", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/tessellator/Tessellator;startDrawingQuads()V", shift = At.Shift.AFTER))
45-
public void disableLightmap(Tessellator tessellator, AABB bounds, int metadata, float brightness, float alpha, Integer lightmapCoordinate, CallbackInfo ci) {
46-
if(LightmapHelper.isLightmapEnabled() && fullbright) tessellator.setLightmapCoord(LightmapHelper.getLightmapCoord(15,15));
47-
}
45+
@Inject(method = "renderBlockWithBounds", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/tessellator/Tessellator;startDrawingQuads()V", shift = At.Shift.AFTER))
46+
public void disableLightmap(Tessellator tessellator, AABB bounds, int metadata, float brightness, float alpha, Integer lightmapCoordinate, CallbackInfo ci) {
47+
if (LightmapHelper.isLightmapEnabled() && fullbright)
48+
tessellator.setLightmapCoord(LightmapHelper.getLightmapCoord(15, 15));
49+
}
4850

4951

50-
@Override
51-
public void overrideColor(float r, float g, float b, float alpha) {
52-
colorOverride = new Vec4f(r,g,b,alpha);
53-
}
52+
@Override
53+
public void overrideColor(float r, float g, float b, float alpha) {
54+
colorOverride = new Vec4f(r, g, b, alpha);
55+
}
5456

5557
@Override
5658
public void enableColorOverride() {
@@ -63,12 +65,12 @@ public void disableColorOverride() {
6365
}
6466

6567
@Override
66-
public void enableFullbright() {
67-
fullbright = true;
68-
}
68+
public void enableFullbright() {
69+
fullbright = true;
70+
}
6971

70-
@Override
71-
public void disableFullbright() {
72-
fullbright = false;
73-
}
72+
@Override
73+
public void disableFullbright() {
74+
fullbright = false;
75+
}
7476
}

core/src/main/java/sunsetsatellite/catalyst/core/mixin/FontRendererMixin.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,26 @@
1111
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
1212
import sunsetsatellite.catalyst.core.util.model.IFullbright;
1313

14-
@Mixin(value = Font.class,remap = false)
14+
@Mixin(value = Font.class, remap = false)
1515
public class FontRendererMixin implements IFullbright {
1616

1717
@Unique
1818
private boolean fullbright = false;
1919

20-
@Inject(method = "renderStringAtPos",at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/tessellator/Tessellator;startDrawingQuads()V",shift = At.Shift.AFTER))
21-
public void disableLightmap(String text, boolean flag, CallbackInfo ci){
22-
if(LightmapHelper.isLightmapEnabled() && fullbright) Tessellator.instance.setLightmapCoord(LightmapHelper.getLightmapCoord(15,15));
20+
@Inject(method = "renderStringAtPos", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/tessellator/Tessellator;startDrawingQuads()V", shift = At.Shift.AFTER))
21+
public void disableLightmap(String text, boolean flag, CallbackInfo ci) {
22+
if (LightmapHelper.isLightmapEnabled() && fullbright)
23+
Tessellator.instance.setLightmapCoord(LightmapHelper.getLightmapCoord(15, 15));
2324
}
2425

25-
@Inject(method = "renderDefaultChar",at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glBegin(I)V",shift = At.Shift.BEFORE))
26-
public void disableLightmap2(char c, boolean italic, CallbackInfoReturnable<Float> cir){
27-
if(LightmapHelper.isLightmapEnabled() && fullbright) LightmapHelper.setLightmapCoord(15,15);
26+
@Inject(method = "renderDefaultChar", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glBegin(I)V", shift = At.Shift.BEFORE))
27+
public void disableLightmap2(char c, boolean italic, CallbackInfoReturnable<Float> cir) {
28+
if (LightmapHelper.isLightmapEnabled() && fullbright) LightmapHelper.setLightmapCoord(15, 15);
2829
}
2930

30-
@Inject(method = "renderUnicodeChar",at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glBegin(I)V",shift = At.Shift.BEFORE))
31-
public void disableLightmap3(char c, boolean italic, CallbackInfoReturnable<Float> cir){
32-
if(LightmapHelper.isLightmapEnabled() && fullbright) LightmapHelper.setLightmapCoord(15,15);
31+
@Inject(method = "renderUnicodeChar", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glBegin(I)V", shift = At.Shift.BEFORE))
32+
public void disableLightmap3(char c, boolean italic, CallbackInfoReturnable<Float> cir) {
33+
if (LightmapHelper.isLightmapEnabled() && fullbright) LightmapHelper.setLightmapCoord(15, 15);
3334
}
3435

3536
@Override

core/src/main/java/sunsetsatellite/catalyst/core/mixin/GameSettingsMixin.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
import sunsetsatellite.catalyst.core.util.mixin.interfaces.IKeybinds;
99

1010
@Mixin(
11-
value = GameSettings.class,
12-
remap = false
11+
value = GameSettings.class,
12+
remap = false
1313
)
14-
public class GameSettingsMixin implements IKeybinds
15-
{
16-
private final GameSettings thisAs = ((GameSettings)(Object)this);
14+
public class GameSettingsMixin implements IKeybinds {
15+
private final GameSettings thisAs = ((GameSettings) (Object) this);
1716

1817
@Unique
19-
OptionBoolean networkRenderOption = new OptionBoolean(thisAs,"catalyst-core.showNetworkRender",false);
18+
OptionBoolean networkRenderOption = new OptionBoolean(thisAs, "catalyst-core.showNetworkRender", false);
2019

2120
@Override
2221
public OptionBoolean getNetworkRenderOption() {

0 commit comments

Comments
 (0)