Skip to content

Commit

Permalink
Cleanup Codebase (#44)
Browse files Browse the repository at this point in the history
* Format
Unsure if I like this entirely... It is *better* though.

* Better

* Remove unused

* Brackets
  • Loading branch information
KyGost authored Oct 1, 2021
1 parent a3f471c commit 64e9fd9
Show file tree
Hide file tree
Showing 106 changed files with 4,890 additions and 4,719 deletions.
47 changes: 24 additions & 23 deletions src/main/java/dev/cafeteria/artofalchemy/AoAConfig.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,21 @@
package dev.cafeteria.artofalchemy;

import dev.cafeteria.artofalchemy.util.MateriaRank;

import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
import me.shedaniel.autoconfig.annotation.ConfigEntry;


@Config(name = ArtOfAlchemy.MOD_ID)
public class AoAConfig implements ConfigData {

public static AoAConfig get() {
return AutoConfig.getConfigHolder(AoAConfig.class).getConfig();
}

public int networkProcessingLimit = 1024;
public boolean formulaLoot = true;

public int vesselCapacity = 4000;
public int tankCapacity = 8000;
public int centrifugeCapacity = 4000;

@ConfigEntry.Gui.CollapsibleObject
public CalcinatorSettings calcinatorSettings = new CalcinatorSettings();
public static class CalcinatorSettings {
public float yieldBasic = 0.5f;
public float yieldPlus = 1.0f;
public int opTimeBasic = 60;
public int opTimePlus = 120;
}

@ConfigEntry.Gui.CollapsibleObject
public DissolverSettings dissolverSettings = new DissolverSettings();
public static class DissolverSettings {
public float yieldBasic = 0.5f;
public float yieldPlus = 1.0f;
Expand All @@ -42,8 +25,11 @@ public static class DissolverSettings {
public int tankPlus = 8000;
}

@ConfigEntry.Gui.CollapsibleObject
public SynthesizerSettings synthesizerSettings = new SynthesizerSettings();
public static class ProjectorSettings {
public int opTime = 180;
public int tankSize = 8000;
}

public static class SynthesizerSettings {
public MateriaRank maxTierBasic = MateriaRank.C;
public MateriaRank maxTierPlus = MateriaRank.OMEGA;
Expand All @@ -53,11 +39,26 @@ public static class SynthesizerSettings {
public int tankPlus = 8000;
}

public static AoAConfig get() {
return AutoConfig.getConfigHolder(AoAConfig.class).getConfig();
}

public int networkProcessingLimit = 1024;

public boolean formulaLoot = true;
public int vesselCapacity = 4000;

public int tankCapacity = 8000;
public int centrifugeCapacity = 4000;

@ConfigEntry.Gui.CollapsibleObject
public CalcinatorSettings calcinatorSettings = new CalcinatorSettings();
@ConfigEntry.Gui.CollapsibleObject
public DissolverSettings dissolverSettings = new DissolverSettings();

@ConfigEntry.Gui.CollapsibleObject
public SynthesizerSettings synthesizerSettings = new SynthesizerSettings();
@ConfigEntry.Gui.CollapsibleObject
public ProjectorSettings projectorSettings = new ProjectorSettings();
public static class ProjectorSettings {
public int opTime = 180;
public int tankSize = 8000;
}

}
35 changes: 18 additions & 17 deletions src/main/java/dev/cafeteria/artofalchemy/ArtOfAlchemy.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,40 @@
import dev.cafeteria.artofalchemy.transport.EssentiaNetworker;
import dev.cafeteria.artofalchemy.util.AoALoot;
import dev.cafeteria.artofalchemy.util.AoATags;

import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;

public class ArtOfAlchemy implements ModInitializer {

public static final String MOD_ID = "artofalchemy";
public static final String MOD_NAME = "Art of Alchemy";

public static final Logger LOGGER = LogManager.getLogger(MOD_NAME);
public static final Logger LOGGER = LogManager.getLogger(ArtOfAlchemy.MOD_NAME);

public static final ItemGroup ALCHEMY_GROUP = FabricItemGroupBuilder.create(ArtOfAlchemy.id("alchemy"))
.icon(() -> new ItemStack(AoAItems.MYSTERIOUS_SIGIL)).build();

public static final ItemGroup ALCHEMY_GROUP = FabricItemGroupBuilder.create(id("alchemy"))
.icon(() -> new ItemStack(AoAItems.MYSTERIOUS_SIGIL)).build();
public static Identifier id(final String name) {
return new Identifier(ArtOfAlchemy.MOD_ID, name);
}

public static void log(final Level level, final String message) {
ArtOfAlchemy.LOGGER.log(level, message);
}

@Override
public void onInitialize() {
log(Level.INFO, "Humankind cannot gain anything without first giving something in return. "
+ "To obtain, something of equal value must be lost.");
ArtOfAlchemy.log(
Level.INFO,
"Humankind cannot gain anything without first giving something in return. "
+ "To obtain, something of equal value must be lost."
);

AoATags.init();
AutoConfig.register(AoAConfig.class, GsonConfigSerializer::new);
Expand All @@ -54,19 +63,11 @@ public void onInitialize() {
AoADispenserBehavior.registerDispenserBehavior();
AoANetworking.initializeNetworking();
AoALoot.initialize();
ServerTickEvents.END_WORLD_TICK.register((world) -> {
ServerTickEvents.END_WORLD_TICK.register(world -> {
if (!world.isClient()) {
EssentiaNetworker.get((ServerWorld) world).tick();
EssentiaNetworker.get(world).tick();
}
});
}

public static Identifier id(String name) {
return new Identifier(MOD_ID, name);
}

public static void log(Level level, String message){
LOGGER.log(level, message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import dev.cafeteria.artofalchemy.gui.screen.AoAScreens;
import dev.cafeteria.artofalchemy.network.AoAClientNetworking;
import dev.cafeteria.artofalchemy.render.AoARenderers;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.cafeteria.artofalchemy.block;

import dev.cafeteria.artofalchemy.essentia.EssentiaContainer;

import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
Expand All @@ -24,49 +23,50 @@ abstract public class AbstractBlockCentrifuge extends Block implements BlockEnti

public static final int TANK_SIZE = 4000;
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
public static final Settings SETTINGS = Settings
.of(Material.STONE)
.strength(5.0f, 6.0f);
protected EssentiaContainer input = new EssentiaContainer().setCapacity(TANK_SIZE).setInput(true).setOutput(false);
public static final Settings SETTINGS = Settings.of(Material.STONE).strength(5.0f, 6.0f);
protected EssentiaContainer input = new EssentiaContainer().setCapacity(AbstractBlockCentrifuge.TANK_SIZE)
.setInput(true).setOutput(false);
protected EssentiaContainer[] outputs;

public AbstractBlockCentrifuge() {
super(SETTINGS);
setDefaultState(getDefaultState().with(FACING, Direction.NORTH));
super(AbstractBlockCentrifuge.SETTINGS);
this.setDefaultState(this.getDefaultState().with(AbstractBlockCentrifuge.FACING, Direction.NORTH));
}

@Override
protected void appendProperties(final Builder<Block, BlockState> builder) {
builder.add(AbstractBlockCentrifuge.FACING);
}

@Override
protected void appendProperties(Builder<Block, BlockState> builder) {
builder.add(FACING);
public BlockState getPlacementState(final ItemPlacementContext ctx) {
return super.getPlacementState(ctx).with(AbstractBlockCentrifuge.FACING, ctx.getPlayerFacing().getOpposite());
}

@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return super.getPlacementState(ctx).with(FACING, ctx.getPlayerFacing().getOpposite());
public BlockState mirror(final BlockState state, final BlockMirror mirror) {
return state.rotate(mirror.getRotation(state.get(AbstractBlockCentrifuge.FACING)));
}

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {
public ActionResult onUse(
final BlockState state, final World world, final BlockPos pos, final PlayerEntity player, final Hand hand,
final BlockHitResult hit
) {
if (world.isClient) {
return ActionResult.SUCCESS;
}

if (player.isSneaking()) {
world.setBlockState(pos, rotate(state, BlockRotation.CLOCKWISE_90));
world.setBlockState(pos, this.rotate(state, BlockRotation.CLOCKWISE_90));
} else {
world.setBlockState(pos, rotate(state, BlockRotation.COUNTERCLOCKWISE_90));
world.setBlockState(pos, this.rotate(state, BlockRotation.COUNTERCLOCKWISE_90));
}
return ActionResult.SUCCESS;
}

@Override
public BlockState rotate(BlockState state, BlockRotation rotation) {
return state.with(FACING, rotation.rotate(state.get(FACING)));
}

@Override
public BlockState mirror(BlockState state, BlockMirror mirror) {
return state.rotate(mirror.getRotation(state.get(FACING)));
public BlockState rotate(final BlockState state, final BlockRotation rotation) {
return state.with(AbstractBlockCentrifuge.FACING, rotation.rotate(state.get(AbstractBlockCentrifuge.FACING)));
}
}
67 changes: 33 additions & 34 deletions src/main/java/dev/cafeteria/artofalchemy/block/AoABlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import dev.cafeteria.artofalchemy.item.AoAItems;
import dev.cafeteria.artofalchemy.item.BlockItemMateria;
import dev.cafeteria.artofalchemy.util.MateriaRank;

import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.util.Identifier;
Expand All @@ -36,50 +35,50 @@ public class AoABlocks {
public static final Block ALKAHEST = new BlockAlkahest();
public static final Map<Essentia, Block> ESSENTIA = new HashMap<>();

public static void registerBlocks() {
register("analysis_desk", ANALYZER);
register("calcination_furnace", CALCINATOR);
register("dissolution_chamber", DISSOLVER);
register("distillation_apparatus", DISTILLER);
register("synthesis_table", SYNTHESIZER);
register("projection_altar", PROJECTOR);
register("calcination_furnace_plus", CALCINATOR_PLUS);
register("dissolution_chamber_plus", DISSOLVER_PLUS);
register("synthesis_table_plus", SYNTHESIZER_PLUS);
register("astrological_centrifuge", ASTRO_CENTRIFUGE);
register("elemental_centrifuge", ELEMENT_CENTRIFUGE);
register("essentia_tank", TANK);
register("essentia_pipe", PIPE);
public static Block register(final String name, final Block block) {
AoAItems.register(name, new BlockItem(block, AoAItems.defaults()));
return AoABlocks.registerItemless(name, block);
}

registerItemless("alkahest", ALKAHEST);
public static void registerBlocks() {
AoABlocks.register("analysis_desk", AoABlocks.ANALYZER);
AoABlocks.register("calcination_furnace", AoABlocks.CALCINATOR);
AoABlocks.register("dissolution_chamber", AoABlocks.DISSOLVER);
AoABlocks.register("distillation_apparatus", AoABlocks.DISTILLER);
AoABlocks.register("synthesis_table", AoABlocks.SYNTHESIZER);
AoABlocks.register("projection_altar", AoABlocks.PROJECTOR);
AoABlocks.register("calcination_furnace_plus", AoABlocks.CALCINATOR_PLUS);
AoABlocks.register("dissolution_chamber_plus", AoABlocks.DISSOLVER_PLUS);
AoABlocks.register("synthesis_table_plus", AoABlocks.SYNTHESIZER_PLUS);
AoABlocks.register("astrological_centrifuge", AoABlocks.ASTRO_CENTRIFUGE);
AoABlocks.register("elemental_centrifuge", AoABlocks.ELEMENT_CENTRIFUGE);
AoABlocks.register("essentia_tank", AoABlocks.TANK);
AoABlocks.register("essentia_pipe", AoABlocks.PIPE);

AoABlocks.registerItemless("alkahest", AoABlocks.ALKAHEST);

// Register materia dusts
for (MateriaRank rank : MateriaRank.values()) {
String name = "materia_block_" + rank.toString().toLowerCase();
BlockMateria block = new BlockMateria(rank);
MATERIA_BLOCKS.put(rank, registerItemless(name, block));
for (final MateriaRank rank : MateriaRank.values()) {
final String name = "materia_block_" + rank.toString().toLowerCase();
final BlockMateria block = new BlockMateria(rank);
AoABlocks.MATERIA_BLOCKS.put(rank, AoABlocks.registerItemless(name, block));
AoAItems.register(name, new BlockItemMateria(block, AoAItems.defaults()));
}

// Register essentia fluid blocks; add-on essentia fluids will be registered to THEIR namespace
RegistryEssentia.INSTANCE.forEach((Essentia essentia, Identifier id) -> {
Identifier blockId = new Identifier(id.getNamespace(), "essentia_" + id.getPath());
ESSENTIA.put(essentia, registerItemless(blockId, new BlockEssentia(essentia)));
// Register essentia fluid blocks; add-on essentia fluids will be registered to
// THEIR namespace
RegistryEssentia.INSTANCE.forEach((essentia, id) -> {
final Identifier blockId = new Identifier(id.getNamespace(), "essentia_" + id.getPath());
AoABlocks.ESSENTIA.put(essentia, AoABlocks.registerItemless(blockId, new BlockEssentia(essentia)));
});
}


public static Block register(String name, Block block) {
AoAItems.register(name, new BlockItem(block, AoAItems.defaults()));
return registerItemless(name, block);
}

public static Block registerItemless(String name, Block block) {
return registerItemless(ArtOfAlchemy.id(name), block);
public static Block registerItemless(final Identifier id, final Block block) {
return Registry.register(Registry.BLOCK, id, block);
}

public static Block registerItemless(Identifier id, Block block) {
return Registry.register(Registry.BLOCK, id, block);
public static Block registerItemless(final String name, final Block block) {
return AoABlocks.registerItemless(ArtOfAlchemy.id(name), block);
}

}
24 changes: 11 additions & 13 deletions src/main/java/dev/cafeteria/artofalchemy/block/BlockAlkahest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.Random;

import dev.cafeteria.artofalchemy.fluid.AoAFluids;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
Expand All @@ -17,28 +16,27 @@

public class BlockAlkahest extends FluidBlock {

public static final Settings SETTINGS = Settings.copy(Blocks.WATER)
.luminance((state) -> 9);
public static final Settings SETTINGS = Settings.copy(Blocks.WATER).luminance(state -> 9);

public BlockAlkahest() {
super(AoAFluids.ALKAHEST, SETTINGS);
super(AoAFluids.ALKAHEST, BlockAlkahest.SETTINGS);
}

@Override
public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) {
public void onEntityCollision(final BlockState state, final World world, final BlockPos pos, final Entity entity) {
entity.damage(DamageSource.MAGIC, 2);
// world.playSound(entity.getX(), entity.getY(), entity.getZ(), SoundEvents.ENTITY_GENERIC_BURN,
// entity.getSoundCategory(), 1.0F, 1.0F, false);
world.addParticle(ParticleTypes.LARGE_SMOKE, entity.getX(), entity.getY(), entity.getZ(),
0.0D, 0.0D, 0.0D);
// world.playSound(entity.getX(), entity.getY(), entity.getZ(),
// SoundEvents.ENTITY_GENERIC_BURN,
// entity.getSoundCategory(), 1.0F, 1.0F, false);
world.addParticle(ParticleTypes.LARGE_SMOKE, entity.getX(), entity.getY(), entity.getZ(), 0.0D, 0.0D, 0.0D);
}

@Override
@Environment(EnvType.CLIENT)
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
double x = pos.getX() + random.nextDouble();
double y = pos.getY() + random.nextDouble();
double z = pos.getZ() + random.nextDouble();
public void randomDisplayTick(final BlockState state, final World world, final BlockPos pos, final Random random) {
final double x = pos.getX() + random.nextDouble();
final double y = pos.getY() + random.nextDouble();
final double z = pos.getZ() + random.nextDouble();
world.addParticle(ParticleTypes.SMOKE, x, y, z, 0.0D, 0.0D, 0.0D);
super.randomDisplayTick(state, world, pos, random);
}
Expand Down
Loading

0 comments on commit 64e9fd9

Please sign in to comment.