-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Odd Horizontal Elevator Doors
- Loading branch information
Showing
13 changed files
with
267 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 40 additions & 5 deletions
45
common/src/main/java/ru/weryskok/mtrrumetro/blocks/BlockSPBHorizontalElevatorDoor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,68 @@ | ||
package ru.weryskok.mtrrumetro.blocks; | ||
|
||
import mtr.block.BlockPSDAPGDoorBase; | ||
import mtr.block.BlockPSDAPGGlassEndBase; | ||
import mtr.block.IBlock; | ||
import mtr.mappings.BlockEntityMapper; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.LevelAccessor; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.block.state.StateDefinition; | ||
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; | ||
import net.minecraft.world.level.block.state.properties.Property; | ||
import ru.weryskok.mtrrumetro.BlockEntityTypes; | ||
import ru.weryskok.mtrrumetro.Items; | ||
|
||
public class BlockSPBHorizontalElevatorDoor extends BlockPSDAPGDoorBase { | ||
boolean is_odd; | ||
|
||
public BlockSPBHorizontalElevatorDoor() { | ||
public BlockSPBHorizontalElevatorDoor(boolean is_odd) { | ||
super(); | ||
this.is_odd = is_odd; | ||
} | ||
|
||
@Override | ||
public BlockState updateShape(BlockState state, Direction direction, BlockState newState, LevelAccessor world, BlockPos pos, BlockPos posFrom) { | ||
if (is_odd){ | ||
boolean isTop = IBlock.getStatePropertySafe(state, HALF) == DoubleBlockHalf.UPPER; | ||
return (isTop && direction == Direction.DOWN || !isTop && direction == Direction.UP) && !newState.is(this) ? Blocks.AIR.defaultBlockState() : state; | ||
} | ||
if (IBlock.getSideDirection(state) == direction && !newState.is(this)) { | ||
return Blocks.AIR.defaultBlockState(); | ||
} else { | ||
BlockState superState = super.updateShape(state, direction, newState, world, pos, posFrom); | ||
if (superState.getBlock() == Blocks.AIR) { | ||
return superState; | ||
} else { | ||
boolean end = world.getBlockState(pos.relative(IBlock.getSideDirection(state).getOpposite())).getBlock() instanceof BlockPSDAPGGlassEndBase; | ||
return (BlockState)superState.setValue(END, end); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public BlockEntityMapper createBlockEntity(BlockPos pos, BlockState state) { | ||
return new TileEntitySPBHorizontalElevatorDoor(pos, state); | ||
return new TileEntitySPBHorizontalElevatorDoor(pos, state, is_odd); | ||
} | ||
|
||
@Override | ||
public Item asItem() { | ||
return Items.SPB_HORIZONTAL_ELEVATOR_DOOR.get(); | ||
return (is_odd? Items.SPB_HORIZONTAL_ELEVATOR_DOOR_ODD : Items.SPB_HORIZONTAL_ELEVATOR_DOOR).get(); | ||
} | ||
|
||
@Override | ||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { | ||
builder.add(new Property[]{END, FACING, HALF, SIDE, TEMP, UNLOCKED}); | ||
} | ||
|
||
public static class TileEntitySPBHorizontalElevatorDoor extends TileEntityPSDAPGDoorBase { | ||
|
||
public TileEntitySPBHorizontalElevatorDoor(BlockPos pos, BlockState state) { | ||
super(BlockEntityTypes.SPB_HORIZONTAL_ELEVATOR_DOOR_TILE_ENTITY.get(), pos, state); | ||
public TileEntitySPBHorizontalElevatorDoor(BlockPos pos, BlockState state, boolean is_odd) { | ||
super((is_odd ? BlockEntityTypes.SPB_HORIZONTAL_ELEVATOR_DOOR_ODD_TILE_ENTITY : BlockEntityTypes.SPB_HORIZONTAL_ELEVATOR_DOOR_TILE_ENTITY).get(), pos, state); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
.../src/main/resources/assets/russianmetro/blockstates/spb_horizontal_elevator_door_odd.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"multipart": [ | ||
{ | ||
"when": { | ||
"facing": "west", | ||
"side": "left", | ||
"half": "lower", | ||
"temp": "true" | ||
}, | ||
"apply": { | ||
"model": "russianmetro:block/temp_doors/spb_horizontal_elevator_door_odd_bottom" | ||
} | ||
}, | ||
{ | ||
"when": { | ||
"facing": "north", | ||
"side": "left", | ||
"half": "lower", | ||
"temp": "true" | ||
}, | ||
"apply": { | ||
"model": "russianmetro:block/temp_doors/spb_horizontal_elevator_door_odd_bottom", | ||
"y": 90 | ||
} | ||
}, | ||
{ | ||
"when": { | ||
"facing": "east", | ||
"side": "left", | ||
"half": "lower", | ||
"temp": "true" | ||
}, | ||
"apply": { | ||
"model": "russianmetro:block/temp_doors/spb_horizontal_elevator_door_odd_bottom", | ||
"y": 180 | ||
} | ||
}, | ||
{ | ||
"when": { | ||
"facing": "south", | ||
"side": "left", | ||
"half": "lower", | ||
"temp": "true" | ||
}, | ||
"apply": { | ||
"model": "russianmetro:block/temp_doors/spb_horizontal_elevator_door_odd_bottom", | ||
"y": 270 | ||
} | ||
}, | ||
{ | ||
"when": { | ||
"facing": "west", | ||
"side": "left", | ||
"half": "upper", | ||
"temp": "true" | ||
}, | ||
"apply": { | ||
"model": "russianmetro:block/temp_doors/spb_horizontal_elevator_door_odd_top" | ||
} | ||
}, | ||
{ | ||
"when": { | ||
"facing": "north", | ||
"side": "left", | ||
"half": "upper", | ||
"temp": "true" | ||
}, | ||
"apply": { | ||
"model": "russianmetro:block/temp_doors/spb_horizontal_elevator_door_odd_top", | ||
"y": 90 | ||
} | ||
}, | ||
{ | ||
"when": { | ||
"facing": "east", | ||
"side": "left", | ||
"half": "upper", | ||
"temp": "true" | ||
}, | ||
"apply": { | ||
"model": "russianmetro:block/temp_doors/spb_horizontal_elevator_door_odd_top", | ||
"y": 180 | ||
} | ||
}, | ||
{ | ||
"when": { | ||
"facing": "south", | ||
"side": "left", | ||
"half": "upper", | ||
"temp": "true" | ||
}, | ||
"apply": { | ||
"model": "russianmetro:block/temp_doors/spb_horizontal_elevator_door_odd_top", | ||
"y": 270 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.