Initial Commit for 1.19.2
This commit is contained in:
82
src/main/java/dev/venomcode/jumpvader/JumpVaderConfig.java
Normal file
82
src/main/java/dev/venomcode/jumpvader/JumpVaderConfig.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package dev.venomcode.jumpvader;
|
||||
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class JumpVaderConfig
|
||||
{
|
||||
|
||||
public boolean getEnabled()
|
||||
{
|
||||
return rootNode.node(ENABLED_TAG).getBoolean(true);
|
||||
}
|
||||
|
||||
public int getMaxVerticalBlocks()
|
||||
{
|
||||
return rootNode.node(MAX_VERTICAL_BLOCKS_TAG).getInt(128);
|
||||
}
|
||||
|
||||
public void setupConfig() throws SerializationException
|
||||
{
|
||||
|
||||
rootNode.node(ENABLED_TAG).comment(ENABLED_TAG_COMMENT).set(getEnabled());
|
||||
rootNode.node(MAX_VERTICAL_BLOCKS_TAG).comment(MAX_VERTICAL_BLOCKS_TAG_COMMENT).set(getMaxVerticalBlocks());
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
// NODE LOCATION TAGS & COMMENTS
|
||||
private static final String ENABLED_TAG = "enabled";
|
||||
private static final String ENABLED_TAG_COMMENT = "Toggles this entire mod on and off.";
|
||||
private static final String MAX_VERTICAL_BLOCKS_TAG = "max_blocks_vertical";
|
||||
private static final String MAX_VERTICAL_BLOCKS_TAG_COMMENT = "The maximum amount of vertical blocks to travel when using the jump vader block.";
|
||||
|
||||
|
||||
public JumpVaderConfig()
|
||||
{
|
||||
loader = HoconConfigurationLoader.builder()
|
||||
.path(Path.of("./config/" + JumpVaderMod.MODID + ".conf"))
|
||||
.build();
|
||||
try
|
||||
{
|
||||
rootNode = loader.load();
|
||||
setupConfig();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
JumpVaderMod.LOGGER.info("Error occurred loading config:" + ex.getMessage());
|
||||
if(ex.getCause() != null)
|
||||
{
|
||||
ex.getCause().printStackTrace();
|
||||
}
|
||||
rootNode = null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean save()
|
||||
{
|
||||
try
|
||||
{
|
||||
loader.save(rootNode);
|
||||
return true;
|
||||
}
|
||||
catch (final ConfigurateException ex)
|
||||
{
|
||||
JumpVaderMod.LOGGER.info("Unable to save config for '" + JumpVaderMod.MODID + "'! Error: " + ex.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private CommentedConfigurationNode getRootNode()
|
||||
{
|
||||
return rootNode;
|
||||
}
|
||||
|
||||
private final HoconConfigurationLoader loader;
|
||||
private CommentedConfigurationNode rootNode;
|
||||
}
|
38
src/main/java/dev/venomcode/jumpvader/JumpVaderMod.java
Normal file
38
src/main/java/dev/venomcode/jumpvader/JumpVaderMod.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package dev.venomcode.jumpvader;
|
||||
|
||||
import dev.venomcode.jumpvader.blocks.JumpVaderBlock;
|
||||
import eu.pb4.polymer.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.block.Material;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
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);
|
||||
private static JumpVaderConfig config;
|
||||
|
||||
@Override
|
||||
public void onInitialize()
|
||||
{
|
||||
config = new JumpVaderConfig();
|
||||
|
||||
Registry.register( Registry.BLOCK, new Identifier(JumpVaderMod.MODID, "jumpvader_block"), JUMP_VADER_BLOCK);
|
||||
|
||||
Registry.register( Registry.ITEM, new Identifier(JumpVaderMod.MODID, "jumpvader_block"), new PolymerBlockItem( JUMP_VADER_BLOCK, new FabricItemSettings(), Items.ORANGE_STAINED_GLASS ) );
|
||||
}
|
||||
public static JumpVaderConfig getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
public static final JumpVaderBlock JUMP_VADER_BLOCK = new JumpVaderBlock(FabricBlockSettings.of(Material.GLASS), Blocks.ORANGE_STAINED_GLASS);
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
package dev.venomcode.jumpvader.blocks;
|
||||
|
||||
import dev.venomcode.jumpvader.JumpVaderMod;
|
||||
import dev.venomcode.jumpvader.ifaces.IJumpVaderListener;
|
||||
import eu.pb4.polymer.api.block.SimplePolymerBlock;
|
||||
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.block.Material;
|
||||
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 virtualBlock)
|
||||
{
|
||||
super(settings, virtualBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onJump(BlockPos pos , ServerPlayerEntity player )
|
||||
{
|
||||
pos = pos.up();
|
||||
ServerWorld w = player.getWorld();
|
||||
int count = 0;
|
||||
|
||||
while(count < JumpVaderMod.getConfig().getMaxVerticalBlocks() && pos.getY() < 318)
|
||||
{
|
||||
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.networkHandler.requestTeleport( tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, player.getHeadYaw(), 0f );
|
||||
|
||||
w.playSound( null, tpPos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 0.5f, 1.5f );
|
||||
w.spawnParticles( ParticleTypes.END_ROD, tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, 10, 0, 0, 0, 0.25f );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
pos = pos.up();
|
||||
count++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCrouch( BlockPos pos , ServerPlayerEntity player )
|
||||
{
|
||||
pos = pos.down();
|
||||
ServerWorld w = 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.networkHandler.requestTeleport( tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, player.getHeadYaw(), 0f );
|
||||
|
||||
w.playSound( null, tpPos, SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 0.5f, 1.5f );
|
||||
w.spawnParticles( ParticleTypes.END_ROD, tpPos.getX() + 0.5f, tpPos.getY(), tpPos.getZ() + 0.5f, 10, 0, 0, 0, 0.25f );
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
pos = pos.down();
|
||||
count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getPolymerBlock(BlockState state)
|
||||
{
|
||||
return Blocks.ORANGE_STAINED_GLASS;
|
||||
}
|
||||
|
||||
private static final Identifier _identifier = new Identifier( JumpVaderMod.MODID, "jumpvader_block" );
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
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 );
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package dev.venomcode.jumpvader.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import dev.venomcode.jumpvader.ifaces.IJumpVaderListener;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.encryption.PlayerPublicKey;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin( ServerPlayerEntity.class )
|
||||
public abstract class ServerPlayerMixin extends PlayerEntity
|
||||
{
|
||||
@Override
|
||||
public void jump( )
|
||||
{
|
||||
BlockPos p = this.getBlockPos().down();
|
||||
Block blk = this.world.getBlockState( p ).getBlock();
|
||||
|
||||
if(blk instanceof IJumpVaderListener bActioner)
|
||||
{
|
||||
if(bActioner.onJump( p, (ServerPlayerEntity ) (Object)this ))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
super.jump( );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSneaking( boolean sneaking )
|
||||
{
|
||||
super.setSneaking( sneaking );
|
||||
if(sneaking)
|
||||
{
|
||||
BlockPos p = this.getBlockPos().down();
|
||||
Block blk = this.world.getBlockState( p ).getBlock();
|
||||
|
||||
if(blk instanceof IJumpVaderListener bActioner)
|
||||
{
|
||||
bActioner.onCrouch( p, (ServerPlayerEntity ) (Object)this );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ServerPlayerMixin(World world , BlockPos pos , float yaw , GameProfile profile, PlayerPublicKey pubKey)
|
||||
{
|
||||
super(world, pos, yaw, profile, pubKey);
|
||||
}
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package net.fabricmc.example;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ExampleMod 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 Logger LOGGER = LoggerFactory.getLogger("modid");
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||
// However, some things (like resources) may still be uninitialized.
|
||||
// Proceed with mild caution.
|
||||
|
||||
LOGGER.info("Hello Fabric world!");
|
||||
}
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
package net.fabricmc.example.mixin;
|
||||
|
||||
import net.fabricmc.example.ExampleMod;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(TitleScreen.class)
|
||||
public class ExampleMixin {
|
||||
@Inject(at = @At("HEAD"), method = "init()V")
|
||||
private void init(CallbackInfo info) {
|
||||
ExampleMod.LOGGER.info("This line is printed by an example mod mixin!");
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 453 B |
3
src/main/resources/data/jumpvader/lang/en_us.json
Normal file
3
src/main/resources/data/jumpvader/lang/en_us.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"block.jumpvader.jumpvader_block": "Jump Vader"
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "jumpvader:jumpvader_block"
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
23
src/main/resources/data/jumpvader/recipes/jump_vader.json
Normal file
23
src/main/resources/data/jumpvader/recipes/jump_vader.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"#A#",
|
||||
"AEA",
|
||||
"#A#"
|
||||
],
|
||||
"key": {
|
||||
"#": {
|
||||
"item": "minecraft:glass"
|
||||
},
|
||||
"A": {
|
||||
"item": "minecraft:amethyst_shard"
|
||||
},
|
||||
"E": {
|
||||
"item": "minecraft:ender_pearl"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "jumpvader:jumpvader_block",
|
||||
"count": 2
|
||||
}
|
||||
}
|
@@ -1,29 +1,29 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "modid",
|
||||
"id": "jumpvader",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "Example Mod",
|
||||
"description": "This is an example description! Tell everyone what your mod is about!",
|
||||
"name": "Jump Vader",
|
||||
"description": "Ender Vaders ServerSide Only",
|
||||
"authors": [
|
||||
"Me!"
|
||||
"VenomCodeDev"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://fabricmc.net/",
|
||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
||||
"homepage": "https://github.com/VenomCodeDev/JumpVaderMod",
|
||||
"sources": "https://github.com/VenomCodeDev/JumpVaderMod"
|
||||
},
|
||||
|
||||
"license": "CC0-1.0",
|
||||
"icon": "assets/modid/icon.png",
|
||||
"icon": "assets/jumpvader/icon.png",
|
||||
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"net.fabricmc.example.ExampleMod"
|
||||
"dev.venomcode.jumpvader.JumpVaderMod"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"modid.mixins.json"
|
||||
"jumpvader.mixins.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
|
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "net.fabricmc.example.mixin",
|
||||
"package": "dev.venomcode.jumpvader.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"ServerPlayerMixin"
|
||||
],
|
||||
"client": [
|
||||
"ExampleMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
Reference in New Issue
Block a user