Skip to content

Commit

Permalink
uncommitted files
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkGoosik committed Jul 8, 2024
1 parent 98581f4 commit c248414
Show file tree
Hide file tree
Showing 378 changed files with 10,051 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: publish

on:
release:
types:
- published

jobs:
build:
strategy:
matrix:
java: [ 21 ]
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Setup JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'microsoft'
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Build
run: ./gradlew build
- name: Merge Jars
run: ./gradlew mergeJars
- uses: BrycensRanch/read-properties-action@v1
id: props
with:
file: gradle.properties
all: true

- name: Publish
uses: Kir-Antipov/[email protected]
with:
modrinth-id: ${{ steps.props.outputs.modrinth_id }}
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
curseforge-id: ${{ steps.props.outputs.curseforge_id }}
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}

files: |
Merged/${{ steps.props.outputs.mod_id }}-${{ github.event.release.tag_name }}.jar
name: ${{ github.event.release.tag_name }}
version: ${{ github.event.release.tag_name }}

version-type: beta
loaders: |
fabric
neoforge
game-versions: ${{ steps.props.outputs.minecraft_version_range_fabric }}
game-version-filter: releases

dependencies: |
cloth-config
java: |
21
retry-attempts: 0
fail-mode: skip

- name: Upload assets to GitHub
uses: AButler/[email protected]
with:
files: "Merged/${{ steps.props.outputs.mod_id }}-${{ github.event.release.tag_name }}.jar;${{ steps.props.outputs.mod_id }}-fabric/build/libs/${{ steps.props.outputs.mod_id }}-fabric-${{ github.event.release.tag_name }}.jar;${{ steps.props.outputs.mod_id }}-fabric/build/libs/${{ steps.props.outputs.mod_id }}-fabric-${{ github.event.release.tag_name }}-sources.jar;${{ steps.props.outputs.mod_id }}-neoforge/build/libs/${{ steps.props.outputs.mod_id }}-neoforge-${{ github.event.release.tag_name }}.jar;${{ steps.props.outputs.mod_id }}-neoforge/build/libs/${{ steps.props.outputs.mod_id }}-neoforge-${{ github.event.release.tag_name }}-sources.jar"
repo-token: ${{ secrets.GH_TOKEN }}
100 changes: 100 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import net.fabricmc.loom.api.LoomGradleExtensionAPI

plugins {
java
id("architectury-plugin") version "3.4-SNAPSHOT"
id("dev.architectury.loom") version "1.7-SNAPSHOT" apply false
id("io.github.pacifistmc.forgix") version "1.2.9"
}

architectury {
minecraft = rootProject.property("minecraft_version").toString()
}

forgix {
group = "ru.pinkgoosik.winterly"
mergedJarName = "winterly-${rootProject.property("mod_version").toString()}.jar"
}

subprojects {
apply(plugin = "dev.architectury.loom")
apply(plugin = "architectury-plugin")

val loom = project.extensions.getByName<LoomGradleExtensionAPI>("loom")
loom.silentMojangMappingsLicense()

dependencies {
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft_version")}")

// The template comes with Mojang mappings, but you may use other mappings such as Yarn and Quilt if you want.
@Suppress("UnstableApiUsage")
"mappings"(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${rootProject.property("minecraft_version")}:${rootProject.property("parchment_version")}@zip")
})
}

tasks.processResources {
val expandProps = mapOf(
"name" to rootProject.property("mod_name"),
"version" to rootProject.property("mod_version"),
"description" to rootProject.property("mod_description"),
"mod_id" to rootProject.property("mod_id"),
"homepage_url" to rootProject.property("homepage_url"),
"sources_url" to rootProject.property("sources_url"),
"issue_tracker_url" to rootProject.property("issue_tracker_url"),
"license" to rootProject.property("license"),
"minecraft_version" to rootProject.property("minecraft_version"),
"minecraft_version_range" to rootProject.property("minecraft_version_range"),
"minecraft_version_range_fabric" to rootProject.property("minecraft_version_range_fabric"),
"fabric_loader_version" to rootProject.property("fabric_loader_version"),
"fabric_version" to rootProject.property("fabric_api_version"),
"neoforge_version" to rootProject.property("neoforge_version"),
"neoforge_version_range" to rootProject.property("neoforge_version_range")
)

inputs.properties(expandProps)

filesMatching(listOf("pack.mcmeta", "fabric.mod.json", "META-INF/neoforge.mods.toml", "*.mixins.json")) {
expand(expandProps)
}
}
}

allprojects {
apply(plugin = "java")
apply(plugin = "architectury-plugin")
apply(plugin = "maven-publish")

base.archivesName.set(rootProject.property("archives_base_name").toString())
version = rootProject.property("mod_version").toString()
group = rootProject.property("maven_group").toString()

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// 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.

maven("https://maven.neoforged.net/releases/") {
name = "NeoForged"
}

maven("https://maven.parchmentmc.org") {
name = "ParchmentMC"
}
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.release = 21
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}
18 changes: 18 additions & 0 deletions winterly-common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
architectury {
val enabled_platforms: String by rootProject
common(enabled_platforms.split(","))
}

loom {
accessWidenerPath.set(file("src/main/resources/${project(":winterly-common").property("mod_id")}.accesswidener"))
}

dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}")
modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:${rootProject.property("cloth_config")}") { exclude("net.fabricmc.fabric-api") }

// Remove the next line if you don't want to depend on the API
//modApi("dev.architectury:architectury:${rootProject.property("architectury_version")}")
}
18 changes: 18 additions & 0 deletions winterly-common/src/main/java/ru/pinkgoosik/winterly/Winterly.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ru.pinkgoosik.winterly;

import net.minecraft.resources.ResourceLocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.pinkgoosik.winterly.config.WinterlyClothConfig;
import ru.pinkgoosik.winterly.config.WinterlyConfig;

public class Winterly {
public static final String MOD_ID = "winterly";
public static final Logger LOGGER = LoggerFactory.getLogger("Winterly");
public static WinterlyConfig config = WinterlyClothConfig.init();

public static ResourceLocation id(String path) {
return ResourceLocation.fromNamespaceAndPath(MOD_ID, path);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
package ru.pinkgoosik.winterly.block;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
import ru.pinkgoosik.winterly.data.CachedFlowers;
import ru.pinkgoosik.winterly.registry.CommonWinterlyBlocks;

import java.util.Objects;

@SuppressWarnings("NullableProblems")
public class CommonFrozenFlowerBlock extends Block {
public static final IntegerProperty LAYERS = IntegerProperty.create("layers", 0, 8);
public static final BooleanProperty PERSISTENT = BlockStateProperties.PERSISTENT;

protected static final VoxelShape[] LAYERS_TO_SHAPE = new VoxelShape[] {
Block.box(5.0, 0.0, 5.0, 11.0, 10.0, 11.0),
Block.box(0.0, 0.0, 0.0, 16.0, 2.0, 16.0),
Block.box(0.0, 0.0, 0.0, 16.0, 4.0, 16.0),
Block.box(0.0, 0.0, 0.0, 16.0, 6.0, 16.0),
Block.box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0),
Block.box(0.0, 0.0, 0.0, 16.0, 10.0, 16.0),
Block.box(0.0, 0.0, 0.0, 16.0, 12.0, 16.0),
Block.box(0.0, 0.0, 0.0, 16.0, 14.0, 16.0),
Block.box(0.0, 0.0, 0.0, 16.0, 16.0, 16.0)
};

public CommonFrozenFlowerBlock(Properties settings) {
super(settings);
this.registerDefaultState(this.stateDefinition.any().setValue(LAYERS, 0).setValue(PERSISTENT, false));
}

@Override
public SoundType getSoundType(BlockState state) {
if(state.getValue(LAYERS) == 0) {
return SoundType.GRASS;
}
else {
return SoundType.SNOW;
}
}

@Override
protected boolean isPathfindable(BlockState state, PathComputationType type) {
if(type.equals(PathComputationType.LAND)) {
return state.getValue(LAYERS) < 5;
}
else return false;
}

@Override
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
return LAYERS_TO_SHAPE[state.getValue(LAYERS)];
}

@Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
if(state.getValue(LAYERS).equals(0) || state.getValue(LAYERS).equals(1)) {
return Shapes.empty();
}
else {
return LAYERS_TO_SHAPE[state.getValue(LAYERS) - 1];
}
}

@Override
public VoxelShape getBlockSupportShape(BlockState state, BlockGetter world, BlockPos pos) {
return LAYERS_TO_SHAPE[state.getValue(LAYERS)];
}

@Override
public VoxelShape getVisualShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
return LAYERS_TO_SHAPE[state.getValue(LAYERS)];
}

@Override
public boolean useShapeForLightOcclusion(BlockState state) {
return true;
}

@Override
public float getShadeBrightness(BlockState state, BlockGetter world, BlockPos pos) {
return state.getValue(LAYERS) == 8 ? 0.2F : 1.0F;
}

@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockPos down = pos.below();
return this.canPlantOnTop(world.getBlockState(down));
}

protected boolean canPlantOnTop(BlockState floor) {
return floor.is(BlockTags.DIRT) || floor.is(Blocks.FARMLAND);
}

@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
return !state.canSurvive(world, pos) ? Blocks.AIR.defaultBlockState() : super.updateShape(state, direction, neighborState, world, pos, neighborPos);
}

@Override
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (world.getBrightness(LightLayer.BLOCK, pos) > 11) {
dropResources(state, world, pos);
if(state.getValue(LAYERS) != 0) {
var cachedFlower = CachedFlowers.getFlower(world, pos);
world.setBlockAndUpdate(pos, Objects.requireNonNullElse(cachedFlower, this).defaultBlockState());
}
}
}

@Override
public void destroy(LevelAccessor world, BlockPos pos, BlockState state) {
super.destroy(world, pos, state);

if(state.getValue(LAYERS) != 0 && world instanceof ServerLevel server) {
var cachedFlower = CachedFlowers.getFlower(server, pos);
world.setBlock(pos, Objects.requireNonNullElse(cachedFlower, this).defaultBlockState(), Block.UPDATE_ALL);
}
}

@Override
public boolean canBeReplaced(BlockState state, BlockPlaceContext context) {
int layers = state.getValue(LAYERS);

if(layers == 8) {
return false;
}
if(context.getItemInHand().is(Blocks.SNOW.asItem())) {
if(layers == 0) {
return true;
}
else {
return context.getClickedFace() == Direction.UP;
}
}
return false;
}

@Nullable
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
BlockState state = ctx.getLevel().getBlockState(ctx.getClickedPos());
if(state.is(Blocks.SNOW) || state.is(CommonWinterlyBlocks.FROZEN_GRASS)) {
return defaultBlockState().setValue(LAYERS, 1).setValue(PERSISTENT, true);
}
else {
return super.getStateForPlacement(ctx);
}
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(LAYERS);
builder.add(PERSISTENT);
}
}
Loading

0 comments on commit c248414

Please sign in to comment.