Skip to content

Commit

Permalink
PSD Tianjin Line 9, Updated to MTR beta-9
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiYueCommentary committed Sep 10, 2024
1 parent 728bd25 commit 7bbea7b
Show file tree
Hide file tree
Showing 66 changed files with 2,310 additions and 75 deletions.
1 change: 0 additions & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ dependencies {
String FabricVersion = buildTools.getFabricVersion()
modImplementation "net.fabricmc:fabric-loader:${FabricVersion}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${buildTools.getFabricApiVersion()}"
//modImplementation(files("E:\\Tianjin-Metro\\libs\\MTR-fabric-4.0.0-beta-8+1.16.5-server.jar"))
modApi "com.terraformersmc:modmenu:${buildTools.getModMenuVersion()}"
modApi("ziyue.filters:filters-fabric:${buildTools.getFiltersAPIVersion()}") {
exclude(group: "net.fabricmc")
Expand Down
2 changes: 2 additions & 0 deletions fabric/src/main/java/ziyue/tjmetro/mod/BlockEntityTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ public interface BlockEntityTypes
BlockEntityTypeRegistryObject<BlockAPGDoorTianjinBMT.BlockEntity> APG_DOOR_TIANJIN_BMT = Registry.registerBlockEntityType("apg_door_tianjin_bmt", BlockAPGDoorTianjinBMT.BlockEntity::new, BlockList.APG_DOOR_TIANJIN_BMT_BLOCK::get);
BlockEntityTypeRegistryObject<BlockAPGGlassTianjinBMT.BlockEntity> APG_GLASS_TIANJIN_BMT = Registry.registerBlockEntityType("apg_glass_tianjin_bmt", BlockAPGGlassTianjinBMT.BlockEntity::new, BlockList.APG_GLASS_TIANJIN_BMT_BLOCK::get);
BlockEntityTypeRegistryObject<BlockMetalPoleBMT.BlockEntity> METAL_POLE_BMT = Registry.registerBlockEntityType("metal_pole_bmt", BlockMetalPoleBMT.BlockEntity::new, BlockList.METAL_POLE_BMT::get);
BlockEntityTypeRegistryObject<BlockPSDDoorTianjinBMT.BlockEntity> PSD_DOOR_TIANJIN_BMT = Registry.registerBlockEntityType("psd_door_tianjin_bmt", BlockPSDDoorTianjinBMT.BlockEntity::new, BlockList.PSD_DOOR_TIANJIN_BMT_BLOCK::get);
BlockEntityTypeRegistryObject<BlockPSDTopTianjinBMT.BlockEntity> PSD_TOP_TIANJIN_BMT = Registry.registerBlockEntityType("psd_top_tianjin_bmt", BlockPSDTopTianjinBMT.BlockEntity::new, BlockList.PSD_TOP_TIANJIN_BMT::get);

static void registerBlockEntities() {
// Calling this class to initialize constants
Expand Down
4 changes: 4 additions & 0 deletions fabric/src/main/java/ziyue/tjmetro/mod/BlockList.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ public interface BlockList
BlockRegistryObject APG_GLASS_TIANJIN_BMT_BLOCK = Registry.registerBlock("apg_glass_tianjin_bmt", () -> new Block(new BlockAPGGlassTianjinBMT()));
BlockRegistryObject APG_GLASS_END_TIANJIN_BMT_BLOCK = Registry.registerBlock("apg_glass_end_tianjin_bmt", () -> new Block(new BlockAPGGlassEndTianjinBMT()));
BlockRegistryObject METAL_POLE_BMT = Registry.registerBlockWithBlockItem("metal_pole_bmt", () -> new Block(new BlockMetalPoleBMT()), BlockItemExtension::new, CreativeModeTabs.TIANJIN_METRO);
BlockRegistryObject PSD_DOOR_TIANJIN_BMT_BLOCK = Registry.registerBlock("psd_door_tianjin_bmt", () -> new Block(new BlockPSDDoorTianjinBMT()));
BlockRegistryObject PSD_GLASS_TIANJIN_BMT_BLOCK = Registry.registerBlock("psd_glass_tianjin_bmt", () -> new Block(new BlockPSDGlassTianjinBMT()));
BlockRegistryObject PSD_GLASS_END_TIANJIN_BMT_BLOCK = Registry.registerBlock("psd_glass_end_tianjin_bmt", () -> new Block(new BlockPSDGlassEndTianjinBMT()));
BlockRegistryObject PSD_TOP_TIANJIN_BMT = Registry.registerBlock("psd_top_tianjin_bmt", () -> new Block(new BlockPSDTopTianjinBMT()));

static void registerBlocks() {
// Calling this class to initialize constants
Expand Down
3 changes: 3 additions & 0 deletions fabric/src/main/java/ziyue/tjmetro/mod/ItemList.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public interface ItemList
ItemRegistryObject APG_DOOR_TIANJIN_BMT = Registry.registerItem("apg_door_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_DOOR_TIANJIN_BMT_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO);
ItemRegistryObject APG_GLASS_TIANJIN_BMT = Registry.registerItem("apg_glass_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_GLASS_TIANJIN_BMT_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO);
ItemRegistryObject APG_GLASS_END_TIANJIN_BMT = Registry.registerItem("apg_glass_end_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.APG_GLASS_END_TIANJIN_BMT_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO);
ItemRegistryObject PSD_DOOR_TIANJIN_BMT = Registry.registerItem("psd_door_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.PSD_DOOR_TIANJIN_BMT_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO);
ItemRegistryObject PSD_GLASS_TIANJIN_BMT = Registry.registerItem("psd_glass_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.PSD_GLASS_TIANJIN_BMT_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO);
ItemRegistryObject PSD_GLASS_END_TIANJIN_BMT = Registry.registerItem("psd_glass_end_tianjin_bmt", itemSettings -> new Item(new ItemPSDAPGTianjinBase(BlockList.PSD_GLASS_END_TIANJIN_BMT_BLOCK, itemSettings)), CreativeModeTabs.TIANJIN_METRO);

static void registerItems() {
// Calling this class to initialize constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public static void init() {
RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_GLASS_TIANJIN_BMT_BLOCK);
RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.APG_GLASS_END_TIANJIN_BMT_BLOCK);
RegistryClient.registerBlockRenderType(RenderLayer.getTranslucent(), BlockList.ROLLING);
RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_DOOR_TIANJIN_BMT_BLOCK);
RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_GLASS_TIANJIN_BMT_BLOCK);
RegistryClient.registerBlockRenderType(RenderLayer.getCutout(), BlockList.PSD_GLASS_END_TIANJIN_BMT_BLOCK);

RegistryClient.registerBlockEntityRenderer(BlockEntityTypes.STATION_NAME_SIGN_1, RenderStationNameSign::new);
RegistryClient.registerBlockEntityRenderer(BlockEntityTypes.STATION_NAME_SIGN_2, RenderStationNameSign::new);
Expand Down Expand Up @@ -89,6 +92,8 @@ public static void init() {
RegistryClient.registerBlockEntityRenderer(BlockEntityTypes.APG_DOOR_TIANJIN, dispatcher -> new RenderPSDAPGDoor<>(dispatcher, 2));
RegistryClient.registerBlockEntityRenderer(BlockEntityTypes.APG_DOOR_TIANJIN_BMT, dispatcher -> new RenderPSDAPGDoor<>(dispatcher, 2));
RegistryClient.registerBlockEntityRenderer(BlockEntityTypes.APG_GLASS_TIANJIN_BMT, RenderAPGGlassTianjinBMT::new);
RegistryClient.registerBlockEntityRenderer(BlockEntityTypes.PSD_TOP_TIANJIN_BMT, RenderPSDTopTianjinBMT::new);
RegistryClient.registerBlockEntityRenderer(BlockEntityTypes.PSD_DOOR_TIANJIN_BMT, RenderPSDTianjinBMTDoor::new);

RegistryClient.registerEntityRenderer(EntityTypes.SEAT, RenderSeat::new);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package ziyue.tjmetro.mod.block;

import org.mtr.mapping.holder.BlockPos;
import org.mtr.mapping.holder.BlockState;
import org.mtr.mapping.holder.Item;
import org.mtr.mapping.mapper.BlockEntityExtension;
import org.mtr.mod.block.BlockPSDAPGDoorBase;
import ziyue.tjmetro.mod.BlockEntityTypes;
import ziyue.tjmetro.mod.ItemList;
import ziyue.tjmetro.mod.block.base.BlockFlagPSDTianjinBMT;

import javax.annotation.Nonnull;

/**
* @author ZiYueCommentary
* @see org.mtr.mod.block.BlockPSDDoor
* @see ziyue.tjmetro.mod.item.ItemPSDAPGTianjinBase
* @see BlockEntity
* @since 1.0.0-beta-2
*/

public class BlockPSDDoorTianjinBMT extends BlockPSDAPGDoorBase implements BlockFlagPSDTianjinBMT
{
@Nonnull
@Override
public Item asItem2() {
return ItemList.PSD_DOOR_TIANJIN_BMT.get();
}

@Override
public BlockEntityExtension createBlockEntity(BlockPos blockPos, BlockState blockState) {
return new BlockEntity(blockPos, blockState);
}

/**
* @author ZiYueCommentary
* @see org.mtr.mod.render.RenderPSDAPGDoor
* @since 1.0.0-beta-1
*/
public static class BlockEntity extends BlockEntityBase
{
public BlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityTypes.PSD_DOOR_TIANJIN_BMT.get(), pos, state);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ziyue.tjmetro.mod.block;

import org.mtr.mapping.holder.Item;
import org.mtr.mod.block.BlockPSDAPGGlassEndBase;
import ziyue.tjmetro.mod.ItemList;
import ziyue.tjmetro.mod.block.base.BlockFlagPSDTianjinBMT;

import javax.annotation.Nonnull;

/**
* @author ZiYueCommentary
* @see org.mtr.mod.block.BlockPSDGlassEnd
* @see ziyue.tjmetro.mod.item.ItemPSDAPGTianjinBase
* @since 1.0.0-beta-2
*/

public class BlockPSDGlassEndTianjinBMT extends BlockPSDAPGGlassEndBase implements BlockFlagPSDTianjinBMT
{
@Nonnull
@Override
public Item asItem2() {
return ItemList.PSD_GLASS_END_TIANJIN_BMT.get();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package ziyue.tjmetro.mod.block;

import org.mtr.mapping.holder.Item;
import org.mtr.mod.block.BlockPSDAPGGlassBase;
import ziyue.tjmetro.mod.ItemList;
import ziyue.tjmetro.mod.block.base.BlockFlagPSDTianjinBMT;

import javax.annotation.Nonnull;

/**
* @author ZiYueCommentary
* @see org.mtr.mod.block.BlockPSDGlass
* @see ziyue.tjmetro.mod.item.ItemPSDAPGTianjinBase
* @since 1.0.0-beta-2
*/

public class BlockPSDGlassTianjinBMT extends BlockPSDAPGGlassBase implements BlockFlagPSDTianjinBMT
{
@Nonnull
@Override
public Item asItem2() {
return ItemList.PSD_GLASS_TIANJIN_BMT.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@

public class BlockPSDTopTianjin extends BlockPSDTop implements BlockFlagPSDTianjin
{
public static final EnumProperty<EnumDoorType> STYLE = EnumProperty.of("style", EnumDoorType.class);
public static final EnumProperty<EnumPSDType> STYLE = EnumProperty.of("style", EnumPSDType.class);

@Nonnull
@Override
public ActionResult onUse2(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return IBlock.checkHoldingItem(world, player, item -> {
if (item.data == ItemList.WRENCH.get().data) {
if (BlockList.PSD_DOOR_TIANJIN_BLOCK.get().data == world.getBlockState(pos.down()).getBlock().data) {
world.setBlockState(pos, IBlockExtension.cycleBlockState(state, STYLE, value -> value != EnumDoorType.NEXT_STATION));
world.setBlockState(pos, IBlockExtension.cycleBlockState(state, STYLE, value -> value != EnumPSDType.NEXT_STATION));
BlockPos pos1 = (IBlock.getStatePropertySafe(state, SIDE_EXTENDED) == EnumSide.LEFT) ? pos.offset(IBlock.getStatePropertySafe(state, FACING).rotateYClockwise()) : pos.offset(IBlock.getStatePropertySafe(state, FACING).rotateYCounterclockwise());
world.setBlockState(pos1, IBlockExtension.cycleBlockState(world.getBlockState(pos1), STYLE, value -> value != EnumDoorType.NEXT_STATION));
world.setBlockState(pos1, IBlockExtension.cycleBlockState(world.getBlockState(pos1), STYLE, value -> value != EnumPSDType.NEXT_STATION));
} else {
world.setBlockState(pos, IBlockExtension.cycleBlockState(state, STYLE, EnumDoorType.DEFAULT, EnumDoorType.NEXT_STATION));
world.setBlockState(pos, IBlockExtension.cycleBlockState(state, STYLE, EnumPSDType.DEFAULT, EnumPSDType.NEXT_STATION));
Consumer<Direction> setStyle = direction -> {
EnumDoorType style = IBlock.getStatePropertySafe(world, pos, STYLE);
EnumPSDType style = IBlock.getStatePropertySafe(world, pos, STYLE);
BlockPos offsetPos = pos;
for (; ; ) {
if (BlockList.PSD_DOOR_TIANJIN_BLOCK.get().data == world.getBlockState(offsetPos.down()).getBlock().data) {
offsetPos = offsetPos.offset(direction);
style = (style == EnumDoorType.DEFAULT) ? EnumDoorType.NEXT_STATION : EnumDoorType.DEFAULT;
style = (style == EnumPSDType.DEFAULT) ? EnumPSDType.NEXT_STATION : EnumPSDType.DEFAULT;
} else if (this == world.getBlockState(offsetPos).getBlock().data) {
world.setBlockState(offsetPos, world.getBlockState(offsetPos).with(new Property<>(STYLE.data), style));
} else {
Expand Down Expand Up @@ -156,7 +156,7 @@ public BlockEntity(BlockPos pos, BlockState state) {
}
}

public enum EnumDoorType implements StringIdentifiable
public enum EnumPSDType implements StringIdentifiable
{
DEFAULT("default"),
STATION_NAME("station_name"),
Expand All @@ -167,7 +167,7 @@ public enum EnumDoorType implements StringIdentifiable

final String name;

EnumDoorType(String name) {
EnumPSDType(String name) {
this.name = name;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package ziyue.tjmetro.mod.block;

import org.mtr.mapping.holder.*;
import org.mtr.mapping.mapper.BlockEntityExtension;
import org.mtr.mapping.tool.HolderBase;
import org.mtr.mod.block.BlockPSDAPGBase;
import org.mtr.mod.block.BlockPSDTop;
import org.mtr.mod.block.IBlock;
import ziyue.tjmetro.mod.BlockEntityTypes;
import ziyue.tjmetro.mod.BlockList;
import ziyue.tjmetro.mod.ItemList;
import ziyue.tjmetro.mod.block.base.BlockFlagPSDTianjinBMT;

import javax.annotation.Nonnull;
import java.util.List;

/**
* @author ZiYueCommentary
* @see BlockEntity
* @see BlockPSDTop
* @since 1.0.0-beta-2
*/

public class BlockPSDTopTianjinBMT extends BlockPSDTop implements BlockFlagPSDTianjinBMT
{
public static final IntegerProperty ARROW_DIRECTION = IntegerProperty.of("arrow_direction", 0, 1);
public static final EnumProperty<EnumPSDType> STYLE = EnumProperty.of("style", EnumPSDType.class);

@Nonnull
@Override
public ActionResult onUse2(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
return IBlock.checkHoldingItem(world, player, item -> {
if (item.data == ItemList.WRENCH.get().data) {
world.setBlockState(pos, state.cycle(new Property<>(STYLE.data)));
propagate(world, pos, IBlock.getStatePropertySafe(state, FACING).rotateYClockwise(), new Property<>(STYLE.data), 1);
propagate(world, pos, IBlock.getStatePropertySafe(state, FACING).rotateYCounterclockwise(), new Property<>(STYLE.data), 1);
} else {
world.setBlockState(pos, state.cycle(new Property<>(ARROW_DIRECTION.data)));
propagate(world, pos, IBlock.getStatePropertySafe(state, FACING).rotateYClockwise(), new Property<>(ARROW_DIRECTION.data), 1);
propagate(world, pos, IBlock.getStatePropertySafe(state, FACING).rotateYCounterclockwise(), new Property<>(ARROW_DIRECTION.data), 1);
}
}, null, org.mtr.mod.Items.BRUSH.get());
}

@Nonnull
@Override
public BlockState getStateForNeighborUpdate2(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (direction == Direction.DOWN && !(neighborState.getBlock().data instanceof BlockPSDAPGBase)) {
return Blocks.getAirMapped().getDefaultState();
} else {
return getActualState(world, pos);
}
}

@Nonnull
@Override
public Item asItem2() {
return ItemList.PSD_GLASS_TIANJIN_BMT.get();
}

@Override
public void addBlockProperties(List<HolderBase<?>> properties) {
properties.add(STYLE);
properties.add(FACING);
properties.add(SIDE_EXTENDED);
properties.add(AIR_LEFT);
properties.add(AIR_RIGHT);
properties.add(ARROW_DIRECTION);
}

@Nonnull
@Override
public BlockEntityExtension createBlockEntity(BlockPos blockPos, BlockState blockState) {
return new BlockEntity(blockPos, blockState);
}

public static BlockState getActualState(WorldAccess world, BlockPos pos) {
Direction facing = null;
EnumSide side = null;
boolean airLeft = false, airRight = false;

final BlockState stateBelow = world.getBlockState(pos.down());
final Block blockBelow = stateBelow.getBlock();
if (blockBelow.data instanceof BlockPSDGlassTianjinBMT || blockBelow.data instanceof BlockPSDDoorTianjinBMT || blockBelow.data instanceof BlockPSDGlassEndTianjinBMT) {
if (blockBelow.data instanceof BlockPSDDoorTianjinBMT) {
side = IBlock.getStatePropertySafe(stateBelow, SIDE);
} else {
side = IBlock.getStatePropertySafe(stateBelow, SIDE_EXTENDED);
}

if (blockBelow.data instanceof BlockPSDGlassEndTianjinBMT) {
if (IBlock.getStatePropertySafe(stateBelow, new Property<>(BlockPSDGlassEndTianjinBMT.TOUCHING_LEFT.data)) == BlockPSDGlassEndTianjinBMT.EnumPSDAPGGlassEndSide.AIR) {
airLeft = true;
}
if (IBlock.getStatePropertySafe(stateBelow, new Property<>(BlockPSDGlassEndTianjinBMT.TOUCHING_RIGHT.data)) == BlockPSDGlassEndTianjinBMT.EnumPSDAPGGlassEndSide.AIR) {
airRight = true;
}
}

facing = IBlock.getStatePropertySafe(stateBelow, FACING);
}

final BlockState oldState = world.getBlockState(pos);
BlockState neighborState = (oldState.getBlock().data instanceof BlockPSDTop ? oldState : BlockList.PSD_TOP_TIANJIN_BMT.get().getDefaultState()).with(new Property<>(AIR_LEFT.data), airLeft).with(new Property<>(AIR_RIGHT.data), airRight);
if (facing != null) {
neighborState = neighborState.with(new Property<>(FACING.data), facing.data);
}
if (side != null) {
neighborState = neighborState.with(new Property<>(SIDE_EXTENDED.data), side);
}
return neighborState;
}

/**
* @author ZiYueCommentary
* @see ziyue.tjmetro.mod.render.RenderPSDTopTianjin
* @since 1.0.0-beta-1
*/
public static class BlockEntity extends BlockEntityBase
{
public BlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityTypes.PSD_TOP_TIANJIN_BMT.get(), pos, state);
}
}

public enum EnumPSDType implements StringIdentifiable
{
BMT("bmt"),
TRT("trt");

final String name;

EnumPSDType(String name) {
this.name = name;
}

@Nonnull
@Override
public String asString2() {
return this.name;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,7 @@ public void onPlaced2(World world, BlockPos pos, BlockState state, @Nullable Liv
@Nonnull
@Override
public VoxelShape getOutlineShape2(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
final Direction facing = IBlock.getStatePropertySafe(state, FACING);
if (IBlockExtension.isBlock(state, BlockList.RAILWAY_SIGN_TIANJIN_BMT_MIDDLE.get())) {
return IBlock.getVoxelShapeByDirection(0, 0, 7, 16, 12, 9, facing);
} else {
final int xStart = getXStart();
final VoxelShape main = IBlock.getVoxelShapeByDirection(xStart - 0.75, 0, 7, 16, 12, 9, facing);
final VoxelShape pole = IBlock.getVoxelShapeByDirection(xStart - 2, 0, 7, xStart - 0.75, 16, 9, facing);
return VoxelShapes.union(main, pole);
}
return IRailwaySign.getOutlineShape(state, getXStart(), BlockList.RAILWAY_SIGN_TIANJIN_BMT_MIDDLE.get());
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ziyue.tjmetro.mod.block.base;

/**
* @since 1.0.0-beta-2
*/

public interface BlockFlagPSDTianjinBMT
{
}
Loading

0 comments on commit 7bbea7b

Please sign in to comment.