-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Craig <[email protected]>
- Loading branch information
1 parent
537b442
commit d2bde10
Showing
20 changed files
with
450 additions
and
20 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
...on/src/main/java/whocraft/tardis_refined/common/block/device/CorridorTeleporterBlock.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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package whocraft.tardis_refined.common.block.device; | ||
|
||
import net.minecraft.client.multiplayer.ClientLevel; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.particles.ParticleTypes; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.util.RandomSource; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.BaseEntityBlock; | ||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.level.block.EntityBlock; | ||
import net.minecraft.world.level.block.RenderShape; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.level.block.entity.BlockEntityTicker; | ||
import net.minecraft.world.level.block.entity.BlockEntityType; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.AABB; | ||
import net.minecraft.world.phys.Vec3; | ||
import net.minecraft.world.phys.shapes.BooleanOp; | ||
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.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import whocraft.tardis_refined.common.blockentity.device.CorridorTeleporterBlockEntity; | ||
import whocraft.tardis_refined.common.blockentity.life.EyeBlockEntity; | ||
import whocraft.tardis_refined.common.tardis.ExteriorShell; | ||
import whocraft.tardis_refined.common.util.ClientHelper; | ||
import whocraft.tardis_refined.common.util.TRTeleporter; | ||
import whocraft.tardis_refined.registry.TRBlockEntityRegistry; | ||
import whocraft.tardis_refined.registry.TRDimensionTypes; | ||
|
||
public class CorridorTeleporterBlock extends Block implements EntityBlock { | ||
|
||
public CorridorTeleporterBlock(Properties properties) { | ||
super(properties); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { | ||
return new CorridorTeleporterBlockEntity(blockPos, blockState); | ||
} | ||
|
||
@Override | ||
public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) { | ||
return Shapes.join(Block.box(2, 0, 2, 14, 2, 14), Block.box(4, 1, 4, 12, 3, 12), BooleanOp.OR); | ||
} | ||
|
||
@Override | ||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(@NotNull Level level, @NotNull BlockState state, @NotNull BlockEntityType<T> type) { | ||
return (level1, blockPos, blockState, t) -> { | ||
if (t instanceof CorridorTeleporterBlockEntity corridorTeleporterBlockEntity) { | ||
corridorTeleporterBlockEntity.tick(level, blockPos, blockState, corridorTeleporterBlockEntity); | ||
} | ||
}; | ||
} | ||
|
||
|
||
@Override | ||
public void entityInside(BlockState blockState, Level level, BlockPos blockPos, Entity entity) { | ||
|
||
if (!level.isClientSide()){ | ||
ServerLevel serverLevel = (ServerLevel)level; | ||
if (serverLevel.getBlockEntity(blockPos) instanceof CorridorTeleporterBlockEntity corridorTeleporterBlockEntity) { | ||
corridorTeleporterBlockEntity.startTeleporterTimer(); | ||
} | ||
} else { | ||
|
||
for (int i = 0; i < 5; i++) { | ||
ClientHelper.playParticle((ClientLevel) level, ParticleTypes.PORTAL, new Vec3(blockPos.getX() + 0.5f, blockPos.getY(), blockPos.getZ() + 0.5f), -0.5 + level.random.nextFloat(), 0.5f, -0.5 + level.random.nextFloat()); | ||
} | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...java/whocraft/tardis_refined/common/blockentity/device/CorridorTeleporterBlockEntity.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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package whocraft.tardis_refined.common.blockentity.device; | ||
|
||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.particles.ParticleOptions; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.sounds.SoundEvents; | ||
import net.minecraft.sounds.SoundSource; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.entity.BlockEntity; | ||
import net.minecraft.world.level.block.entity.BlockEntityTicker; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.phys.AABB; | ||
import whocraft.tardis_refined.client.TRParticles; | ||
import whocraft.tardis_refined.common.tardis.TardisArchitectureHandler; | ||
import whocraft.tardis_refined.common.tardis.manager.TardisInteriorManager; | ||
import whocraft.tardis_refined.common.util.TRTeleporter; | ||
import whocraft.tardis_refined.registry.TRBlockEntityRegistry; | ||
import whocraft.tardis_refined.registry.TRDimensionTypes; | ||
import whocraft.tardis_refined.registry.TRSoundRegistry; | ||
|
||
import java.util.List; | ||
|
||
public class CorridorTeleporterBlockEntity extends BlockEntity implements BlockEntityTicker<CorridorTeleporterBlockEntity> { | ||
|
||
private static int TICKS_FOR_COOLDOWN = 100; | ||
private static int TICKS_TO_TRIGGER_TELEPORT = 160; | ||
|
||
private int timeSinceTriggeredTicks = 0; | ||
private int cooldownTicks = 0; | ||
|
||
public CorridorTeleporterBlockEntity( BlockPos blockPos, BlockState blockState) { | ||
super(TRBlockEntityRegistry.CORRIDOR_TELEPORTER.get(), blockPos, blockState); | ||
} | ||
|
||
public void startTeleporterTimer() { | ||
if (cooldownTicks == 0 && timeSinceTriggeredTicks == 0) { | ||
this.timeSinceTriggeredTicks += 1; | ||
level.playSound(null, getBlockPos(), TRSoundRegistry.CORRIDOR_TELEPORTER.get(), SoundSource.BLOCKS, 1, 1); | ||
} | ||
} | ||
|
||
|
||
@Override | ||
public void tick(Level level, BlockPos blockPos, BlockState blockState, CorridorTeleporterBlockEntity blockEntity) { | ||
|
||
// If we're meant to be ticking, let's tick. | ||
if (this.timeSinceTriggeredTicks > 0 && cooldownTicks == 0) { | ||
this.timeSinceTriggeredTicks += 1; | ||
} | ||
|
||
if (this.cooldownTicks > 0) { | ||
this.cooldownTicks -= 1; | ||
} | ||
|
||
if (timeSinceTriggeredTicks == TICKS_TO_TRIGGER_TELEPORT) { | ||
timeSinceTriggeredTicks = 0; | ||
this.cooldownTicks = TICKS_FOR_COOLDOWN; | ||
|
||
if (level.dimensionTypeId() != TRDimensionTypes.TARDIS) { | ||
level.playSound(null, getBlockPos(), SoundEvents.BLAZE_DEATH, SoundSource.BLOCKS, 1, 0.5f); | ||
return; | ||
} | ||
|
||
|
||
if (level instanceof ServerLevel serverLevel) { | ||
AABB box = new AABB(blockPos).inflate(0.25f, 1, 0.25f); | ||
List<Entity> entities = serverLevel.getEntitiesOfClass(Entity.class, box); | ||
BlockPos corridorAirlock = TardisInteriorManager.STATIC_CORRIDOR_POSITION; | ||
for (Entity entity : entities) { | ||
TRTeleporter.performTeleport(entity, serverLevel, corridorAirlock.getX() + 0.5f, corridorAirlock.getY(), corridorAirlock.getZ() + 0.5f, 0,0 ); | ||
} | ||
|
||
if (entities.stream().count() > 0) { | ||
// Play at the source block and at the exit point. | ||
level.playSound(null, getBlockPos(), TRSoundRegistry.CORRIDOR_TELEPORTER_SUCCESS.get(), SoundSource.BLOCKS, 1, 1); | ||
level.playSound(null, corridorAirlock, TRSoundRegistry.CORRIDOR_TELEPORTER_SUCCESS.get(), SoundSource.BLOCKS, 1, 1); | ||
} | ||
} | ||
|
||
|
||
} | ||
} | ||
} |
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
71 changes: 71 additions & 0 deletions
71
common/src/main/resources/assets/tardis_refined/models/block/corridor_teleporter.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,71 @@ | ||
{ | ||
"credit": "Made with Blockbench", | ||
"texture_size": [64, 64], | ||
"textures": { | ||
"1": "tardis_refined:block/corridor_teleporter", | ||
"particle": "tardis_refined:block/corridor_teleporter" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [2, 0, 2], | ||
"to": [14, 2, 14], | ||
"faces": { | ||
"north": {"uv": [3.25, 2.25, 6.25, 3.25], "texture": "#1"}, | ||
"east": {"uv": [0, 6.5, 3, 7.5], "texture": "#1"}, | ||
"south": {"uv": [3.25, 2.25, 6.25, 3.25], "texture": "#1"}, | ||
"west": {"uv": [0, 6.5, 3, 7.5], "texture": "#1"}, | ||
"up": {"uv": [3, 3, 0, 0], "texture": "#1"}, | ||
"down": {"uv": [3, 3.25, 0, 6.25], "texture": "#1"} | ||
} | ||
}, | ||
{ | ||
"from": [4, 1, 4], | ||
"to": [12, 3, 12], | ||
"faces": { | ||
"north": {"uv": [5.5, 1.5, 7.5, 2], "texture": "#1"}, | ||
"east": {"uv": [5.5, 1.5, 7.5, 2], "texture": "#1"}, | ||
"south": {"uv": [5.5, 1.5, 7.5, 2], "texture": "#1"}, | ||
"west": {"uv": [5.5, 1.5, 7.5, 2], "texture": "#1"}, | ||
"up": {"uv": [5.25, 2, 3.25, 0], "texture": "#1"}, | ||
"down": {"uv": [5.25, 0, 3.25, 2], "texture": "#1"} | ||
} | ||
} | ||
], | ||
"display": { | ||
"thirdperson_righthand": { | ||
"rotation": [75, 45, 0], | ||
"translation": [0, 2.5, 2.75], | ||
"scale": [0.375, 0.375, 0.375] | ||
}, | ||
"thirdperson_lefthand": { | ||
"rotation": [75, 45, 0], | ||
"translation": [0, 2.5, 2.75], | ||
"scale": [0.375, 0.375, 0.375] | ||
}, | ||
"firstperson_righthand": { | ||
"rotation": [0, 45, 0], | ||
"translation": [0, 3.75, 0], | ||
"scale": [0.4, 0.4, 0.4] | ||
}, | ||
"firstperson_lefthand": { | ||
"rotation": [0, 45, 0], | ||
"translation": [0, 3.75, 0], | ||
"scale": [0.4, 0.4, 0.4] | ||
}, | ||
"ground": { | ||
"translation": [0, 3, 0], | ||
"scale": [0.75, 0.75, 0.75] | ||
}, | ||
"gui": { | ||
"rotation": [30, 225, 0], | ||
"translation": [0, 3.25, 0], | ||
"scale": [0.75, 0.75, 0.75] | ||
}, | ||
"head": { | ||
"translation": [0, 14.25, 0] | ||
}, | ||
"fixed": { | ||
"translation": [0, 1, 1.25] | ||
} | ||
} | ||
} |
Binary file added
BIN
+860 Bytes
...n/src/main/resources/assets/tardis_refined/models/block/corridor_teleporter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions
71
common/src/main/resources/assets/tardis_refined/models/block/teleporter.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,71 @@ | ||
{ | ||
"credit": "Made with Blockbench", | ||
"texture_size": [64, 64], | ||
"textures": { | ||
"1": "tardis_refined:block/corridor_teleporter", | ||
"particle": "console icons" | ||
}, | ||
"elements": [ | ||
{ | ||
"from": [2, 0, 2], | ||
"to": [14, 2, 14], | ||
"faces": { | ||
"north": {"uv": [3.25, 2.25, 6.25, 3.25], "texture": "#1"}, | ||
"east": {"uv": [0, 6.5, 3, 7.5], "texture": "#1"}, | ||
"south": {"uv": [3.25, 2.25, 6.25, 3.25], "texture": "#1"}, | ||
"west": {"uv": [0, 6.5, 3, 7.5], "texture": "#1"}, | ||
"up": {"uv": [3, 3, 0, 0], "texture": "#1"}, | ||
"down": {"uv": [3, 3.25, 0, 6.25], "texture": "#1"} | ||
} | ||
}, | ||
{ | ||
"from": [4, 1, 4], | ||
"to": [12, 3, 12], | ||
"faces": { | ||
"north": {"uv": [5.5, 1.5, 7.5, 2], "texture": "#1"}, | ||
"east": {"uv": [5.5, 1.5, 7.5, 2], "texture": "#1"}, | ||
"south": {"uv": [5.5, 1.5, 7.5, 2], "texture": "#1"}, | ||
"west": {"uv": [5.5, 1.5, 7.5, 2], "texture": "#1"}, | ||
"up": {"uv": [5.25, 2, 3.25, 0], "texture": "#1"}, | ||
"down": {"uv": [5.25, 0, 3.25, 2], "texture": "#1"} | ||
} | ||
} | ||
], | ||
"display": { | ||
"thirdperson_righthand": { | ||
"rotation": [75, 45, 0], | ||
"translation": [0, 2.5, 2.75], | ||
"scale": [0.375, 0.375, 0.375] | ||
}, | ||
"thirdperson_lefthand": { | ||
"rotation": [75, 45, 0], | ||
"translation": [0, 2.5, 2.75], | ||
"scale": [0.375, 0.375, 0.375] | ||
}, | ||
"firstperson_righthand": { | ||
"rotation": [0, 45, 0], | ||
"translation": [0, 3.75, 0], | ||
"scale": [0.4, 0.4, 0.4] | ||
}, | ||
"firstperson_lefthand": { | ||
"rotation": [0, 45, 0], | ||
"translation": [0, 3.75, 0], | ||
"scale": [0.4, 0.4, 0.4] | ||
}, | ||
"ground": { | ||
"translation": [0, 3, 0], | ||
"scale": [0.75, 0.75, 0.75] | ||
}, | ||
"gui": { | ||
"rotation": [30, 225, 0], | ||
"translation": [0, 3.25, 0], | ||
"scale": [0.75, 0.75, 0.75] | ||
}, | ||
"head": { | ||
"translation": [0, 14.25, 0] | ||
}, | ||
"fixed": { | ||
"translation": [0, 1, 1.25] | ||
} | ||
} | ||
} |
Oops, something went wrong.