Update
This commit is contained in:
parent
64c6f17d7f
commit
6c2df592c5
12
README.md
12
README.md
@ -1,15 +1,15 @@
|
|||||||
# Jump Vader - A Fabric Server-Side Elevator Mod
|
# Televator - A Fabric Server-Side Elevator Mod
|
||||||
|
|
||||||
|
based on [JumpVader](https://github.com/StimzRx/JumpVaderMod) by [StimzRx](https://github.com/StimzRx/JumpVaderMod)
|
||||||
|
|
||||||
## What is it
|
## What is it
|
||||||
I'ts a mod that lets you place "Jump Vader" blocks similar to the Quark mod's elevators.
|
It's a mod that lets you place "Jump Vader" blocks similar to the Quark mod's elevators.
|
||||||
You simply place one above the other at any vertical distance, and jump/crouch on top of the
|
You simply place one above the other at any vertical distance, and jump/crouch on top of the
|
||||||
block to go in between the different heights.
|
block to go in between the different heights.
|
||||||
|
|
||||||
## Crafting
|
## Crafting
|
||||||
![Crafting Recipe](https://github.com/VenomCodeDev/JumpVaderMod/blob/d1cd96ccd846d3249a4a7fcb298e740775ee344c/assets/JumpVaderCraftingRecipe.png?raw=true)
|
![Crafting Recipe](https://github.com/VenomCodeDev/TelevatorMod/blob/d1cd96ccd846d3249a4a7fcb298e740775ee344c/assets/TelevatorCraftingRecipe.png?raw=true)
|
||||||
|
|
||||||
## Removal
|
## Removal
|
||||||
If you've spotted a bug and want to DISABLE the JumpVader's, please do so via the config file in your servers Config folder.
|
|
||||||
Otherwise, just stop the server, delete the mod from the mods folder, and start the server back up.
|
|
||||||
|
|
||||||
**NOTE:** Removing the mods from the mods folder will delete all JumpVader blocks in inventories and the world permanently!
|
**NOTE:** Removing the mods from the mods folder will delete all Televator blocks in inventories and the world permanently!
|
||||||
|
34
build.gradle
34
build.gradle
@ -1,6 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.2-SNAPSHOT'
|
id 'fabric-loom' version '1.6-SNAPSHOT'
|
||||||
id 'maven-publish'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
version = project.mod_version
|
version = project.mod_version
|
||||||
@ -16,10 +15,7 @@ repositories {
|
|||||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||||
// for more information about repositories.
|
// for more information about repositories.
|
||||||
|
|
||||||
maven { url 'https://maven.nucleoid.xyz' }
|
maven { url 'https://maven.nucleoid.xyz' }
|
||||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
|
|
||||||
maven { url "https://api.modrinth.com/maven" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -31,16 +27,11 @@ dependencies {
|
|||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
// Uncomment the following line to enable the deprecated Fabric API modules.
|
|
||||||
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
include(modImplementation("maven.modrinth:server-api:${project.serverapi_version}"))
|
|
||||||
|
|
||||||
include(modImplementation('me.lucko:fabric-permissions-api:0.2-SNAPSHOT'))
|
|
||||||
|
|
||||||
include(modImplementation("eu.pb4:polymer-core:${project.polymer_version}"))
|
include(modImplementation("eu.pb4:polymer-core:${project.polymer_version}"))
|
||||||
|
modImplementation include("eu.pb4:polymer-resource-pack:${project.polymer_version}")
|
||||||
|
modImplementation include("eu.pb4:polymer-autohost:${project.polymer_version}")
|
||||||
|
modImplementation include("eu.pb4:polymer-blocks:${project.polymer_version}")
|
||||||
include(modImplementation("xyz.nucleoid:server-translations-api:${project.server_translations_api_version}"))
|
include(modImplementation("xyz.nucleoid:server-translations-api:${project.server_translations_api_version}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,21 +61,4 @@ jar {
|
|||||||
from("LICENSE") {
|
from("LICENSE") {
|
||||||
rename { "${it}_${project.archivesBaseName}"}
|
rename { "${it}_${project.archivesBaseName}"}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// configure the maven publication
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
mavenJava(MavenPublication) {
|
|
||||||
from components.java
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
|
||||||
repositories {
|
|
||||||
// Add repositories to publish to here.
|
|
||||||
// Notice: This block does NOT have the same function as the block in the top level.
|
|
||||||
// The repositories here will be used for publishing your artifact, not for
|
|
||||||
// retrieving dependencies.
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,17 +4,17 @@ org.gradle.parallel=true
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=1.20.1
|
minecraft_version=1.20.4
|
||||||
yarn_mappings=1.20.1+build.2
|
yarn_mappings=1.20.4+build.3
|
||||||
loader_version=0.14.21
|
loader_version=0.15.9
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.0.9+1.20.1
|
mod_version = 1.0.9+1.20.4
|
||||||
maven_group = dev.venomcode.jumpvader
|
maven_group = systems.brn.televator
|
||||||
archives_base_name = jumpvader
|
archives_base_name = televator
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.83.1+1.20.1
|
fabric_version=0.96.11+1.20.4
|
||||||
serverapi_version=1.0.7+1.20.1
|
serverapi_version=1.0.8+1.20.1
|
||||||
polymer_version=0.5.2+1.20.1
|
polymer_version=0.7.7+1.20.4
|
||||||
server_translations_api_version=2.0.0+1.20
|
server_translations_api_version=2.2.0+1.20.3-rc1
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
package dev.venomcode.jumpvader;
|
|
||||||
|
|
||||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
|
||||||
import org.spongepowered.configurate.ConfigurateException;
|
|
||||||
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
|
|
||||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
|
||||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
|
||||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
|
||||||
import org.spongepowered.configurate.serialize.SerializationException;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
@ConfigSerializable
|
|
||||||
public class JumpVaderConfig
|
|
||||||
{
|
|
||||||
|
|
||||||
public boolean getEnabled()
|
|
||||||
{
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxVerticalBlocks()
|
|
||||||
{
|
|
||||||
return maxVerticleBlocks;
|
|
||||||
}
|
|
||||||
public String getAlternativeBlock()
|
|
||||||
{
|
|
||||||
return placeholderBlockRaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Setting("mod enabled")
|
|
||||||
@Comment("Toggles the entire mod on/off. Doesnt delete blocks/items if set to off!")
|
|
||||||
private boolean enabled = true;
|
|
||||||
|
|
||||||
@Setting("max vertical blocks")
|
|
||||||
@Comment("The maximum amount of blocks a player can move vertically using the jump vader")
|
|
||||||
private int maxVerticleBlocks = 128;
|
|
||||||
|
|
||||||
@Setting("display block")
|
|
||||||
@Comment("Sets the 'fake' block to display as a placeholder for the jump vader block.")
|
|
||||||
private String placeholderBlockRaw = "minecraft:orange_wool";
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
package dev.venomcode.jumpvader;
|
|
||||||
|
|
||||||
import dev.venomcode.jumpvader.blocks.JumpVaderBlock;
|
|
||||||
import dev.venomcode.serverapi.api.ServerAPI;
|
|
||||||
import dev.venomcode.serverapi.api.event.SAPIPlayerEvents;
|
|
||||||
import eu.pb4.polymer.core.api.item.PolymerBlockItem;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
|
||||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.registry.Registries;
|
|
||||||
import net.minecraft.registry.Registry;
|
|
||||||
import net.minecraft.util.ActionResult;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
|
||||||
import org.spongepowered.configurate.ConfigurateException;
|
|
||||||
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
public class JumpVaderMod implements ModInitializer {
|
|
||||||
// This logger is used to write text to the console and the log file.
|
|
||||||
// It is considered best practice to use your mod id as the logger's name.
|
|
||||||
// That way, it's clear which mod wrote info, warnings, and errors.
|
|
||||||
public static final String MODID = "jumpvader";
|
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger(MODID);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInitialize()
|
|
||||||
{
|
|
||||||
JumpVaderConfig config = getConfig();
|
|
||||||
saveConfig();
|
|
||||||
|
|
||||||
Identifier jumpVaderProxyIdent = new Identifier(config.getAlternativeBlock());
|
|
||||||
Item jumpVaderProxyItem = Registries.ITEM.get(jumpVaderProxyIdent);
|
|
||||||
|
|
||||||
JUMP_VADER_BLOCK = new JumpVaderBlock(FabricBlockSettings.copyOf(Blocks.BAMBOO_PLANKS), Registries.BLOCK.get(jumpVaderProxyIdent));
|
|
||||||
|
|
||||||
Registry.register(Registries.BLOCK, new Identifier(JumpVaderMod.MODID, "jumpvader_block"), JUMP_VADER_BLOCK);
|
|
||||||
|
|
||||||
Registry.register( Registries.ITEM, new Identifier(JumpVaderMod.MODID, "jumpvader_block"), new PolymerBlockItem( JUMP_VADER_BLOCK, new FabricItemSettings(), jumpVaderProxyItem ) );
|
|
||||||
|
|
||||||
SAPIPlayerEvents.JUMP.register((player -> {
|
|
||||||
if(!config.getEnabled())
|
|
||||||
return true;
|
|
||||||
BlockPos testPos = player.getBlockPos().down();
|
|
||||||
if(player.getWorld().getBlockState(testPos).getBlock() instanceof JumpVaderBlock jumpVaderBlock)
|
|
||||||
{
|
|
||||||
return !jumpVaderBlock.onJump(testPos, player);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}));
|
|
||||||
|
|
||||||
SAPIPlayerEvents.SNEAK.register((player -> {
|
|
||||||
if(!config.getEnabled())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
BlockPos testPos = player.getBlockPos().down();
|
|
||||||
if(player.getWorld().getBlockState(testPos).getBlock() instanceof JumpVaderBlock jumpVaderBlock) {
|
|
||||||
jumpVaderBlock.onCrouch(testPos, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
public static JumpVaderBlock JUMP_VADER_BLOCK;
|
|
||||||
|
|
||||||
public static JumpVaderConfig getConfig() {
|
|
||||||
if(_configCached != null)
|
|
||||||
return _configCached;
|
|
||||||
|
|
||||||
try {
|
|
||||||
CommentedConfigurationNode node = configLoader.load();
|
|
||||||
|
|
||||||
_configCached = node.get(JumpVaderConfig.class);
|
|
||||||
}
|
|
||||||
catch (ConfigurateException ex) {
|
|
||||||
LOGGER.error(ServerAPI.Logger.Error("[ERROR]Failed to load jump_vader config."));
|
|
||||||
}
|
|
||||||
|
|
||||||
return _configCached;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void saveConfig() {
|
|
||||||
CommentedConfigurationNode node = CommentedConfigurationNode.root();
|
|
||||||
try {
|
|
||||||
node.set(JumpVaderConfig.class, _configCached);
|
|
||||||
configLoader.save(node);
|
|
||||||
}
|
|
||||||
catch (ConfigurateException ex) {
|
|
||||||
LOGGER.error(ServerAPI.Logger.Error("[ERROR]Failed to save jump_vader config."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final HoconConfigurationLoader configLoader = HoconConfigurationLoader.builder()
|
|
||||||
.path(Path.of(ServerAPI.CONFIG_PATH + "jump_vader.conf"))
|
|
||||||
.build();
|
|
||||||
private static JumpVaderConfig _configCached = null;
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
package dev.venomcode.jumpvader.blocks;
|
|
||||||
|
|
||||||
import dev.venomcode.jumpvader.JumpVaderMod;
|
|
||||||
import dev.venomcode.jumpvader.ifaces.IJumpVaderListener;
|
|
||||||
import eu.pb4.polymer.core.api.block.PolymerBlock;
|
|
||||||
import eu.pb4.polymer.core.api.block.SimplePolymerBlock;
|
|
||||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|
||||||
import net.minecraft.block.AbstractBlock;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.particle.ParticleTypes;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import net.minecraft.server.world.ServerWorld;
|
|
||||||
import net.minecraft.sound.SoundCategory;
|
|
||||||
import net.minecraft.sound.SoundEvents;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
public class JumpVaderBlock extends SimplePolymerBlock implements IJumpVaderListener {
|
|
||||||
|
|
||||||
public JumpVaderBlock(Settings settings, Block polymerBlock) {
|
|
||||||
super(settings, polymerBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onJump(BlockPos pos , ServerPlayerEntity player )
|
|
||||||
{
|
|
||||||
if(!JumpVaderMod.getConfig().getEnabled())
|
|
||||||
return false;
|
|
||||||
pos = pos.up();
|
|
||||||
ServerWorld w = (ServerWorld) player.getWorld();
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
while(count < JumpVaderMod.getConfig().getMaxVerticalBlocks() && pos.getY() < 316)
|
|
||||||
{
|
|
||||||
Block blk = w.getBlockState( pos ).getBlock();
|
|
||||||
|
|
||||||
if(blk instanceof JumpVaderBlock)
|
|
||||||
{
|
|
||||||
final BlockPos tpPos = pos.up();
|
|
||||||
|
|
||||||
if(w.getBlockState( tpPos ).getBlock().equals( Blocks.AIR ) && w.getBlockState( tpPos.up() ).getBlock().equals( Blocks.AIR ))
|
|
||||||
{
|
|
||||||
player.teleport( tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f );
|
|
||||||
|
|
||||||
w.playSound( null, tpPos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 0.5f, 1.5f );
|
|
||||||
w.spawnParticles( ParticleTypes.POOF, tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, 5, 0, 0, 0, 0.25f );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pos = pos.up();
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCrouch( BlockPos pos , ServerPlayerEntity player )
|
|
||||||
{
|
|
||||||
if(!JumpVaderMod.getConfig().getEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
pos = pos.down();
|
|
||||||
ServerWorld w = (ServerWorld) player.getWorld();
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
while(count < JumpVaderMod.getConfig().getMaxVerticalBlocks() && pos.getY() >= -64)
|
|
||||||
{
|
|
||||||
Block blk = w.getBlockState( pos ).getBlock();
|
|
||||||
|
|
||||||
if(blk instanceof JumpVaderBlock)
|
|
||||||
{
|
|
||||||
final BlockPos tpPos = pos.up();
|
|
||||||
|
|
||||||
if(w.getBlockState( tpPos ).getBlock().equals( Blocks.AIR ) && w.getBlockState( tpPos.up() ).getBlock().equals( Blocks.AIR ))
|
|
||||||
{
|
|
||||||
player.teleport( tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f );
|
|
||||||
|
|
||||||
w.playSound( null, tpPos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 0.5f, 1.5f );
|
|
||||||
w.spawnParticles( ParticleTypes.POOF, tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, 5, 0, 0, 0, 0.25f );
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pos = pos.down();
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Identifier _identifier = new Identifier( JumpVaderMod.MODID, "jumpvader_block" );
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package dev.venomcode.jumpvader.ifaces;
|
|
||||||
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
public interface IJumpVaderListener
|
|
||||||
{
|
|
||||||
boolean onJump(BlockPos pos, ServerPlayerEntity player );
|
|
||||||
void onCrouch( BlockPos pos, ServerPlayerEntity player );
|
|
||||||
}
|
|
47
src/main/java/systems/brn/televator/Televator.java
Normal file
47
src/main/java/systems/brn/televator/Televator.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package systems.brn.televator;
|
||||||
|
|
||||||
|
import systems.brn.televator.blocks.TelevatorBlock;
|
||||||
|
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public class Televator implements ModInitializer {
|
||||||
|
public static final String MODID = "televator";
|
||||||
|
public static final String MODELID = "televator";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onInitialize()
|
||||||
|
{
|
||||||
|
|
||||||
|
PolymerResourcePackUtils.addModAssets(MODID);
|
||||||
|
PolymerResourcePackUtils.markAsRequired();
|
||||||
|
|
||||||
|
TelevatorBlock.register();
|
||||||
|
|
||||||
|
|
||||||
|
ServerTickEvents.END_SERVER_TICK.register(server -> {
|
||||||
|
// Iterate over all online players
|
||||||
|
server.getPlayerManager().getPlayerList().forEach(player -> {
|
||||||
|
// Check if the player is sneaking
|
||||||
|
if (player.isSneaking() && player.isOnGround()) {
|
||||||
|
BlockPos testPos = player.getBlockPos().down();
|
||||||
|
if(player.getWorld().getBlockState(testPos).getBlock() instanceof TelevatorBlock jumpVaderBlock) {
|
||||||
|
jumpVaderBlock.handleMovement(testPos, player, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the player is jumping
|
||||||
|
if (player.getVelocity().y > 0 && !player.isOnGround()) {
|
||||||
|
BlockPos testPos = player.getBlockPos().down();
|
||||||
|
if(player.getWorld().getBlockState(testPos).getBlock() instanceof TelevatorBlock jumpVaderBlock)
|
||||||
|
{
|
||||||
|
jumpVaderBlock.handleMovement(testPos, player, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public static TelevatorBlock JUMP_VADER_BLOCK;
|
||||||
|
|
||||||
|
}
|
12
src/main/java/systems/brn/televator/TelevatorConfig.java
Normal file
12
src/main/java/systems/brn/televator/TelevatorConfig.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package systems.brn.televator;
|
||||||
|
|
||||||
|
public class TelevatorConfig {
|
||||||
|
public static int getMaxVerticalBlocks()
|
||||||
|
{
|
||||||
|
return 128;
|
||||||
|
}
|
||||||
|
public static String getAlternativeBlock()
|
||||||
|
{
|
||||||
|
return "minecraft:orange_wool";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package systems.brn.televator.blocks;
|
||||||
|
|
||||||
|
import systems.brn.televator.Televator;
|
||||||
|
import systems.brn.televator.TelevatorConfig;
|
||||||
|
import systems.brn.televator.items.TelevatorBlockItem;
|
||||||
|
import eu.pb4.polymer.blocks.api.BlockModelType;
|
||||||
|
import eu.pb4.polymer.blocks.api.PolymerBlockModel;
|
||||||
|
import eu.pb4.polymer.blocks.api.PolymerTexturedBlock;
|
||||||
|
import eu.pb4.polymer.blocks.api.PolymerBlockResourceUtils;
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.particle.ParticleTypes;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
|
import net.minecraft.sound.SoundCategory;
|
||||||
|
import net.minecraft.sound.SoundEvents;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public class TelevatorBlock extends Block implements PolymerTexturedBlock {
|
||||||
|
|
||||||
|
private final BlockState polymerBlockState;
|
||||||
|
|
||||||
|
public TelevatorBlock(Settings settings, BlockModelType type, String modelId) {
|
||||||
|
super(settings);
|
||||||
|
this.polymerBlockState = PolymerBlockResourceUtils.requestBlock(type, PolymerBlockModel.of(new Identifier(Televator.MODID, modelId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Block getPolymerBlock(BlockState state) {
|
||||||
|
return this.polymerBlockState.getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getPolymerBlockState(BlockState state) {
|
||||||
|
return this.polymerBlockState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void register() {
|
||||||
|
var modId = new Identifier(Televator.MODID, Televator.MODELID);
|
||||||
|
var block = Registry.register(Registries.BLOCK, modId,
|
||||||
|
new TelevatorBlock(FabricBlockSettings.copy(Blocks.WHITE_WOOL), BlockModelType.FULL_BLOCK, Televator.MODELID));
|
||||||
|
|
||||||
|
Registry.register(Registries.ITEM, modId, new TelevatorBlockItem(new Item.Settings(), block, Televator.MODELID));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleMovement(BlockPos pos, ServerPlayerEntity player, boolean isJumping) {
|
||||||
|
pos = isJumping ? pos.up() : pos.down();
|
||||||
|
ServerWorld world = (ServerWorld) player.getWorld();
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
while (count < TelevatorConfig.getMaxVerticalBlocks() && pos.getY() < world.getTopY() && pos.getY() >= world.getBottomY()) {
|
||||||
|
Block blk = world.getBlockState(pos).getBlock();
|
||||||
|
|
||||||
|
if (blk instanceof TelevatorBlock) {
|
||||||
|
final BlockPos tpPos = pos.up();
|
||||||
|
|
||||||
|
if (world.getBlockState(tpPos).getBlock().equals(Blocks.AIR) && world.getBlockState(tpPos.up()).getBlock().equals(Blocks.AIR)) {
|
||||||
|
teleportWithEffect(player, world, tpPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pos = isJumping ? pos.up() : pos.down();
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void teleportWithEffect(ServerPlayerEntity player, ServerWorld w, BlockPos tpPos) {
|
||||||
|
player.teleport(tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f);
|
||||||
|
w.playSound(null, tpPos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 0.5f, 1.5f);
|
||||||
|
w.spawnParticles(ParticleTypes.POOF, tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, 5, 0, 0, 0, 0.25f);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package systems.brn.televator.items;
|
||||||
|
|
||||||
|
import systems.brn.televator.Televator;
|
||||||
|
import eu.pb4.polymer.core.api.item.PolymerItem;
|
||||||
|
import eu.pb4.polymer.resourcepack.api.PolymerModelData;
|
||||||
|
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.item.BlockItem;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class TelevatorBlockItem extends BlockItem implements PolymerItem {
|
||||||
|
private final PolymerModelData polymerModel;
|
||||||
|
|
||||||
|
public TelevatorBlockItem(Settings settings, Block block, String modelId) {
|
||||||
|
super(block, settings);
|
||||||
|
this.polymerModel = PolymerResourcePackUtils.requestModel(Items.BARRIER, new Identifier(Televator.MODID, modelId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
|
||||||
|
return this.polymerModel.item();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPolymerCustomModelData(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
|
||||||
|
return this.polymerModel.value();
|
||||||
|
}
|
||||||
|
}
|
BIN
src/main/resources/assets/icon.png
Normal file
BIN
src/main/resources/assets/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 225 B |
Binary file not shown.
Before Width: | Height: | Size: 453 B |
3
src/main/resources/assets/televator/lang/en_us.json
Normal file
3
src/main/resources/assets/televator/lang/en_us.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"block.televator.televator": "Jump Vader"
|
||||||
|
}
|
BIN
src/main/resources/assets/televator/textures/block/televator.png
Normal file
BIN
src/main/resources/assets/televator/textures/block/televator.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 225 B |
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"block.jumpvader.jumpvader_block": "Jump Vader"
|
|
||||||
}
|
|
@ -6,7 +6,7 @@
|
|||||||
"entries": [
|
"entries": [
|
||||||
{
|
{
|
||||||
"type": "minecraft:item",
|
"type": "minecraft:item",
|
||||||
"name": "jumpvader:jumpvader_block"
|
"name": "televator:televator"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"conditions": [
|
"conditions": [
|
@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
"item": "jumpvader:jumpvader_block",
|
"item": "televator:televator",
|
||||||
"count": 2
|
"count": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,38 +1,34 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "jumpvader",
|
"id": "televator",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
|
|
||||||
"name": "Jump Vader",
|
"name": "Jump Vader",
|
||||||
"description": "Ender Vaders ServerSide Only",
|
"description": "Ender Vaders ServerSide Only",
|
||||||
"authors": [
|
"authors": [
|
||||||
"VenomCodeDev"
|
"VenomCodeDev",
|
||||||
|
"BRNSystems"
|
||||||
],
|
],
|
||||||
"contact": {
|
"contact": {
|
||||||
"homepage": "https://github.com/VenomCodeDev/JumpVaderMod",
|
"homepage": "https://github.com/VenomCodeDev/TelevatorMod",
|
||||||
"sources": "https://github.com/VenomCodeDev/JumpVaderMod"
|
"sources": "https://github.com/VenomCodeDev/TelevatorMod"
|
||||||
},
|
},
|
||||||
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"icon": "assets/jumpvader/icon.png",
|
"icon": "assets/icon.png",
|
||||||
|
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"dev.venomcode.jumpvader.JumpVaderMod"
|
"systems.brn.televator.Televator"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
|
||||||
"jumpvader.mixins.json"
|
|
||||||
],
|
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.21",
|
"fabricloader": ">=0.15.9",
|
||||||
"minecraft": "~1.20.1",
|
"minecraft": "~1.20.4",
|
||||||
"java": ">=17",
|
"java": ">=17",
|
||||||
"fabric-api": "*"
|
"fabric-api": "*",
|
||||||
},
|
"polymer-core": "0.7.7+1.20.4"
|
||||||
"suggests": {
|
|
||||||
"another-mod": "*"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"required": true,
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"package": "dev.venomcode.jumpvader.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_17",
|
|
||||||
"mixins": [
|
|
||||||
],
|
|
||||||
"client": [
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user