This commit is contained in:
Bruno Rybársky 2024-11-01 23:28:44 +01:00
parent 419a5ab607
commit e78966f133
No known key found for this signature in database
GPG Key ID: 6C9206A821C70598
11 changed files with 86 additions and 133 deletions

@ -1,40 +0,0 @@
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.
name: build
on: [pull_request, push]
jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [
17, # Current Java LTS & minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-22.04, windows-2022]
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
with:
name: Artifacts
path: build/libs/

@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '1.8-SNAPSHOT'
}
version = project.mod_version

@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.0
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
loader_version=0.16.8
# Mod Properties
mod_version=1.1.9
mod_version=1.2.1
maven_group=systems.brn.televator
archives_base_name=televator
# Dependencies
fabric_version=0.102.1+1.21.1
polymer_version=0.9.9+1.21
server_translations_api_version=2.3.1+1.21-pre2
fabric_version=0.107.0+1.21.3
polymer_version=0.10.1+1.21.3
server_translations_api_version=2.4.0+1.21.2-rc1

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

@ -1,18 +1,23 @@
package systems.brn.televator;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.network.ServerPlayerEntity;
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;
import java.util.HashMap;
import java.util.UUID;
public class Televator implements ModInitializer {
public static final String MODID = "televator";
public static final String MODELID = "televator";
public static final HashMap<UUID, Boolean> primed = new HashMap<>();
@Override
public void onInitialize()
{
public void onInitialize() {
PolymerResourcePackUtils.addModAssets(MODID);
PolymerResourcePackUtils.markAsRequired();
@ -24,24 +29,24 @@ public class Televator implements ModInitializer {
// Iterate over all online players
server.getPlayerManager().getPlayerList().forEach(player -> {
// Check if the player is sneaking
if (player.isSneaking() && player.isOnGround()) {
if (!player.getPlayerInput().sneak() && !player.getPlayerInput().jump()) {
primed.put(player.getUuid(), true);
}
if (primed.getOrDefault(player.getUuid(), false)) {
if (player.getPlayerInput().sneak()) {
BlockPos testPos = player.getBlockPos().down();
if (player.getWorld().getBlockState(testPos).getBlock() instanceof TelevatorBlock televatorBlock) {
televatorBlock.handleMovement(testPos, player, false);
}
}
// Check if the player is jumping
if (player.getVelocity().y > 0 && !player.isOnGround()) {
} else if (player.getPlayerInput().jump()) {
BlockPos testPos = player.getBlockPos().down();
if(player.getWorld().getBlockState(testPos).getBlock() instanceof TelevatorBlock televatorBlock)
{
if (player.getWorld().getBlockState(testPos).getBlock() instanceof TelevatorBlock televatorBlock) {
televatorBlock.handleMovement(testPos, player, true);
}
}
}
});
});
}
public static TelevatorBlock JUMP_VADER_BLOCK;
}

@ -1,12 +0,0 @@
package systems.brn.televator;
public class TelevatorConfig {
public static int getMaxVerticalBlocks()
{
return 128;
}
public static String getAlternativeBlock()
{
return "minecraft:orange_wool";
}
}

@ -3,8 +3,11 @@ package systems.brn.televator.blocks;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.AbstractBlock;
import net.minecraft.item.ItemGroups;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.text.Text;
import net.minecraft.world.Heightmap;
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;
@ -23,6 +26,9 @@ import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import xyz.nucleoid.packettweaker.PacketContext;
import static systems.brn.televator.Televator.primed;
public class TelevatorBlock extends Block implements PolymerTexturedBlock {
@ -30,41 +36,41 @@ public class TelevatorBlock extends Block implements PolymerTexturedBlock {
public TelevatorBlock(Settings settings, BlockModelType type, String modelId) {
super(settings);
this.polymerBlockState = PolymerBlockResourceUtils.requestBlock(type, PolymerBlockModel.of(Identifier.of(Televator.MODID, modelId)));
this.polymerBlockState = PolymerBlockResourceUtils.requestBlock(type, PolymerBlockModel.of(Identifier.of(Televator.MODID, "block/" + modelId)));
}
@Override
public BlockState getPolymerBlockState(BlockState state) {
public BlockState getPolymerBlockState(BlockState state, PacketContext packetContext) {
return this.polymerBlockState;
}
public static void register() {
var modId = Identifier.of(Televator.MODID, Televator.MODELID);
var block = Registry.register(Registries.BLOCK, modId,
new TelevatorBlock(AbstractBlock.Settings.copy(Blocks.WHITE_WOOL), BlockModelType.FULL_BLOCK, Televator.MODELID));
new TelevatorBlock(AbstractBlock.Settings.copy(Blocks.WHITE_WOOL).registryKey(RegistryKey.of(RegistryKeys.BLOCK, modId)), BlockModelType.FULL_BLOCK, Televator.MODELID));
Item item = Registry.register(Registries.ITEM, modId, new TelevatorBlockItem(new Item.Settings(), block, Televator.MODELID));
Item item = Registry.register(Registries.ITEM, modId, new TelevatorBlockItem(new Item.Settings().registryKey(RegistryKey.of(RegistryKeys.ITEM, modId)), block, Televator.MODELID));
ItemGroupEvents.modifyEntriesEvent(ItemGroups.FUNCTIONAL).register(content -> content.add(item));
}
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()) {
int maxY = world.getDimension().height() + world.getDimension().minY();
int minY = world.getDimension().minY();
while (pos.getY() <= maxY && pos.getY() >= minY) {
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)) {
if (tpPos.getY() + 1 > maxY || (world.getBlockState(tpPos).getBlock().equals(Blocks.AIR) && world.getBlockState(tpPos.up()).getBlock().equals(Blocks.AIR))) {
teleportWithEffect(player, world, tpPos);
primed.put(player.getUuid(), false);
break;
}
}
pos = isJumping ? pos.up() : pos.down();
count++;
}
}

@ -2,32 +2,31 @@ 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;
import xyz.nucleoid.packettweaker.PacketContext;
public class TelevatorBlockItem extends BlockItem implements PolymerItem {
private final PolymerModelData polymerModel;
private final Identifier polymerModel;
public TelevatorBlockItem(Settings settings, Block block, String modelId) {
super(block, settings);
this.polymerModel = PolymerResourcePackUtils.requestModel(Items.BARRIER, Identifier.of(Televator.MODID, modelId));
this.polymerModel = PolymerResourcePackUtils.getBridgedModelId(Identifier.of(Televator.MODID, "item/" + modelId));
}
@Override
public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
return this.polymerModel.item();
public Item getPolymerItem(ItemStack itemStack, PacketContext packetContext) {
return Items.BARRIER;
}
@Override
public int getPolymerCustomModelData(ItemStack itemStack, @Nullable ServerPlayerEntity player) {
return this.polymerModel.value();
public Identifier getPolymerItemModel(ItemStack stack, PacketContext context) {
return polymerModel;
}
}

@ -1,3 +1,4 @@
{
"block.televator.televator": "Televator"
"block.televator.televator": "Televator",
"item.televator.televator": "Televator"
}

@ -7,15 +7,9 @@
"#A#"
],
"key": {
"#": {
"item": "minecraft:glass"
},
"A": {
"item": "minecraft:amethyst_shard"
},
"E": {
"item": "minecraft:ender_pearl"
}
"#": "minecraft:glass",
"A": "minecraft:amethyst_shard",
"E": "minecraft:ender_pearl"
},
"result": {
"id": "televator:televator",