Skip to content

Commit 9a34901

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/1.20.1.dev'
2 parents fd387db + 22efcee commit 9a34901

File tree

487 files changed

+14097
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

487 files changed

+14097
-260
lines changed

common/src/main/java/net/adeptstack/Blocks/Behaviour/TrainSlidingDoorMovementBehaviour.java renamed to common/src/main/java/net/adeptstack/Blocks/Behaviour/SlidingDoor/TrainSlidingDoorMovementBehaviour.java

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
package net.adeptstack.Blocks.Behaviour;
1+
package net.adeptstack.Blocks.Behaviour.SlidingDoor;
22

3-
import com.mojang.authlib.minecraft.client.MinecraftClient;
43
import com.simibubi.create.content.contraptions.Contraption;
54
import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour;
65
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
@@ -13,7 +12,9 @@
1312
import com.simibubi.create.content.trains.station.GlobalStation;
1413
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
1514
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
16-
import net.adeptstack.Blocks.Doors.TrainSlidingDoorBlockEntity;
15+
import net.adeptstack.Blocks.Doors.SlidingDoor.TrainSlidingDoorBlock;
16+
import net.adeptstack.Core.Utils.TrainSlidingDoorProperties;
17+
import net.adeptstack.Blocks.Doors.SlidingDoor.TrainSlidingDoorBlockEntity;
1718
import net.adeptstack.registry.TrainUtilitiesBuilderTransformers;
1819
import net.minecraft.core.BlockPos;
1920
import net.minecraft.core.Direction;
@@ -25,13 +26,13 @@
2526
import net.minecraft.world.level.block.DoorBlock;
2627
import net.minecraft.world.level.block.entity.BlockEntity;
2728
import net.minecraft.world.level.block.state.BlockState;
29+
import net.minecraft.world.level.block.state.properties.DoorHingeSide;
2830
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
2931
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
3032
import net.minecraft.world.phys.Vec3;
3133

3234
import java.lang.ref.WeakReference;
3335
import java.util.Map;
34-
import java.util.Timer;
3536
import java.util.TimerTask;
3637

3738
public class TrainSlidingDoorMovementBehaviour implements MovementBehaviour {
@@ -54,9 +55,8 @@ public void tick(MovementContext context) {
5455
if (!context.world.isClientSide())
5556
tickOpen(context, open);
5657

57-
if (tsdp == null) {
58-
tsdp = TrainUtilitiesBuilderTransformers.GetSlidingDoorProperties(type);
59-
}
58+
int sound = TrainSlidingDoorBlockEntity.getDoorSoundValue(structureBlockInfo.state());
59+
tsdp = TrainUtilitiesBuilderTransformers.GetSlidingDoorProperties(sound);
6060

6161
Map<BlockPos, BlockEntity> tes = context.contraption.presentBlockEntities;
6262
if (!(tes.get(context.localPos) instanceof TrainSlidingDoorBlockEntity sdbe))
@@ -78,16 +78,32 @@ public void run() {
7878
}
7979
};
8080

81-
if (wasSettled && !sdbe.animation.settled() && !open) {
82-
context.world.playLocalSound(context.position.x, context.position.y, context.position.z,
83-
tsdp.GetClose(), SoundSource.BLOCKS, 1f, 1, false);
84-
}
81+
if (TrainSlidingDoorBlock.isDoubleDoor(structureBlockInfo.state().getValue(TrainSlidingDoorBlock.HINGE), context.localPos, context.state.getValue(TrainSlidingDoorBlock.FACING), context)) {
82+
if (structureBlockInfo.state().getValue(TrainSlidingDoorBlock.HINGE) == DoorHingeSide.RIGHT) {
83+
if (wasSettled && !sdbe.animation.settled() && !open) {
84+
context.world.playLocalSound(context.position.x, context.position.y, context.position.z,
85+
tsdp.GetClose(), SoundSource.BLOCKS, 1f, 1, false);
86+
}
87+
88+
if (wasSettled && !sdbe.animation.settled() && open) {
89+
context.world.playLocalSound(context.position.x, context.position.y, context.position.z,
90+
tsdp.GetOpen(), SoundSource.BLOCKS, 1f, 1, false);
91+
//Timer t = new Timer();
92+
//t.schedule(closeTask, 6000);
93+
}
94+
}
95+
} else {
96+
if (wasSettled && !sdbe.animation.settled() && !open) {
97+
context.world.playLocalSound(context.position.x, context.position.y, context.position.z,
98+
tsdp.GetClose(), SoundSource.BLOCKS, 1f, 1, false);
99+
}
85100

86-
if (wasSettled && !sdbe.animation.settled() && open) {
87-
context.world.playLocalSound(context.position.x, context.position.y, context.position.z,
88-
tsdp.GetOpen(), SoundSource.BLOCKS, 1f, 1, false);
89-
//Timer t = new Timer();
90-
//t.schedule(closeTask, 6000);
101+
if (wasSettled && !sdbe.animation.settled() && open) {
102+
context.world.playLocalSound(context.position.x, context.position.y, context.position.z,
103+
tsdp.GetOpen(), SoundSource.BLOCKS, 1f, 1, false);
104+
//Timer t = new Timer();
105+
//t.schedule(closeTask, 6000);
106+
}
91107
}
92108
}
93109

common/src/main/java/net/adeptstack/Blocks/Behaviour/TrainSlidingDoorMovingInteraction.java renamed to common/src/main/java/net/adeptstack/Blocks/Behaviour/SlidingDoor/TrainSlidingDoorMovingInteraction.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package net.adeptstack.Blocks.Behaviour;
1+
package net.adeptstack.Blocks.Behaviour.SlidingDoor;
22

33
import com.simibubi.create.content.contraptions.Contraption;
44
import com.simibubi.create.content.contraptions.behaviour.SimpleBlockMovingInteraction;
5-
import net.adeptstack.Blocks.Doors.TrainSlidingDoorBlock;
5+
import net.adeptstack.Blocks.Doors.SlidingDoor.TrainSlidingDoorBlock;
66
import net.minecraft.core.BlockPos;
77
import net.minecraft.core.Direction;
88
import net.minecraft.sounds.SoundEvent;
@@ -14,10 +14,6 @@
1414
import net.minecraft.world.level.block.state.properties.DoorHingeSide;
1515
import net.minecraft.world.level.block.state.properties.DoubleBlockHalf;
1616
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
17-
import org.jetbrains.annotations.NotNull;
18-
19-
import java.util.Timer;
20-
import java.util.TimerTask;
2117

2218
public class TrainSlidingDoorMovingInteraction extends SimpleBlockMovingInteraction {
2319

@@ -56,6 +52,7 @@ protected BlockState handle(Player player, Contraption contraption, BlockPos pos
5652
else {
5753
float pitch = player.level().random.nextFloat() * 0.1F + 0.9F;
5854
if (sound != null)
55+
5956
playSound(player, sound, pitch);
6057
}
6158
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package net.adeptstack.Blocks.Doors.SlidingDoor;
2+
3+
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
4+
import com.simibubi.create.content.decoration.slidingDoor.SlidingDoorBlock;
5+
import com.simibubi.create.foundation.item.ItemDescription;
6+
import com.simibubi.create.foundation.item.KineticStats;
7+
import com.simibubi.create.foundation.item.TooltipHelper;
8+
import com.simibubi.create.foundation.item.TooltipModifier;
9+
import net.adeptstack.Core.Client.ClientWrapper;
10+
import net.adeptstack.Core.Utils.ScreenUtils.PlacementUtils;
11+
import net.adeptstack.registry.ModBlockEntities;
12+
import net.minecraft.core.BlockPos;
13+
import net.minecraft.core.Direction;
14+
import net.minecraft.world.InteractionHand;
15+
import net.minecraft.world.InteractionResult;
16+
import net.minecraft.world.entity.player.Player;
17+
import net.minecraft.world.item.BlockItem;
18+
import net.minecraft.world.item.Item;
19+
import net.minecraft.world.level.Level;
20+
import net.minecraft.world.level.block.Block;
21+
import net.minecraft.world.level.block.entity.BlockEntityType;
22+
import net.minecraft.world.level.block.state.BlockState;
23+
import net.minecraft.world.level.block.state.StateDefinition;
24+
import net.minecraft.world.level.block.state.properties.BlockSetType;
25+
import net.minecraft.world.level.block.state.properties.DoorHingeSide;
26+
import net.minecraft.world.level.block.state.properties.IntegerProperty;
27+
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
28+
import net.minecraft.world.phys.BlockHitResult;
29+
import org.jetbrains.annotations.Nullable;
30+
31+
import static net.adeptstack.Main.REGISTRATE;
32+
33+
public class TrainSlidingDoorBlock extends SlidingDoorBlock {
34+
35+
public static final IntegerProperty DOOR_SOUND = IntegerProperty.create("door_sound", 0, 15);
36+
37+
public TrainSlidingDoorBlock(Properties properties, BlockSetType type, boolean isFolding, int defaultSound) {
38+
super(properties, type, isFolding);
39+
40+
this.registerDefaultState(this.stateDefinition.any()
41+
.setValue(DOOR_SOUND, defaultSound)
42+
);
43+
}
44+
45+
@Override
46+
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
47+
super.createBlockStateDefinition(pBuilder);
48+
pBuilder.add(DOOR_SOUND);
49+
}
50+
51+
public static boolean isDoubleDoor(DoorHingeSide hinge, BlockPos pos, Direction facing, MovementContext context) {
52+
if (hinge == DoorHingeSide.LEFT) {
53+
BlockPos posH2 = PlacementUtils.getPlaceDirectionLeft(pos, facing);
54+
StructureTemplate.StructureBlockInfo structureBlockInfo = context.contraption.getBlocks().get(posH2);
55+
if (structureBlockInfo == null)
56+
return false;
57+
if (structureBlockInfo.state().getBlock() instanceof TrainSlidingDoorBlock) {
58+
return structureBlockInfo.state().getValue(HINGE) == DoorHingeSide.RIGHT;
59+
}
60+
}
61+
else {
62+
BlockPos posH2 = PlacementUtils.getPlaceDirectionRight(pos, facing);
63+
StructureTemplate.StructureBlockInfo structureBlockInfo = context.contraption.getBlocks().get(posH2);
64+
if (structureBlockInfo == null)
65+
return false;
66+
if (structureBlockInfo.state().getBlock() instanceof TrainSlidingDoorBlock) {
67+
return structureBlockInfo.state().getValue(HINGE) == DoorHingeSide.LEFT;
68+
}
69+
}
70+
return false;
71+
}
72+
73+
@Override
74+
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) {
75+
if (!pPlayer.isShiftKeyDown()) {
76+
return super.use(pState, pLevel, pPos, pPlayer, pHand, pHit);
77+
} else {
78+
if (pLevel.isClientSide) {
79+
ClientWrapper.openChangeDoorSoundScreen(pPos, pState);
80+
}
81+
return InteractionResult.SUCCESS;
82+
}
83+
}
84+
85+
@Override
86+
public BlockEntityType<? extends TrainSlidingDoorBlockEntity> getBlockEntityType() {
87+
return ModBlockEntities.SLIDING_DOOR.get();
88+
}
89+
}

common/src/main/java/net/adeptstack/Blocks/Doors/TrainSlidingDoorBlockEntity.java renamed to common/src/main/java/net/adeptstack/Blocks/Doors/SlidingDoor/TrainSlidingDoorBlockEntity.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
package net.adeptstack.Blocks.Doors;
1+
package net.adeptstack.Blocks.Doors.SlidingDoor;
22

33
import com.simibubi.create.content.decoration.slidingDoor.SlidingDoorBlockEntity;
44
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
55
import net.minecraft.core.BlockPos;
6+
import net.minecraft.world.level.block.DoorBlock;
67
import net.minecraft.world.level.block.entity.BlockEntityType;
78
import net.minecraft.world.level.block.state.BlockState;
89

@@ -28,6 +29,11 @@ public void tick() {
2829
super.tick();
2930
}
3031

32+
public static int getDoorSoundValue(BlockState state) {
33+
return state.getOptionalValue(TrainSlidingDoorBlock.DOOR_SOUND)
34+
.orElse(0);
35+
}
36+
3137
@Override
3238
protected boolean shouldRenderSpecial(BlockState state) {
3339
return super.shouldRenderSpecial(state);

common/src/main/java/net/adeptstack/Blocks/Doors/TrainSlidingDoorBlockRenderer.java renamed to common/src/main/java/net/adeptstack/Blocks/Doors/SlidingDoor/TrainSlidingDoorBlockRenderer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.adeptstack.Blocks.Doors;
1+
package net.adeptstack.Blocks.Doors.SlidingDoor;
22

33
import com.jozufozu.flywheel.core.PartialModel;
44
import com.mojang.blaze3d.vertex.PoseStack;
@@ -12,11 +12,11 @@
1212
import com.simibubi.create.foundation.utility.AngleHelper;
1313
import com.simibubi.create.foundation.utility.Couple;
1414
import com.simibubi.create.foundation.utility.Iterate;
15+
import net.adeptstack.registry.ModPartialModels;
1516
import net.minecraft.client.renderer.MultiBufferSource;
1617
import net.minecraft.client.renderer.RenderType;
1718
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
1819
import net.minecraft.core.Direction;
19-
import net.minecraft.core.registries.Registries;
2020
import net.minecraft.util.Mth;
2121
import net.minecraft.world.level.block.DoorBlock;
2222
import net.minecraft.world.level.block.state.BlockState;
@@ -54,9 +54,9 @@ protected void renderSafe(SlidingDoorBlockEntity be, float partialTicks, PoseSta
5454
.add(Vec3.atLowerCornerOf(facing.getNormal())
5555
.scale(value2 * 1 / 32f));
5656

57-
if (((SlidingDoorBlock) blockState.getBlock()).isFoldingDoor()) {
57+
if (((TrainSlidingDoorBlock) blockState.getBlock()).isFoldingDoor()) {
5858
Couple<PartialModel> partials =
59-
AllPartialModels.FOLDING_DOORS.get(blockState.getBlock().arch$registryName());
59+
ModPartialModels.FOLDING_DOORS.get(blockState.getBlock().arch$registryName());
6060

6161
boolean flip = blockState.getValue(DoorBlock.HINGE) == DoorHingeSide.RIGHT;
6262
for (boolean left : Iterate.trueAndFalse) {

common/src/main/java/net/adeptstack/Blocks/Doors/TrainSlidingDoorBlock.java

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)