Skip to content

Commit

Permalink
update buildscript, move to 1.15.2
Browse files Browse the repository at this point in the history
  • Loading branch information
LemmaEOF committed Feb 14, 2020
1 parent e46d1a6 commit 2cbbc0e
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 71 deletions.
55 changes: 21 additions & 34 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,60 +1,47 @@
buildscript {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'http://maven.modmuss50.me/'
}
}
dependencies {
classpath "net.fabricmc:fabric-loom:0.2.4-SNAPSHOT"
}
}

plugins {
id 'java'
id 'eclipse'
id 'idea'
id 'maven-publish'
id "java"
id "eclipse"
id "idea"
id "fabric-loom" version "0.2.6-SNAPSHOT"
id "maven-publish"
id "com.jfrog.artifactory" version "4.9.0"
}

apply plugin: net.fabricmc.loom.LoomGradlePlugin

sourceCompatibility = 1.8
targetCompatibility = 1.8

if(rootProject.file('private.gradle').exists()) { //Publishing details
apply from: 'private.gradle'
if(rootProject.file("private.gradle").exists()) { //Publishing details
apply from: "private.gradle"
}

archivesBaseName = "olbm"
group = "io.github.alloffabric"
version = "1.0.0+1.14.4"
archivesBaseName = "${project.archives_base_name}"
group = "${project.maven_group}"
version = "${project.mod_version}+${project.minecraft_version}"

minecraft {
}

repositories {
mavenCentral()
maven { url "http://server.bbkr.space:8081/artifactory/libs-release" }
maven { url "https://minecraft.curseforge.com/api/maven" }
maven { url "https://www.jitpack.io" }
maven { url "https://maven.swordglowsblue.com" }
}

dependencies {
minecraft "com.mojang:minecraft:1.14.4"
mappings "net.fabricmc:yarn:1.14.4+build.14"
modApi "net.fabricmc:fabric-loader:0.6.3+build.167"
modApi "net.fabricmc.fabric-api:fabric-api:0.4.1+build.245-1.14"
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_build}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
compileOnly "com.google.code.findbugs:jsr305:3.0.2"

modApi "io.github.cottonmc:StaticData:1.1.2"
modImplementation "artificemc:artifice:0.3.5"
modImplementation "io.github.cottonmc:Jankson-Fabric:${project.jankson_version}"
modImplementation "io.github.cottonmc:StaticData:${project.static_data_version}"
modImplementation "com.lettuce.fudge:artifice:${project.artifice_version}"

include "io.github.cottonmc:Jankson-Fabric:${project.jankson_version}"
include "io.github.cottonmc:StaticData:${project.static_data_version}"
include "com.lettuce.fudge:artifice:${project.artifice_version}"

include "io.github.cottonmc:StaticData:1.1.2"
include "artificemc:artifice:0.3.5"
}

processResources {
Expand Down
20 changes: 20 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.15.2
yarn_build=3
loader_version=0.7.6+build.179

# Mod Properties
mod_version = 1.0.0
maven_group = io.github.alloffabric
archives_base_name = olbm

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.4.29+build.290-1.15
artifice_version=0.6.0+1.15.2
jankson_version=2.0.1+j1.2.0
static_data_version=1.1.2
10 changes: 10 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}
7 changes: 3 additions & 4 deletions src/main/java/io/github/alloffabric/olbm/OLBClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.render.ColorProviderRegistry;
import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry;
import net.minecraft.client.gui.screen.ingame.ContainerScreen54;
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.item.Items;
import net.minecraft.text.LiteralText;
Expand All @@ -34,7 +34,7 @@ public void onInitializeClient() {
LootBagType type = OLBM.LOOT_BAG_TYPES.get(id);
ColorProviderRegistry.ITEM.register((stack, layer) -> type.getColor(), type.getBag());
}
ScreenProviderRegistry.INSTANCE.registerFactory(new Identifier(OLBM.MODID, "loot_bag"), container -> new ContainerScreen54((LootBagContainer)container, ((LootBagContainer)container).getPlayer().inventory, getName((LootBagContainer)container)));
ScreenProviderRegistry.INSTANCE.registerFactory(new Identifier(OLBM.MODID, "loot_bag"), container -> new GenericContainerScreen((LootBagContainer)container, ((LootBagContainer)container).getPlayer().inventory, getName(((LootBagContainer)container).getId())));
}

public static void createModels() {
Expand All @@ -48,8 +48,7 @@ public static void createModels() {
}
}

private static Text getName(LootBagContainer container) {
Identifier id = container.getId();
public static Text getName(Identifier id) {
String key = "lootbag." + id.getNamespace() + "." + id.getPath();
if (I18n.hasTranslation(key)) return new TranslatableText(key);
else {
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/io/github/alloffabric/olbm/OLBData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import blue.endless.jankson.Jankson;
import blue.endless.jankson.JsonElement;
import blue.endless.jankson.JsonObject;
import blue.endless.jankson.impl.SyntaxError;
import blue.endless.jankson.api.SyntaxError;
import io.github.alloffabric.olbm.api.LootBagType;
import io.github.cottonmc.jankson.JanksonFactory;
import io.github.cottonmc.staticdata.StaticData;
Expand Down Expand Up @@ -74,10 +74,7 @@ static LootBagType getType(String key, JsonObject json) {
Identifier id = new Identifier(key);
Identifier tableId = new Identifier(json.get(String.class, "loot"));
int color = Integer.decode(json.get(String.class, "color").replace("#", "0x"));
boolean makeItem = true;
if (json.containsKey("has_item")) {
makeItem = json.get(Boolean.class, "has_item");
}
boolean makeItem = json.getBoolean("make_item", true);
if (makeItem) {
Rarity rarity = json.containsKey("rarity")? getRarity(json.get(String.class, "rarity")) : Rarity.COMMON;
boolean hasGlint = json.containsKey("glint")? json.get(Boolean.class, "glint") : false;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/io/github/alloffabric/olbm/OLBM.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void onInitialize() {

public static LootBagType registerBag(LootBagType type) {
Identifier id = type.getId();
//TODO: container stuff
return Registry.register(LOOT_BAG_TYPES, id, type);
}
}
42 changes: 15 additions & 27 deletions src/main/java/io/github/alloffabric/olbm/item/LootBagItem.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
package io.github.alloffabric.olbm.item;

import blue.endless.jankson.annotation.Nullable;
import io.github.alloffabric.olbm.OLBClient;
import io.github.alloffabric.olbm.OLBM;
import io.github.alloffabric.olbm.api.LootBagType;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.loot.context.LootContextTypes;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.*;
import net.minecraft.world.World;
import net.minecraft.world.loot.LootSupplier;
import net.minecraft.world.loot.context.LootContext;
import net.minecraft.world.loot.context.LootContextParameters;
import net.minecraft.world.loot.context.LootContextTypes;

import java.util.List;

Expand All @@ -37,7 +35,7 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand h
ServerWorld server = (ServerWorld)world;
Identifier id = type.getTableId();
LootContext ctx = new LootContext.Builder(server).put(LootContextParameters.THIS_ENTITY, player).put(LootContextParameters.POSITION, player.getBlockPos()).build(LootContextTypes.GIFT);
LootSupplier supplier = server.getServer().getLootManager().getSupplier(id);
LootTable supplier = server.getServer().getLootManager().getSupplier(id);
List<ItemStack> stacks = supplier.getDrops(ctx);
ContainerProviderRegistry.INSTANCE.openContainer(new Identifier(OLBM.MODID, "loot_bag"), player, buf -> {
buf.writeIdentifier(type.getId());
Expand All @@ -54,22 +52,7 @@ public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand h

@Override
public Text getName() {
Identifier id = type.getId();
String key = "lootbag." + id.getNamespace() + "." + id.getPath();
if (I18n.hasTranslation(key)) return new TranslatableText(key);
else {
StringBuilder builder = new StringBuilder();
//TODO: do we want the namespace here?
// builder.append(id.getNamespace().substring(0, 1).toUpperCase());
// builder.append(id.getNamespace().substring(1) + " ");
String[] splitPath = id.getPath().split("_");
for (String substr : splitPath) {
builder.append(substr.substring(0, 1).toUpperCase());
builder.append(substr.substring(1));
builder.append(" ");
}
return new LiteralText(builder.toString());
}
return OLBClient.getName(type.getId());
}

@Override
Expand All @@ -81,4 +64,9 @@ public Text getName(ItemStack stack) {
public boolean hasEnchantmentGlint(ItemStack stack) {
return type.hasGlint();
}

@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
if (context.isAdvanced()) tooltip.add(new TranslatableText("tooltip.olbm.source").formatted(Formatting.BLUE, Formatting.ITALIC));
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/olbm/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tooltip.olbm.source": "Powered by OLBM"
}

0 comments on commit 2cbbc0e

Please sign in to comment.