Skip to content

Commit

Permalink
Caves and cliffs update
Browse files Browse the repository at this point in the history
  • Loading branch information
ustc-zzzz committed Jan 3, 2022
1 parent ea54b3e commit 860500e
Show file tree
Hide file tree
Showing 21 changed files with 345 additions and 283 deletions.
27 changes: 15 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,30 @@ import java.time.temporal.ChronoUnit
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
maven { url = 'https://maven.parchmentmc.org' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
classpath group: 'org.parchmentmc', name: 'librarian', version: '1.+'
}
}

apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'

apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '0.3.0'
version = '0.4.0'
group = 'org.teacon'
archivesBaseName = 'ChromeBall-Forge-1.17'
archivesBaseName = 'ChromeBall-Forge-1.18'

java.toolchain.languageVersion = JavaLanguageVersion.of(16)
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
minecraft {
mappings channel: 'official', version: '1.17.1'
// mappings channel: 'official', version: '1.18.1'
mappings channel: 'parchment', version: '2021.12.19-1.18.1'

runs {
client {
Expand All @@ -42,7 +46,7 @@ minecraft {
}

server {
workingDirectory project.file('run')
workingDirectory project.file('run_server')

property 'forge.logging.markers', 'REGISTRIES'

Expand All @@ -56,7 +60,7 @@ minecraft {
}

data {
workingDirectory project.file('run_server')
workingDirectory project.file('run')

property 'forge.logging.markers', 'REGISTRIES'

Expand All @@ -80,7 +84,7 @@ repositories {
}

dependencies {
minecraft 'net.minecraftforge:forge:1.17.1-37.0.7'
minecraft 'net.minecraftforge:forge:1.18.1-39.0.9'
}

jar {
Expand All @@ -97,22 +101,21 @@ jar {
}
}


// Maven publish
def reobfFile = file("$buildDir/reobfJar/output.jar")
def reobfArtifact = artifacts.add('default', reobfFile) {
type 'jar'
builtBy 'reobfJar'
}

publishing {
publications {
release(MavenPublication) {
groupId = "org.teacon"
artifactId = "ChromeBall-Forge-1.17"
artifactId = "ChromeBall-Forge-1.18"

artifact reobfArtifact
pom {
name = 'ChromeBall for Minecraft 1.17'
name = 'ChromeBall for Minecraft 1.18'
description = 'ChromeBall! Just a Chrome Ball.'
licenses {
license {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-7.2-20210702220150+0000-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
52 changes: 34 additions & 18 deletions src/main/java/org/teacon/chromeball/ChromeBall.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,53 @@
package org.teacon.chromeball;

import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.scores.Objective;
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fmlserverevents.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.teacon.chromeball.common.CBRegistry;

import javax.annotation.ParametersAreNonnullByDefault;

@Mod(ChromeBall.MOD_ID)
@Mod.EventBusSubscriber
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class ChromeBall {
public static final String MOD_ID = "chromeball";
public static ObjectiveCriteria O;

public static Config config;
private static Config modConfig;

public ChromeBall() {
ForgeConfigSpec.Builder configBuilder = new ForgeConfigSpec.Builder();
config = new Config(configBuilder);
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, configBuilder.build(), MOD_ID + ".toml");
var builder = new ForgeConfigSpec.Builder();
modConfig = new Config(builder);
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, builder.build(), MOD_ID + ".toml");

var eventBus = FMLJavaModLoadingContext.get().getModEventBus();
CBRegistry.ITEMS.register(eventBus);
CBRegistry.ENTITIES.register(eventBus);
}

@SubscribeEvent
public static void onFMLServerStartingEvent(FMLServerStartingEvent event) {
// O = event.getServer().getScoreboard().getObjective("chrome");
// if (O == null)
// O = event.getServer().getScoreboard().addObjective("chrome", CHROME, new TranslatableComponent("chromeball.tab.1"), ObjectiveCriteria.RenderType.INTEGER);
//
// event.getServer().getScoreboard().setObjectiveInDisplaySlot(0, O);
public static Config getConfig() {
return modConfig;
}

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public static class Config {
public final ForgeConfigSpec.DoubleValue rate;

private double rateValue = -1;

public Config(ForgeConfigSpec.Builder builder) {
this.rate = builder.defineInRange("recovery_rate", 0.3D, 0D, 1D);
}

public double getRateValue() {
if (this.rateValue < 0) {
this.rateValue = rate.get();
}
return this.rateValue;
}
}
}
59 changes: 0 additions & 59 deletions src/main/java/org/teacon/chromeball/ChromeBallEntity.java

This file was deleted.

36 changes: 0 additions & 36 deletions src/main/java/org/teacon/chromeball/ChromeBallItem.java

This file was deleted.

19 changes: 0 additions & 19 deletions src/main/java/org/teacon/chromeball/ClientHandler.java

This file was deleted.

19 changes: 0 additions & 19 deletions src/main/java/org/teacon/chromeball/Config.java

This file was deleted.

39 changes: 0 additions & 39 deletions src/main/java/org/teacon/chromeball/Register.java

This file was deleted.

34 changes: 34 additions & 0 deletions src/main/java/org/teacon/chromeball/client/ClientRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.teacon.chromeball.client;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.client.renderer.entity.ThrownItemRenderer;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.registries.ForgeRegistries;
import org.teacon.chromeball.common.CBRegistry;

import javax.annotation.ParametersAreNonnullByDefault;

@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientRenderer {
@SubscribeEvent
public static void registerRenderer(FMLClientSetupEvent event) {
EntityRenderers.register(CBRegistry.ENTITY_TYPE.get(), ThrownItemRenderer::new);
}

public static void ding() {
var registry = ForgeRegistries.SOUND_EVENTS;
var sound = registry.getValue(new ResourceLocation("entity.experience_orb.pickup"));
if (sound != null) {
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(sound, 1.0f));
}
}
}
Loading

0 comments on commit 860500e

Please sign in to comment.