Skip to content

Commit

Permalink
Merge pull request #23 from SynthRose/0.5.0
Browse files Browse the repository at this point in the history
0.5.0: Magnum Opus
  • Loading branch information
SynthRose authored Apr 10, 2020
2 parents 75ec4f9 + b26c4f3 commit 8013344
Show file tree
Hide file tree
Showing 137 changed files with 1,671 additions and 180 deletions.
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
org.gradle.jvmargs = -Xmx1G

#Fabric properties
minecraft_version = 20w14a
yarn_mappings = 20w14a+build.9
minecraft_version = 20w15a
yarn_mappings = 20w15a+build.4
loader_version = 0.8.2+build.194

#Mod properties
mod_version = 0.4.0
mod_version = 0.5.0
maven_group = io.github.synthrose.artofalchemy
archives_base_name = artofalchemy

#Dependencies
fabric_api_version = 0.5.8+build.316-1.16
libgui_version = 1.8.0+20w12a
modmenu_version = 1.11.0+build.2
fabric_api_version = 0.5.9+build.319-1.16
libgui_version = 1.8.1+20w15a
modmenu_version = 1.11.1+build.3
46 changes: 46 additions & 0 deletions src/main/java/io/github/synthrose/artofalchemy/ArtOfAlchemy.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,22 @@
import io.github.synthrose.artofalchemy.fluid.AoAFluids;
import io.github.synthrose.artofalchemy.gui.controller.AoAContainers;
import io.github.synthrose.artofalchemy.item.AoAItems;
import io.github.synthrose.artofalchemy.item.ItemAlchemyFormula;
import io.github.synthrose.artofalchemy.network.AoANetworking;
import io.github.synthrose.artofalchemy.recipe.AoARecipes;
import io.github.synthrose.artofalchemy.transport.EssentiaNetworker;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.event.world.WorldTickCallback;
import net.fabricmc.fabric.api.loot.v1.FabricLootPoolBuilder;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.ConstantLootTableRange;
import net.minecraft.loot.LootTables;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.loot.function.LootFunction;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.Level;
Expand All @@ -31,6 +39,21 @@ public class ArtOfAlchemy implements ModInitializer {
public static final ItemGroup ALCHEMY_GROUP = FabricItemGroupBuilder.create(ArtOfAlchemy.id("alchemy"))
.icon(() -> new ItemStack(AoAItems.MYSTERIOUS_SIGIL)).build();

public static final Identifier[] LOOT_TABLES = new Identifier[]{
LootTables.SIMPLE_DUNGEON_CHEST,
LootTables.END_CITY_TREASURE_CHEST,
LootTables.NETHER_BRIDGE_CHEST,
LootTables.ABANDONED_MINESHAFT_CHEST,
LootTables.SHIPWRECK_TREASURE_CHEST,
LootTables.DESERT_PYRAMID_CHEST,
LootTables.JUNGLE_TEMPLE_CHEST,
LootTables.STRONGHOLD_LIBRARY_CHEST,
LootTables.PILLAGER_OUTPOST_CHEST,
LootTables.WOODLAND_MANSION_CHEST,
LootTables.BURIED_TREASURE_CHEST,
LootTables.FISHING_TREASURE_GAMEPLAY
};

@Override
public void onInitialize() {
log(Level.INFO, "Humankind cannot gain anything without first giving something in return. "
Expand All @@ -50,6 +73,29 @@ public void onInitialize() {
EssentiaNetworker.get((ServerWorld) world).tick();
}
});
// Thanks, TheBrokenRail!
LootTableLoadingCallback.EVENT.register((resourceManager, lootManager, id, supplier, setter) -> {
if (isSelectedLootTable(id)) {
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder()
.withRolls(new ConstantLootTableRange(1))
.withEntry(ItemEntry.builder(AoAItems.ALCHEMY_FORMULA))
.withFunction((stack, ctx) -> {
ItemAlchemyFormula.setFormula(stack, AoAItems.PHILOSOPHERS_STONE);
return stack;
});
supplier.withPool(poolBuilder);
}
});

}

private boolean isSelectedLootTable(Identifier lootTable) {
for (Identifier id : LOOT_TABLES) {
if (id.equals(lootTable)) {
return true;
}
}
return false;
}

public static Identifier id(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
import java.util.Map;

public class AoABlocks {


public static final Block ANALYZER = new BlockAnalyzer();
public static final Block CALCINATOR = new BlockCalcinator();
public static final Block DISSOLVER = new BlockDissolver();
public static final Block SYNTHESIZER = new BlockSynthesizer();
public static final Block ANALYZER = new BlockAnalyzer();
public static final Block PROJECTOR = new BlockProjector();
public static final Block CALCINATOR_PLUS = new BlockCalcinatorPlus();
public static final Block DISSOLVER_PLUS = new BlockDissolverPlus();
public static final Block SYNTHESIZER_PLUS = new BlockSynthesizerPlus();
public static final Block ASTRO_CENTRIFUGE = new BlockAstroCentrifuge();
public static final Block ELEMENT_CENTRIFUGE = new BlockElementCentrifuge();
public static final Block PIPE = new BlockPipe();
Expand All @@ -31,10 +35,14 @@ public class AoABlocks {
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("synthesis_table", SYNTHESIZER);
register("analysis_desk", ANALYZER);
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ public static Identifier getId() {
}

public BlockCalcinator() {
super(SETTINGS);
this(SETTINGS);
}

protected BlockCalcinator(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(FACING, Direction.NORTH).with(LIT, false));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.github.synthrose.artofalchemy.block;

import io.github.synthrose.artofalchemy.blockentity.BlockEntityCalcinatorPlus;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;

public class BlockCalcinatorPlus extends BlockCalcinator {

public static final Settings SETTINGS = Settings
.of(Material.METAL).sounds(BlockSoundGroup.METAL)
.strength(5.0f, 6.0f)
.lightLevel((state) -> state.get(LIT) ? 15 : 0)
.nonOpaque();

public static Identifier getId() {
return Registry.BLOCK.getId(AoABlocks.CALCINATOR_PLUS);
}

public BlockCalcinatorPlus() {
super(SETTINGS);
}

@Override
public BlockEntity createBlockEntity(BlockView world) {
return new BlockEntityCalcinatorPlus();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public static Identifier getId() {
}

public BlockDissolver() {
super(SETTINGS);
this(SETTINGS);
}

protected BlockDissolver(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(FILLED, false).with(LIT, false));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.github.synthrose.artofalchemy.block;

import io.github.synthrose.artofalchemy.blockentity.BlockEntityDissolverPlus;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;

public class BlockDissolverPlus extends BlockDissolver {

public static final Settings SETTINGS = Settings
.of(Material.METAL)
.strength(5.0f, 6.0f)
.lightLevel((state) -> state.get(LIT) ? 15 : 0)
.nonOpaque();

public static Identifier getId() {
return Registry.BLOCK.getId(AoABlocks.DISSOLVER_PLUS);
}

public BlockDissolverPlus() {
super(SETTINGS);
}

@Override
public BlockEntity createBlockEntity(BlockView world) {
return new BlockEntityDissolverPlus();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package io.github.synthrose.artofalchemy.block;

import io.github.synthrose.artofalchemy.blockentity.BlockEntityProjector;
import io.github.synthrose.artofalchemy.item.AoAItems;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.StateManager.Builder;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;

public class BlockProjector extends Block implements BlockEntityProvider {

public static final BooleanProperty LIT = Properties.LIT;
public static final Settings SETTINGS = Settings
.of(Material.METAL).sounds(BlockSoundGroup.METAL)
.strength(5.0f, 6.0f)
.lightLevel((state) -> state.get(LIT) ? 15 : 0)
.nonOpaque();

public static Identifier getId() {
return Registry.BLOCK.getId(AoABlocks.PROJECTOR);
}

public BlockProjector() {
this(SETTINGS);
}

protected BlockProjector(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(LIT, false));
}

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

@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return super.getPlacementState(ctx);
}

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand,
BlockHitResult hit) {

ItemStack inHand = player.getStackInHand(hand);

BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof BlockEntityProjector) {
BlockEntityProjector projector = (BlockEntityProjector) blockEntity;
if (inHand.getItem() == AoAItems.ALKAHEST_BUCKET && projector.addAlkahest(1000)) {
if (!player.abilities.creativeMode) {
player.setStackInHand(hand, new ItemStack(Items.BUCKET));
}
world.playSound(null, pos, SoundEvents.ITEM_BUCKET_EMPTY,
SoundCategory.BLOCKS, 1.0F, 1.0F);
return ActionResult.SUCCESS;
}
if (!world.isClient()) {
ContainerProviderRegistry.INSTANCE.openContainer(getId(), player,
(packetByteBuf -> packetByteBuf.writeBlockPos(pos)));
}
return ActionResult.SUCCESS;
} else {
return ActionResult.PASS;
}

}

@Override
public BlockEntity createBlockEntity(BlockView world) {
return new BlockEntityProjector();
}

@Override
public void onBlockRemoved(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
if (state.getBlock() != newState.getBlock()) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity instanceof BlockEntityProjector) {
ItemScatterer.spawn(world, pos, (Inventory) blockEntity);
}

super.onBlockRemoved(state, world, pos, newState, moved);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public static Identifier getId() {
}

public BlockSynthesizer() {
super(SETTINGS);
this(SETTINGS);
}

protected BlockSynthesizer(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(LIT, false));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.github.synthrose.artofalchemy.block;

import io.github.synthrose.artofalchemy.blockentity.BlockEntityDissolverPlus;
import io.github.synthrose.artofalchemy.blockentity.BlockEntitySynthesizerPlus;
import net.minecraft.block.Material;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.BlockView;

public class BlockSynthesizerPlus extends BlockSynthesizer {

public static final Settings SETTINGS = Settings
.of(Material.METAL)
.strength(5.0f, 6.0f)
.lightLevel((state) -> state.get(LIT) ? 15 : 0)
.nonOpaque();

public static Identifier getId() {
return Registry.BLOCK.getId(AoABlocks.SYNTHESIZER_PLUS);
}

public BlockSynthesizerPlus() {
super(SETTINGS);
}

@Override
public BlockEntity createBlockEntity(BlockView world) {
return new BlockEntitySynthesizerPlus();
}

}
Loading

0 comments on commit 8013344

Please sign in to comment.