generated from FabricMC/fabric-example-mod
-
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.
- Loading branch information
ellieisjelly
committed
Jan 2, 2024
1 parent
f289968
commit 4076c8f
Showing
7 changed files
with
91 additions
and
22 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
2 changes: 1 addition & 1 deletion
2
.../java/me/ellieis/game/SabotageConfig.java → ...ellieis/Sabotage/game/SabotageConfig.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
34 changes: 18 additions & 16 deletions
34
...n/java/me/ellieis/game/SabotageLobby.java → ...e/ellieis/Sabotage/game/SabotageGame.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
46 changes: 46 additions & 0 deletions
46
src/main/java/me/ellieis/Sabotage/game/map/SabotageMap.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.ellieis.Sabotage.game.map; | ||
|
||
import net.minecraft.entity.Entity; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.gen.chunk.ChunkGenerator; | ||
|
||
import xyz.nucleoid.map_templates.MapTemplate; | ||
import xyz.nucleoid.map_templates.TemplateRegion; | ||
import xyz.nucleoid.plasmid.game.world.generator.TemplateChunkGenerator; | ||
|
||
public class SabotageMap { | ||
private final MapTemplate template; | ||
private final TemplateRegion spawn; | ||
|
||
public SabotageMap(MapTemplate template) { | ||
this.template = template; | ||
this.spawn = template.getMetadata().getFirstRegion("spawn"); | ||
} | ||
|
||
public MapTemplate getTemplate() { | ||
return this.template; | ||
} | ||
|
||
public TemplateRegion getSpawn() { | ||
return this.spawn; | ||
} | ||
|
||
public void spawnEntity(ServerWorld world, Entity entity) { | ||
float yaw = this.spawn.getData().getFloat("Rotation"); | ||
Vec3d pos = this.spawn.getBounds().center(); | ||
if (entity instanceof ServerPlayerEntity) { | ||
ServerPlayerEntity plr = (ServerPlayerEntity) entity; | ||
plr.teleport(world, pos.getX(), pos.getY(), pos.getZ(), yaw, 0); | ||
} else { | ||
entity.teleport(pos.getX(), pos.getY(), pos.getZ()); | ||
entity.setYaw(yaw); | ||
} | ||
} | ||
|
||
public ChunkGenerator asChunkGenerator(MinecraftServer server) { | ||
return new TemplateChunkGenerator(server, this.template); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/me/ellieis/Sabotage/game/map/SabotageMapBuilder.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,21 @@ | ||
package me.ellieis.Sabotage.game.map; | ||
|
||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Identifier; | ||
import xyz.nucleoid.map_templates.MapTemplate; | ||
import xyz.nucleoid.map_templates.MapTemplateSerializer; | ||
import xyz.nucleoid.plasmid.game.GameOpenException; | ||
|
||
import java.io.IOException; | ||
|
||
public class SabotageMapBuilder { | ||
public static SabotageMap build(MinecraftServer server, Identifier identifier) { | ||
try { | ||
MapTemplate template = MapTemplateSerializer.loadFromResource(server, identifier); | ||
return new SabotageMap(template); | ||
} catch(IOException exception) { | ||
throw new GameOpenException(Text.of("Failed to load map " + identifier), exception); | ||
} | ||
} | ||
} |
Binary file not shown.
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