Skip to content

Commit 9e3bb13

Browse files
committed
0.1.0d
* Config * Passways and tables
1 parent 8127a78 commit 9e3bb13

File tree

21 files changed

+380
-140
lines changed

21 files changed

+380
-140
lines changed

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ repositories {
3232
maven {
3333
url "https://maven.tterrag.com/"
3434
}
35+
maven {
36+
url "https://maven.shedaniel.me/"
37+
}
3538
}
3639

3740
dependencies {
@@ -68,6 +71,8 @@ dependencies {
6871
modImplementation "com.simibubi.create:Create:mc${project.create_version}"
6972
modImplementation "com.jozufozu.flywheel:Flywheel-Forge:${project.flywheel_version}"
7073
modImplementation "com.tterrag.registrate:Registrate:MC${project.minecraft_version}-${project.registrate_version}"
74+
75+
modImplementation include("me.shedaniel.cloth:cloth-config-forge:6.4.90")
7176
}
7277

7378
processResources {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ loom.platform=forge
1616
yarn_mappings=1.18.2+build.4
1717

1818
# Mod Properties
19-
mod_version=0.1.0c.rev1
19+
mod_version=0.1.0d
2020
maven_group=io.github.dovecotmc
2121
archives_base_name=LeadBeyond
2222
mod_id=lead_beyond

src/main/java/io/github/dovecotmc/leadbeyond/LeadBeyond.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package io.github.dovecotmc.leadbeyond;
22

3-
import io.github.dovecotmc.leadbeyond.common.reg.*;
3+
import io.github.dovecotmc.leadbeyond.common.config.LBConfig;
4+
import io.github.dovecotmc.leadbeyond.common.reg.BlockEntityReg;
5+
import io.github.dovecotmc.leadbeyond.common.reg.BlockReg;
6+
import io.github.dovecotmc.leadbeyond.common.reg.ItemReg;
7+
import io.github.dovecotmc.leadbeyond.common.reg.SoundReg;
8+
import me.shedaniel.autoconfig.AutoConfig;
9+
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
410
import net.minecraft.util.Identifier;
511
import net.minecraftforge.common.MinecraftForge;
612
import net.minecraftforge.eventbus.api.IEventBus;
@@ -18,6 +24,7 @@
1824
public class LeadBeyond {
1925
public static final String MODID = "lead_beyond";
2026
public static final Logger LOGGER = LoggerFactory.getLogger("Lead Beyond");
27+
public static LBConfig CONFIG;
2128

2229
public LeadBeyond() {
2330
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
@@ -27,6 +34,8 @@ public LeadBeyond() {
2734
BlockEntityReg.BLOCK_ENTITIES.register(eventBus);
2835
eventBus.addListener(this::commonSetup);
2936
eventBus.addListener(LeadBeyondClient::clientSetup);
37+
AutoConfig.register(LBConfig.class, Toml4jConfigSerializer::new);
38+
CONFIG = AutoConfig.getConfigHolder(LBConfig.class).getConfig();
3039
MinecraftForge.EVENT_BUS.register(this);
3140
LOGGER.info("Initialized.");
3241
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package io.github.dovecotmc.leadbeyond.common;
2+
3+
import io.github.dovecotmc.leadbeyond.LeadBeyond;
4+
import net.minecraft.item.Item;
5+
import net.minecraft.item.Items;
6+
import net.minecraft.util.Identifier;
7+
import net.minecraft.util.registry.Registry;
8+
import net.minecraft.util.shape.VoxelShape;
9+
import net.minecraft.util.shape.VoxelShapes;
10+
11+
public class Constants {
12+
public static final VoxelShape YZ_NS_SHAPE = VoxelShapes.union(VoxelShapes.cuboid(0.125, 0, 0.5625, 0.1875, 0.25, 0.8125),
13+
VoxelShapes.cuboid(0.125, 0, 0.1875, 0.1875, 0.25, 0.4375),
14+
VoxelShapes.cuboid(0.125, 0, 0.1875, 0.1875, 0.25, 0.4375),
15+
VoxelShapes.cuboid(0.8125, 0, 0.1875, 0.875, 0.25, 0.4375),
16+
VoxelShapes.cuboid(0.8125, 0, 0.5625, 0.875, 0.25, 0.8125),
17+
VoxelShapes.cuboid(0, 0.25, 0, 1, 0.5, 1),
18+
VoxelShapes.cuboid(0, 0.5, 0.375, 0.5, 1.4375, 0.625),
19+
VoxelShapes.cuboid(0.53125, 0.5, 0.375, 1, 1.4375, 0.625));
20+
public static final VoxelShape YZ_EW_SHAPE = VoxelShapes.union(VoxelShapes.cuboid(0.1875, 0, 0.125, 0.4375, 0.25, 0.1875),
21+
VoxelShapes.cuboid(0.5625, 0, 0.125, 0.8125, 0.25, 0.1875),
22+
VoxelShapes.cuboid(0.5625, 0, 0.8125, 0.8125, 0.25, 0.875),
23+
VoxelShapes.cuboid(0.1875, 0, 0.8125, 0.4375, 0.25, 0.875),
24+
VoxelShapes.cuboid(0, 0.25, 0, 1, 0.5, 1),
25+
VoxelShapes.cuboid(0.375, 0.5, 0, 0.625, 1.4375, 0.5),
26+
VoxelShapes.cuboid(0.375, 0.5, 0.53125, 0.625, 1.4375, 1));
27+
28+
public static final VoxelShape PASSWAY_NS_SHAPE = VoxelShapes.union(VoxelShapes.cuboid(-0.125, -0.25, 0, 1.125, -0.125, 1),
29+
VoxelShapes.cuboid(-0.125, 1.875, 0, 1.125, 2, 1),
30+
VoxelShapes.cuboid(1, -0.125, 0, 1.125, 1.875, 1),
31+
VoxelShapes.cuboid(-0.125, -0.125, 0, 0, 1.875, 1));
32+
public static final VoxelShape PASSWAY_EW_SHAPE = VoxelShapes.union(VoxelShapes.cuboid(0, -0.25, -0.125, 1, -0.125, 1.125),
33+
VoxelShapes.cuboid(0, 1.875, -0.125, 1, 2, 1.125),
34+
VoxelShapes.cuboid(0, -0.125, 1, 1, 1.875, 1.125),
35+
VoxelShapes.cuboid(0, -0.125, -0.125, 1, 1.875, 0));
36+
37+
public static Item getCurrencyItem() {
38+
Item ret = Registry.ITEM.get(new Identifier(LeadBeyond.CONFIG.currencyItemId));
39+
return ret == Items.AIR ? Items.EMERALD : ret;
40+
}
41+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package io.github.dovecotmc.leadbeyond.common.block;
2+
3+
import net.minecraft.block.BlockState;
4+
import net.minecraft.item.ItemPlacementContext;
5+
import net.minecraft.util.math.BlockPos;
6+
import net.minecraft.util.math.Direction;
7+
import net.minecraft.util.shape.VoxelShape;
8+
import net.minecraft.world.WorldView;
9+
10+
import javax.annotation.Nullable;
11+
import java.util.function.Function;
12+
13+
public class DirAwareHorizontalCVSBlock extends HorizontalCVSBlock {
14+
public DirAwareHorizontalCVSBlock(Settings settings, Function<BlockState, VoxelShape> shape) {
15+
super(settings, shape);
16+
}
17+
18+
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
19+
Direction direction = state.get(FACING);
20+
BlockPos blockPos = pos.offset(direction.getOpposite());
21+
BlockState blockState = world.getBlockState(blockPos);
22+
return blockState.isSideSolidFullSquare(world, blockPos, direction);
23+
}
24+
25+
@Nullable
26+
public BlockState getPlacementState(ItemPlacementContext ctx) {
27+
BlockState blockState = this.getDefaultState();
28+
WorldView worldView = ctx.getWorld();
29+
BlockPos blockPos = ctx.getBlockPos();
30+
Direction[] directions = ctx.getPlacementDirections();
31+
for (Direction direction : directions) {
32+
if (direction.getAxis().isHorizontal()) {
33+
Direction direction2 = direction.getOpposite();
34+
blockState = blockState.with(FACING, direction2);
35+
if (blockState.canPlaceAt(worldView, blockPos)) {
36+
return blockState;
37+
}
38+
}
39+
}
40+
return null;
41+
}
42+
}

src/main/java/io/github/dovecotmc/leadbeyond/common/block/TicketVendorBlock.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
package io.github.dovecotmc.leadbeyond.common.block;
22

33
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
4+
import io.github.dovecotmc.leadbeyond.LeadBeyond;
5+
import io.github.dovecotmc.leadbeyond.common.Constants;
46
import io.github.dovecotmc.leadbeyond.common.item.CardItem;
57
import io.github.dovecotmc.leadbeyond.common.reg.ItemReg;
68
import io.github.dovecotmc.leadbeyond.common.reg.SoundReg;
7-
import net.minecraft.block.*;
9+
import net.minecraft.block.Block;
10+
import net.minecraft.block.BlockState;
11+
import net.minecraft.block.HorizontalFacingBlock;
12+
import net.minecraft.block.ShapeContext;
813
import net.minecraft.entity.player.PlayerEntity;
914
import net.minecraft.item.ItemPlacementContext;
1015
import net.minecraft.item.ItemStack;
@@ -60,8 +65,8 @@ public BlockState getPlacementState(ItemPlacementContext ctx) {
6065
@Override
6166
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
6267
if (world.isClient()) return ActionResult.SUCCESS;
63-
if (player.getStackInHand(hand).isOf(Items.EMERALD)) {
64-
player.getStackInHand(hand).decrement(1);
68+
if (player.getStackInHand(hand).isOf(Constants.getCurrencyItem())) {
69+
if (!player.isCreative()) player.getStackInHand(hand).decrement(1);
6570
if (getStackInOtherHand(player, hand).getItem() instanceof CardItem) {
6671
world.playSound(null, pos, SoundReg.BEEP_TICKET_VENDOR.get(), SoundCategory.BLOCKS, 1f, 1f);
6772
NbtCompound nbt = getStackInOtherHand(player, hand).getOrCreateSubNbt("cardInfo");

src/main/java/io/github/dovecotmc/leadbeyond/common/block/TurnstileBlock.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.github.dovecotmc.leadbeyond.common.block;
22

33
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
4-
import com.simibubi.create.content.contraptions.wrench.WrenchItem;
54
import io.github.dovecotmc.leadbeyond.common.item.CardItem;
65
import io.github.dovecotmc.leadbeyond.common.item.TicketItem;
76
import io.github.dovecotmc.leadbeyond.common.item.Ticketable;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.github.dovecotmc.leadbeyond.common.config;
2+
3+
import me.shedaniel.autoconfig.ConfigData;
4+
import me.shedaniel.autoconfig.annotation.Config;
5+
6+
@Config(name = "lead_beyond")
7+
public class LBConfig implements ConfigData {
8+
public String currencyItemId = "minecraft:emerald";
9+
}
Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,17 @@
11
package io.github.dovecotmc.leadbeyond.common.reg;
22

33
import io.github.dovecotmc.leadbeyond.LeadBeyond;
4-
import io.github.dovecotmc.leadbeyond.common.block.HorizontalCVSBlock;
5-
import io.github.dovecotmc.leadbeyond.common.block.LBSeatBlock;
6-
import io.github.dovecotmc.leadbeyond.common.block.TicketVendorBlock;
7-
import io.github.dovecotmc.leadbeyond.common.block.TurnstileBlock;
4+
import io.github.dovecotmc.leadbeyond.common.Constants;
5+
import io.github.dovecotmc.leadbeyond.common.block.*;
86
import net.minecraft.block.AbstractBlock;
97
import net.minecraft.block.Block;
108
import net.minecraft.block.Blocks;
11-
import net.minecraft.util.shape.VoxelShape;
129
import net.minecraft.util.shape.VoxelShapes;
1310
import net.minecraftforge.registries.DeferredRegister;
1411
import net.minecraftforge.registries.ForgeRegistries;
1512
import net.minecraftforge.registries.RegistryObject;
1613

1714
public class BlockReg {
18-
public static final VoxelShape yzNsShape = VoxelShapes.union(VoxelShapes.cuboid(0.125, 0, 0.5625, 0.1875, 0.25, 0.8125),
19-
VoxelShapes.cuboid(0.125, 0, 0.1875, 0.1875, 0.25, 0.4375),
20-
VoxelShapes.cuboid(0.125, 0, 0.1875, 0.1875, 0.25, 0.4375),
21-
VoxelShapes.cuboid(0.8125, 0, 0.1875, 0.875, 0.25, 0.4375),
22-
VoxelShapes.cuboid(0.8125, 0, 0.5625, 0.875, 0.25, 0.8125),
23-
VoxelShapes.cuboid(0, 0.25, 0, 1, 0.5, 1),
24-
VoxelShapes.cuboid(0, 0.5, 0.375, 0.5, 1.4375, 0.625),
25-
VoxelShapes.cuboid(0.53125, 0.5, 0.375, 1, 1.4375, 0.625));
26-
public static final VoxelShape yzEwShape = VoxelShapes.union(VoxelShapes.cuboid(0.1875, 0, 0.125, 0.4375, 0.25, 0.1875),
27-
VoxelShapes.cuboid(0.5625, 0, 0.125, 0.8125, 0.25, 0.1875),
28-
VoxelShapes.cuboid(0.5625, 0, 0.8125, 0.8125, 0.25, 0.875),
29-
VoxelShapes.cuboid(0.1875, 0, 0.8125, 0.4375, 0.25, 0.875),
30-
VoxelShapes.cuboid(0, 0.25, 0, 1, 0.5, 1),
31-
VoxelShapes.cuboid(0.375, 0.5, 0, 0.625, 1.4375, 0.5),
32-
VoxelShapes.cuboid(0.375, 0.5, 0.53125, 0.625, 1.4375, 1));
33-
3415
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS,
3516
LeadBeyond.MODID);
3617

@@ -43,9 +24,21 @@ public class BlockReg {
4324
public static final RegistryObject<Block> YZ_SEAT2 = BLOCKS.register("yz_seat2", () ->
4425
new HorizontalCVSBlock(AbstractBlock.Settings.copy(Blocks.BLUE_WOOL), state -> switch (state.get(HorizontalCVSBlock.FACING)) {
4526
default -> VoxelShapes.fullCube();
46-
case NORTH, SOUTH -> yzNsShape;
47-
case WEST, EAST -> yzEwShape;
27+
case NORTH, SOUTH -> Constants.YZ_NS_SHAPE;
28+
case WEST, EAST -> Constants.YZ_EW_SHAPE;
29+
}));
30+
public static final RegistryObject<Block> PASSWAY = BLOCKS.register("passway", () ->
31+
new HorizontalCVSBlock(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK), state -> switch (state.get(HorizontalCVSBlock.FACING)) {
32+
default -> VoxelShapes.fullCube();
33+
case NORTH, SOUTH -> Constants.PASSWAY_NS_SHAPE;
34+
case WEST, EAST -> Constants.PASSWAY_EW_SHAPE;
35+
}));
36+
public static final RegistryObject<Block> YZ_TABLE = BLOCKS.register("yz_table", () ->
37+
new DirAwareHorizontalCVSBlock(AbstractBlock.Settings.copy(Blocks.OAK_PLANKS), state -> switch (state.get(HorizontalCVSBlock.FACING)) {
38+
default -> VoxelShapes.fullCube();
39+
case NORTH -> Block.createCuboidShape(2, 14, 2, 14, 15, 16);
40+
case SOUTH -> Block.createCuboidShape(2, 14, 0, 14, 15, 14);
41+
case EAST -> Block.createCuboidShape(0, 14, 2, 14, 15, 14);
42+
case WEST -> Block.createCuboidShape(2, 14, 2, 16, 15, 14);
4843
}));
49-
50-
5144
}

src/main/java/io/github/dovecotmc/leadbeyond/common/reg/ItemReg.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ public class ItemReg {
2626
new BlockItem(BlockReg.RZ_SEAT.get(), new Item.Settings().group(LBItemGroup.INSTANCE)));
2727
public static final RegistryObject<Item> YZ_SEAT2 = ITEM.register("yz_seat2", () ->
2828
new BlockItem(BlockReg.YZ_SEAT2.get(), new Item.Settings().group(LBItemGroup.INSTANCE)));
29+
public static final RegistryObject<Item> PASSWAY = ITEM.register("passway", () ->
30+
new BlockItem(BlockReg.PASSWAY.get(), new Item.Settings().group(LBItemGroup.INSTANCE)));
31+
public static final RegistryObject<Item> YZ_TABLE = ITEM.register("yz_table", () ->
32+
new BlockItem(BlockReg.YZ_TABLE.get(), new Item.Settings().group(LBItemGroup.INSTANCE)));
2933
}

0 commit comments

Comments
 (0)