Skip to content

Commit

Permalink
Some small code changes and moscow metro logo
Browse files Browse the repository at this point in the history
What I did:
-Moved code from main to other classes to clean up
-Metro Logo
  • Loading branch information
CodeFlusher authored and WerySkok committed Aug 29, 2023
1 parent c338dd9 commit 1f295db
Show file tree
Hide file tree
Showing 23 changed files with 281 additions and 353 deletions.
16 changes: 14 additions & 2 deletions common/src/main/java/ru/weryskok/mtrrumetro/BlockEntityTypes.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
package ru.weryskok.mtrrumetro;

import mtr.RegistryObject;
import mtr.mappings.BlockEntityMapper;
import mtr.mappings.RegistryUtilities;
import net.minecraft.world.level.block.entity.BlockEntityType;
import ru.weryskok.mtrrumetro.blocks.*;

public interface BlockEntityTypes {
RegistryObject<BlockEntityType<BlockSPBHorizontalElevatorDoor.TileEntitySPBHorizontalElevatorDoor>> SPB_HORIZONTAL_ELEVATOR_DOOR_TILE_ENTITY = new RegistryObject<>(() -> RegistryUtilities.getBlockEntityType(BlockSPBHorizontalElevatorDoor.TileEntitySPBHorizontalElevatorDoor::new, Blocks.SPB_HORIZONTAL_ELEVATOR_DOOR.get()));
import java.util.function.BiConsumer;

public class BlockEntityTypes {
public final BiConsumer<String, RegistryObject<? extends BlockEntityType<? extends BlockEntityMapper>>> registerBlockEntityType;
public static final RegistryObject<BlockEntityType<BlockSPBHorizontalElevatorDoor.TileEntitySPBHorizontalElevatorDoor>> SPB_HORIZONTAL_ELEVATOR_DOOR_TILE_ENTITY = new RegistryObject<>(() -> RegistryUtilities.getBlockEntityType(BlockSPBHorizontalElevatorDoor.TileEntitySPBHorizontalElevatorDoor::new, Blocks.SPB_HORIZONTAL_ELEVATOR_DOOR.get()));

public BlockEntityTypes(BiConsumer<String, RegistryObject<? extends BlockEntityType<? extends BlockEntityMapper>>> registerBlockEntityType) {
this.registerBlockEntityType = registerBlockEntityType;
}

public void registerBlockEntites(){
registerBlockEntityType.accept("spb_horizontal_elevator_door", BlockEntityTypes.SPB_HORIZONTAL_ELEVATOR_DOOR_TILE_ENTITY);
}
}
51 changes: 41 additions & 10 deletions common/src/main/java/ru/weryskok/mtrrumetro/Blocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,46 @@
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.MaterialColor;
import ru.weryskok.mtrrumetro.blocks.*;
import ru.weryskok.mtrrumetro.blocks.outside.MetroLogo;

public interface Blocks {
RegistryObject<Block> MOSCOW_OLD_TICKET_BARRIER_ENTRANCE = new RegistryObject<>(()-> new BlockMoscowOldTicketBarrier(true));
RegistryObject<Block> MOSCOW_OLD_TICKET_BARRIER_EXIT = new RegistryObject<>(()-> new BlockMoscowOldTicketBarrier(false));
RegistryObject<Block> MOSCOW_OLD_TICKET_BARRIER_SIDE_COVER = new RegistryObject<>(BlockMoscowOldTicketBarrierSideCover::new);
RegistryObject<Block> MOSCOW_NEW_TICKET_BARRIER_ENTRANCE = new RegistryObject<>(()-> new BlockMoscowNewTicketBarrier(true));
RegistryObject<Block> MOSCOW_NEW_TICKET_BARRIER_EXIT = new RegistryObject<>(()-> new BlockMoscowNewTicketBarrier(false));
RegistryObject<Block> MOSCOW_NEW_TICKET_BARRIER_SIDE_COVER = new RegistryObject<>(BlockMoscowNewTicketBarrierSideCover::new);
RegistryObject<Block> MOSCOW_NEW_TICKET_MACHINE = new RegistryObject<>(() -> new BlockMoscowNewTicketMachine(BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_GRAY).requiresCorrectToolForDrops().strength(2).lightLevel(state -> 5).noOcclusion()));
RegistryObject<Block> SPB_HORIZONTAL_ELEVATOR_DOOR = new RegistryObject<>(BlockSPBHorizontalElevatorDoor::new);
RegistryObject<Block> MOSCOW_OLD_INFOSOS_STAND = new RegistryObject<>(BlockMoscowOldInfoSosStand::new);
import java.util.function.BiConsumer;

public class Blocks {
private BiConsumer<String, RegistryObject<Block>> registerBlock;
private Main.RegisterBlockItem registerBlockItem;
public static final RegistryObject<Block> MOSCOW_OLD_TICKET_BARRIER_ENTRANCE = new RegistryObject<>(()-> new BlockMoscowOldTicketBarrier(true));
public static final RegistryObject<Block> MOSCOW_OLD_TICKET_BARRIER_EXIT = new RegistryObject<>(()-> new BlockMoscowOldTicketBarrier(false));
public static final RegistryObject<Block> MOSCOW_OLD_TICKET_BARRIER_SIDE_COVER = new RegistryObject<>(BlockMoscowOldTicketBarrierSideCover::new);
public static final RegistryObject<Block> MOSCOW_NEW_TICKET_BARRIER_ENTRANCE = new RegistryObject<>(()-> new BlockMoscowNewTicketBarrier(true));
public static final RegistryObject<Block> MOSCOW_NEW_TICKET_BARRIER_EXIT = new RegistryObject<>(()-> new BlockMoscowNewTicketBarrier(false));
public static final RegistryObject<Block> MOSCOW_NEW_TICKET_BARRIER_SIDE_COVER = new RegistryObject<>(BlockMoscowNewTicketBarrierSideCover::new);
public static final RegistryObject<Block> MOSCOW_NEW_TICKET_MACHINE = new RegistryObject<>(() -> new BlockMoscowNewTicketMachine(BlockBehaviour.Properties.of(Material.METAL, MaterialColor.COLOR_GRAY).requiresCorrectToolForDrops().strength(2).lightLevel(state -> 5).noOcclusion()));
public static final RegistryObject<Block> SPB_HORIZONTAL_ELEVATOR_DOOR = new RegistryObject<>(BlockSPBHorizontalElevatorDoor::new);
public static final RegistryObject<Block> MOSCOW_OLD_INFOSOS_STAND = new RegistryObject<>(BlockMoscowOldInfoSosStand::new);
public static final RegistryObject<Block> MOSCOW_METRO_LABEL = new RegistryObject<>(MetroLogo::new);

public Blocks(BiConsumer<String, RegistryObject<Block>> registerBlock, Main.RegisterBlockItem registerBlockItem){
this.registerBlock = registerBlock;
this.registerBlockItem = registerBlockItem;
}
public void registerBlockItems(){
//Регистрация блоков
//Старые барьеры
registerBlockItem.accept("moscow_old_ticket_barrier_entrance", Blocks.MOSCOW_OLD_TICKET_BARRIER_ENTRANCE, CreativeModeTabs.RUSSIAN_METRO_STUFF);
registerBlockItem.accept("moscow_old_ticket_barrier_exit", Blocks.MOSCOW_OLD_TICKET_BARRIER_EXIT, CreativeModeTabs.RUSSIAN_METRO_STUFF);
registerBlockItem.accept("moscow_old_ticket_barrier_side_cover", Blocks.MOSCOW_OLD_TICKET_BARRIER_SIDE_COVER, CreativeModeTabs.RUSSIAN_METRO_STUFF);
//Новые барьеры
registerBlockItem.accept("moscow_new_ticket_barrier_entrance", Blocks.MOSCOW_NEW_TICKET_BARRIER_ENTRANCE, CreativeModeTabs.RUSSIAN_METRO_STUFF);
registerBlockItem.accept("moscow_new_ticket_barrier_exit", Blocks.MOSCOW_NEW_TICKET_BARRIER_EXIT, CreativeModeTabs.RUSSIAN_METRO_STUFF);
registerBlockItem.accept("moscow_new_ticket_barrier_side_cover", Blocks.MOSCOW_NEW_TICKET_BARRIER_SIDE_COVER, CreativeModeTabs.RUSSIAN_METRO_STUFF);
registerBlockItem.accept("moscow_new_ticket_machine", Blocks.MOSCOW_NEW_TICKET_MACHINE, CreativeModeTabs.RUSSIAN_METRO_STUFF);
//Лого
registerBlockItem.accept("moscow_metro_label", Blocks.MOSCOW_METRO_LABEL, CreativeModeTabs.RUSSIAN_METRO_STUFF);
//Табло SOS
registerBlockItem.accept("moscow_old_infosos_stand", Blocks.MOSCOW_OLD_INFOSOS_STAND, CreativeModeTabs.RUSSIAN_METRO_STUFF);
}

public void registerBlocks(){
registerBlock.accept("spb_horizontal_elevator_door", Blocks.SPB_HORIZONTAL_ELEVATOR_DOOR);
}
}
15 changes: 13 additions & 2 deletions common/src/main/java/ru/weryskok/mtrrumetro/Items.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
import net.minecraft.world.item.Item;
import ru.weryskok.mtrrumetro.items.*;

public interface Items {
RegistryObject<Item> SPB_HORIZONTAL_ELEVATOR_DOOR = new RegistryObject<>(ItemSPBHorizontalElevatorDoor::new);
import java.util.function.BiConsumer;

public class Items {
private final BiConsumer<String, RegistryObject<Item>> registerItem;
public static final RegistryObject<Item> SPB_HORIZONTAL_ELEVATOR_DOOR = new RegistryObject<>(ItemSPBHorizontalElevatorDoor::new);

public Items(BiConsumer<String, RegistryObject<Item>> registerItem) {
this.registerItem = registerItem;
}

public void registerItem(){
registerItem.accept("spb_horizontal_elevator_door", Items.SPB_HORIZONTAL_ELEVATOR_DOOR);
}
}
33 changes: 17 additions & 16 deletions common/src/main/java/ru/weryskok/mtrrumetro/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;

import java.util.function.BiConsumer;

public class Main {
public static final String MOD_ID = "russianmetro";
public static Blocks blocks;
public static Items items;
public static SoundEvents soundEvents;
public static BlockEntityTypes blockEntityTypes;

public static void init(
BiConsumer<String, RegistryObject<Item>> registerItem,
Expand All @@ -23,23 +28,19 @@ public static void init(
BiConsumer<String, RegistryObject<? extends EntityType<? extends Entity>>> registerEntityType,
BiConsumer<String, SoundEvent> registerSoundEvent
) {
//Срать в ините = идея хуйня ебаная.
//Лучше разделить на классы, вынести все в свое
//Java <3
blocks = new Blocks(registerBlock, registerBlockItem);
items = new Items(registerItem);
soundEvents = new SoundEvents(registerSoundEvent);
blockEntityTypes = new BlockEntityTypes(registerBlockEntityType);

blocks.registerBlockItems();
items.registerItem();
soundEvents.regiserEvents();
blockEntityTypes.registerBlockEntites();

registerBlockItem.accept("moscow_old_ticket_barrier_entrance", Blocks.MOSCOW_OLD_TICKET_BARRIER_ENTRANCE, CreativeModeTabs.RUSSIAN_METRO_STUFF);
registerBlockItem.accept("moscow_old_ticket_barrier_exit", Blocks.MOSCOW_OLD_TICKET_BARRIER_EXIT, CreativeModeTabs.RUSSIAN_METRO_STUFF);
registerBlockItem.accept("moscow_old_ticket_barrier_side_cover", Blocks.MOSCOW_OLD_TICKET_BARRIER_SIDE_COVER, CreativeModeTabs.RUSSIAN_METRO_STUFF);
registerSoundEvent.accept("moscow_old_ticket_barrier_fail", SoundEvents.MOSCOW_OLD_TICKET_BARRIER_FAIL);

registerBlockItem.accept("moscow_new_ticket_barrier_entrance", Blocks.MOSCOW_NEW_TICKET_BARRIER_ENTRANCE, CreativeModeTabs.RUSSIAN_METRO_STUFF);
registerBlockItem.accept("moscow_new_ticket_barrier_exit", Blocks.MOSCOW_NEW_TICKET_BARRIER_EXIT, CreativeModeTabs.RUSSIAN_METRO_STUFF);
registerBlockItem.accept("moscow_new_ticket_barrier_side_cover", Blocks.MOSCOW_NEW_TICKET_BARRIER_SIDE_COVER, CreativeModeTabs.RUSSIAN_METRO_STUFF);

registerBlockItem.accept("moscow_new_ticket_machine", Blocks.MOSCOW_NEW_TICKET_MACHINE, CreativeModeTabs.RUSSIAN_METRO_STUFF);

registerBlock.accept("spb_horizontal_elevator_door", Blocks.SPB_HORIZONTAL_ELEVATOR_DOOR);
registerItem.accept("spb_horizontal_elevator_door", Items.SPB_HORIZONTAL_ELEVATOR_DOOR);
registerBlockEntityType.accept("spb_horizontal_elevator_door", BlockEntityTypes.SPB_HORIZONTAL_ELEVATOR_DOOR_TILE_ENTITY);

registerBlockItem.accept("moscow_old_infosos_stand", Blocks.MOSCOW_OLD_INFOSOS_STAND, CreativeModeTabs.RUSSIAN_METRO_STUFF);
}

@FunctionalInterface
Expand Down
15 changes: 13 additions & 2 deletions common/src/main/java/ru/weryskok/mtrrumetro/SoundEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;

public interface SoundEvents {
SoundEvent MOSCOW_OLD_TICKET_BARRIER_FAIL = RegistryUtilities.createSoundEvent(new ResourceLocation(Main.MOD_ID, "moscow_old_ticket_barrier_fail"));
import java.util.function.BiConsumer;

public class SoundEvents {
private final BiConsumer<String, SoundEvent> registerSoundEvent;
public static final SoundEvent MOSCOW_OLD_TICKET_BARRIER_FAIL = RegistryUtilities.createSoundEvent(new ResourceLocation(Main.MOD_ID, "moscow_old_ticket_barrier_fail"));

SoundEvents(BiConsumer<String, SoundEvent> registerSoundEvent){
this.registerSoundEvent =registerSoundEvent;
}

public void regiserEvents(){
registerSoundEvent.accept("moscow_old_ticket_barrier_fail", SoundEvents.MOSCOW_OLD_TICKET_BARRIER_FAIL);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package ru.weryskok.mtrrumetro.blocks.outside;

import it.unimi.dsi.fastutil.doubles.DoubleList;
import mtr.block.IBlock;
import mtr.data.RailAngle;
import mtr.mappings.BlockDirectionalMapper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;

public class MetroLogo extends BlockDirectionalMapper {

public MetroLogo() {
super(Properties.of(Material.METAL).friction(2f));
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(FACING);
}

@Nullable
@Override
public BlockState getStateForPlacement(BlockPlaceContext blockPlaceContext) {
return defaultBlockState().setValue(FACING, blockPlaceContext.getHorizontalDirection().getOpposite());
}

@Override
public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
return Shapes.box(0.3f, 0.3f, 0.3f, 0.7f, 0.7f, 0.7f);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"variants": {
"facing=north": {
"model": "russianmetro:block/enterance_deco/metro_logo"
},
"facing=east": {
"model": "russianmetro:block/enterance_deco/metro_logo",
"y": 90
},
"facing=south": {
"model": "russianmetro:block/enterance_deco/metro_logo",
"y": 180
},
"facing=west": {
"model": "russianmetro:block/enterance_deco/metro_logo",
"y": 270
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"credit": "Made with Blockbench",
"parent": "block/block",
"texture_size": [32, 32],
"textures": {
"0": "russianmetro:block/enterance_deco/subway_logo",
"particle": "russianmetro:block/enterance_deco/subway_logo"
},
"elements": [
{
"from": [9.15432, 4.77583, 7],
"to": [11.15432, 12.27583, 9],
"rotation": {"angle": 22.5, "axis": "z", "origin": [8, 11, 8]},
"faces": {
"north": {"uv": [3, 0, 4, 4], "texture": "#0"},
"east": {"uv": [0, 0, 1, 4], "texture": "#0"},
"south": {"uv": [1, 0, 2, 4], "texture": "#0"},
"west": {"uv": [2, 0, 3, 4], "texture": "#0"},
"up": {"uv": [4, 7.5, 3, 6.5], "rotation": 90, "texture": "#0"},
"down": {"uv": [5, 6.5, 4, 7.5], "rotation": 270, "texture": "#0"}
}
},
{
"from": [7.84568, 8.52583, 7],
"to": [9.84568, 13.52583, 9],
"rotation": {"angle": -22.5, "axis": "z", "origin": [8, 11, 8]},
"faces": {
"north": {"uv": [5, 2.5, 6, 5], "texture": "#0"},
"east": {"uv": [3, 4, 4, 6.5], "texture": "#0"},
"south": {"uv": [4, 4, 5, 6.5], "texture": "#0"},
"west": {"uv": [5, 0, 6, 2.5], "texture": "#0"},
"up": {"uv": [8, 3, 7, 2], "rotation": 90, "texture": "#0"},
"down": {"uv": [8, 3, 7, 4], "rotation": 270, "texture": "#0"}
}
},
{
"from": [6.15432, 8.52583, 7],
"to": [8.15432, 13.52583, 9],
"rotation": {"angle": 22.5, "axis": "z", "origin": [8, 11, 8]},
"faces": {
"north": {"uv": [6, 5, 7, 7.5], "texture": "#0"},
"east": {"uv": [5, 5, 6, 7.5], "texture": "#0"},
"south": {"uv": [6, 0, 7, 2.5], "texture": "#0"},
"west": {"uv": [6, 2.5, 7, 5], "texture": "#0"},
"up": {"uv": [8, 5, 7, 4], "rotation": 90, "texture": "#0"},
"down": {"uv": [8, 5, 7, 6], "rotation": 270, "texture": "#0"}
}
},
{
"from": [4.84568, 4.77583, 7],
"to": [6.84568, 12.27583, 9],
"rotation": {"angle": -22.5, "axis": "z", "origin": [8, 11, 8]},
"faces": {
"north": {"uv": [2, 4, 3, 8], "texture": "#0"},
"east": {"uv": [0, 4, 1, 8], "texture": "#0"},
"south": {"uv": [4, 0, 5, 4], "texture": "#0"},
"west": {"uv": [1, 4, 2, 8], "texture": "#0"},
"up": {"uv": [8, 1, 7, 0], "rotation": 90, "texture": "#0"},
"down": {"uv": [8, 1, 7, 2], "rotation": 270, "texture": "#0"}
}
},
{
"from": [8.825, 13, 7],
"to": [10.425, 13.4, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 11, 8]},
"faces": {
"north": {"uv": [1, 8, 2, 8.5], "texture": "#0"},
"east": {"uv": [0, 8, 1, 8.5], "texture": "#0"},
"south": {"uv": [8, 0, 9, 0.5], "texture": "#0"},
"west": {"uv": [8, 0.5, 9, 1], "texture": "#0"},
"up": {"uv": [8, 7, 7, 6], "rotation": 90, "texture": "#0"},
"down": {"uv": [8, 7, 7, 8], "rotation": 270, "texture": "#0"}
}
},
{
"from": [5.575, 13, 7],
"to": [7.175, 13.4, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 11, 8]},
"faces": {
"north": {"uv": [8, 2, 9, 2.5], "texture": "#0"},
"east": {"uv": [8, 1, 9, 1.5], "texture": "#0"},
"south": {"uv": [8, 1.5, 9, 2], "texture": "#0"},
"west": {"uv": [2, 8, 3, 8.5], "texture": "#0"},
"up": {"uv": [4, 8.5, 3, 7.5], "rotation": 90, "texture": "#0"},
"down": {"uv": [5, 7.5, 4, 8.5], "rotation": 270, "texture": "#0"}
}
},
{
"from": [7.15, 8, 7],
"to": [8.75, 8.4, 9],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 11, 8]},
"faces": {
"north": {"uv": [8, 4, 9, 4.5], "texture": "#0"},
"east": {"uv": [8, 2.5, 9, 3], "texture": "#0"},
"south": {"uv": [8, 3, 9, 3.5], "texture": "#0"},
"west": {"uv": [8, 3.5, 9, 4], "texture": "#0"},
"up": {"uv": [6, 8.5, 5, 7.5], "rotation": 90, "texture": "#0"},
"down": {"uv": [7, 7.5, 6, 8.5], "rotation": 270, "texture": "#0"}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"parent": "block/block",
"credit": "Designed by Anastasiya Trusheva, Made with Blockbench",
"texture_size": [91, 91],
"textures": {
Expand Down Expand Up @@ -745,43 +746,7 @@
}
}
],
"display": {
"thirdperson_righthand": {
"translation": [0, 0.75, 0.5],
"scale": [0.2, 0.2, 0.2]
},
"thirdperson_lefthand": {
"scale": [0.2, 0.2, 0.2]
},
"firstperson_righthand": {
"rotation": [177, -180, -180],
"translation": [0, 1, 0],
"scale": [0.25, 0.25, 0.25]
},
"firstperson_lefthand": {
"rotation": [177, -153, -180],
"translation": [0, 1, 0],
"scale": [0.25, 0.25, 0.25]
},
"ground": {
"scale": [0.3, 0.3, 0.3]
},
"gui": {
"rotation": [28, 40, 0],
"translation": [-1.5, -2.25, 0],
"scale": [0.5, 0.5, 0.5]
},
"head": {
"rotation": [0, 180, 0],
"translation": [0, 13, 0],
"scale": [0.8, 0.8, 0.8]
},
"fixed": {
"rotation": [0, -90, 0],
"translation": [0, -1.25, -3.5],
"scale": [0.4, 0.4, 0.4]
}
},

"groups": [
{
"name": "group",
Expand Down
Loading

0 comments on commit 1f295db

Please sign in to comment.