Skip to content

Commit

Permalink
Fixed bugs related to sit down on Bench
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiYueCommentary committed Aug 5, 2024
1 parent b113e08 commit 2cac3a2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion fabric/src/main/java/ziyue/tjmetro/mod/EntityTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public interface EntityTypes
{
EntityTypeRegistryObject<EntitySeat> SEAT = Registry.registerEntityType("seat", EntitySeat::new, Float.MIN_VALUE, Float.MIN_VALUE);
EntityTypeRegistryObject<EntitySeat> SEAT = Registry.registerEntityType("seat", EntitySeat::new, 0, 0);

static void registerEntities() {
// Calling this class to initialize constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public BlockBench(BlockSettings blockSettings) {
@Nonnull
@Override
public ActionResult onUse2(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
Entity entity = new Entity(new EntitySeat(world, pos.getX() + 0.5, pos.getY() + 0.35, pos.getZ() + 0.5));
Entity entity = new Entity(new EntitySeat(world, pos.getX() + 0.5, pos.getY() + 0.55, pos.getZ() + 0.5));
world.spawnEntity(entity);
player.startRiding(entity);
return ActionResult.SUCCESS;
Expand Down
12 changes: 3 additions & 9 deletions fabric/src/main/java/ziyue/tjmetro/mod/entity/EntitySeat.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,8 @@ public boolean doesNotCollide2(double offsetX, double offsetY, double offsetZ) {
}

@Override
public void tick2() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (!this.hasPassenger2(new Entity(this))) {
this.kill2();
}
protected void removePassenger2(Entity passenger) {
super.removePassenger2(passenger);
if (!getWorld().isClient()) this.kill2();
}
}

0 comments on commit 2cac3a2

Please sign in to comment.