Initial Commit for 1.19.2

This commit is contained in:
VenomCodeDev 2022-10-11 22:00:30 -05:00
parent 91ff57231d
commit d1cd96ccd8
17 changed files with 375 additions and 65 deletions

@ -1,9 +1,9 @@
# Fabric Example Mod
# Jump Vader - A Fabric Server-Side Elevator Mod
## Setup
## What is it
I'ts 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
block to go in between the different heights.
For setup instructions please see the [fabric wiki page](https://fabricmc.net/wiki/tutorial:setup) that relates to the IDE that you are using.
## License
This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.
## Crafting
![Crafting Recipe](https://raw.githubusercontent.com/VenomCodeDev/JumpVaderMod/1.19/assets/JumpVaderCraftingRecipe.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

@ -1,6 +1,7 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
sourceCompatibility = JavaVersion.VERSION_17
@ -16,6 +17,9 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
mavenCentral()
maven { url 'https://maven.nucleoid.xyz' }
}
dependencies {
@ -27,10 +31,15 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Uncomment the following line to enable the deprecated Fabric API modules.
// 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.
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
shadow(implementation('org.spongepowered:configurate-hocon:4.1.2'))
modImplementation include("eu.pb4:polymer:${project.polymer_version}")
modImplementation include("fr.catcore:server-translations-api:${project.server_translation_api_version}")
}
processResources {
@ -57,6 +66,18 @@ jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
archiveClassifier.set("dev")
}
shadowJar {
configurations = [project.configurations.shadow]
archiveClassifier.set("dev")
relocate "net.objecthunter", "de.siphalor.spiceoffabric.shadow.net.objecthunter"
}
remapJar {
dependsOn(shadowJar)
inputFile = tasks.shadowJar.archiveFile
}
// configure the maven publication

@ -2,15 +2,17 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.8
loader_version=0.14.9
# check these on https://fabricmc.net/develop
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.20
loader_version=0.14.9
# Mod Properties
mod_version = 1.0.0
maven_group = com.example
archives_base_name = fabric-example-mod
mod_version = 1.0.0
maven_group = dev.venomcode
archives_base_name = jump-vader
# Dependencies
fabric_version=0.60.0+1.19.2
fabric_version=0.62.0+1.19.2
polymer_version=0.2.16+1.19.2
server_translation_api_version=1.4.17+1.19.2

@ -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;
}

@ -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

@ -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"
}
]
}
]
}

@ -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