forked from Makkuusen/TimingSystem
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds version check to original Mak code. Still need to add command to toggle and configuration option.
- Loading branch information
Showing
7 changed files
with
158 additions
and
10 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
46 changes: 46 additions & 0 deletions
46
src/main/java/me/makkuusen/timing/system/boat/v1_20_R1/BoatSpawner.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,46 @@ | ||
package me.makkuusen.timing.system.boat.v1_20_R1; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.craftbukkit.v1_20_R1.CraftServer; | ||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld; | ||
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftBoat; | ||
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftChestBoat; | ||
import org.bukkit.event.entity.CreatureSpawnEvent; | ||
|
||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.entity.vehicle.Boat; | ||
|
||
public class BoatSpawner { | ||
|
||
public static org.bukkit.entity.Boat spawnBoat(Location location) { | ||
ServerLevel level = ((CraftWorld) location.getWorld()).getHandle(); | ||
CollisionlessBoat boat = new CollisionlessBoat(level, location.getX(), location.getY(), location.getZ()); | ||
float yaw = Location.normalizeYaw(location.getYaw()); | ||
boat.setYRot(yaw); | ||
boat.yRotO = yaw; | ||
boat.setYHeadRot(yaw); | ||
level.addFreshEntity(boat, CreatureSpawnEvent.SpawnReason.COMMAND); | ||
boat.setVariant(Boat.Type.OAK); | ||
var craftBoat = new CraftBoat((CraftServer) Bukkit.getServer(), boat); | ||
return craftBoat; | ||
} | ||
|
||
public static org.bukkit.entity.ChestBoat spawnChestBoat(Location location) { | ||
ServerLevel level = ((CraftWorld) location.getWorld()).getHandle(); | ||
CollisionlessChestBoat boat = new CollisionlessChestBoat(level, location.getX(), location.getY(), location.getZ()); | ||
float yaw = Location.normalizeYaw(location.getYaw()); | ||
boat.setYRot(yaw); | ||
boat.yRotO = yaw; | ||
boat.setYHeadRot(yaw); | ||
level.addFreshEntity(boat, CreatureSpawnEvent.SpawnReason.COMMAND); | ||
boat.setVariant(Boat.Type.OAK); | ||
var craftBoat = new CraftChestBoat((CraftServer) Bukkit.getServer(), boat); | ||
return craftBoat; | ||
} | ||
|
||
public boolean isCollisionless(org.bukkit.entity.Boat boat) { | ||
return ((CraftBoat) boat).getHandle() instanceof CollisionlessBoat; | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/me/makkuusen/timing/system/boat/v1_20_R1/CollisionlessBoat.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,18 @@ | ||
package me.makkuusen.timing.system.boat.v1_20_R1; | ||
|
||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.vehicle.Boat; | ||
import net.minecraft.world.level.Level; | ||
|
||
public class CollisionlessBoat extends Boat { | ||
|
||
public CollisionlessBoat(Level world, double d0, double d1, double d2) { | ||
super(world, d0, d1, d2); | ||
} | ||
|
||
@Override | ||
public boolean canCollideWith(Entity entity) { | ||
return false; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/me/makkuusen/timing/system/boat/v1_20_R1/CollisionlessChestBoat.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,22 @@ | ||
package me.makkuusen.timing.system.boat.v1_20_R1; | ||
|
||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.entity.vehicle.ChestBoat; | ||
import net.minecraft.world.level.Level; | ||
|
||
public class CollisionlessChestBoat extends ChestBoat { | ||
|
||
public CollisionlessChestBoat(Level world, double d0, double d1, double d2) { | ||
super(world, d0, d1, d2); | ||
} | ||
|
||
public CollisionlessChestBoat(EntityType<? extends ChestBoat> entitytypes, Level world) { | ||
super(entitytypes, world); | ||
} | ||
|
||
@Override | ||
public boolean canCollideWith(Entity entity) { | ||
return false; | ||
} | ||
} |
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