Skip to content

Commit

Permalink
1.17 update + blast compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Draylar committed Jun 18, 2021
1 parent 5d244cc commit 8b771aa
Show file tree
Hide file tree
Showing 21 changed files with 295 additions and 323 deletions.
55 changes: 32 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
plugins {
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name + "-" + project.minecraft_version
version = project.mod_version
group = project.maven_group

minecraft {
accessWidener "src/main/resources/goml.accesswidener"
}

repositories {
maven { url "https://maven.jamieswhiteshirt.com/libs-release/" }
maven { url = "https://maven.fabricmc.net/" }
maven { url = 'https://jitpack.io' }

maven {
url = "https://maven.jamieswhiteshirt.com/libs-release/"
content {
includeGroup 'com.jamieswhiteshirt'
}
}

maven {
name = "Ladysnake Libs"
url = "https://dl.bintray.com/ladysnake/libs"
name = 'Ladysnake Mods'
url = 'https://ladysnake.jfrog.io/artifactory/mods'
}

maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
jcenter()
}

dependencies {
Expand All @@ -29,41 +46,33 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

include "com.jamieswhiteshirt:rtree-3i-lite-fabric:${project.rtree_version}"
modCompile "com.jamieswhiteshirt:rtree-3i-lite-fabric:${project.rtree_version}"

modCompile ("io.github.prospector:modmenu:${project.mod_menu_version}") {
exclude group: "net.fabricmc.fabric-api"
}
modImplementation "com.jamieswhiteshirt:rtree-3i-lite-fabric:${project.rtree_version}"

// Config
modImplementation 'com.github.Draylar.omega-config:omega-config-base:1.0.4-beta'
include 'com.github.Draylar.omega-config:omega-config-base:1.0.4-beta:min'

// CCA for data
modImplementation "io.github.OnyxStudios.Cardinal-Components-API:cardinal-components-base:${project.cca_version}"
include "io.github.OnyxStudios.Cardinal-Components-API:cardinal-components-base:${project.cca_version}"
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:${project.cca_version}"
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:${project.cca_version}"

modImplementation "io.github.OnyxStudios.Cardinal-Components-API:cardinal-components-world:${project.cca_version}"
include "io.github.OnyxStudios.Cardinal-Components-API:cardinal-components-world:${project.cca_version}"
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-world:${project.cca_version}"
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-world:${project.cca_version}"

// Flight
modImplementation "io.github.ladysnake:PlayerAbilityLib:${pal_version}"
include "io.github.ladysnake:PlayerAbilityLib:${pal_version}"

modImplementation 'com.github.TheRandomLabs:VanillaDeathChest:1.16-fabric-SNAPSHOT'
// Dev testing
modCompileOnly modRuntime ('curse.maven:BLAST-349938:3350311')
}

processResources {
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
filesMatching('fabric.mod.json') {
expand "version": project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.6
loader_version=0.11.3
minecraft_version=1.17
yarn_mappings=1.17+build.12
loader_version=0.11.6
fabric_version=0.35.2+1.17

# Mod Properties
mod_version = 1.3.4-beta
mod_version = 1.4.0-beta
maven_group = com.github.draylar
archives_base_name = get-off-my-lawn

# 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.32.5+1.16
rtree_version=0.3.0
mod_menu_version=1.14+
cca_version=2.5.0
cca_version=3.0.0
autoconfig_version=3.2.2
pal_version=1.2.1
pal_version=1.3.0-nightly.1.17-rc1
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Sat Feb 29 21:28:08 CST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 11 additions & 18 deletions src/main/java/draylar/goml/GetOffMyLawn.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package draylar.goml;

import draylar.goml.api.compat.DeathChestsCompat;
import dev.onyxstudios.cca.api.v3.component.ComponentKey;
import dev.onyxstudios.cca.api.v3.component.ComponentRegistryV3;
import dev.onyxstudios.cca.api.v3.world.WorldComponentFactoryRegistry;
import dev.onyxstudios.cca.api.v3.world.WorldComponentInitializer;
import draylar.goml.cca.ClaimComponent;
import draylar.goml.cca.WorldClaimComponent;
import draylar.goml.command.ClaimCommand;
Expand All @@ -9,27 +12,17 @@
import draylar.goml.registry.GOMLEntities;
import draylar.goml.registry.GOMLItems;
import draylar.omegaconfig.OmegaConfig;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer;
import nerdhub.cardinal.components.api.ComponentRegistry;
import nerdhub.cardinal.components.api.ComponentType;
import nerdhub.cardinal.components.api.event.WorldComponentCallback;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class GetOffMyLawn implements ModInitializer {

public static final ComponentType<ClaimComponent> CLAIM = ComponentRegistry.INSTANCE.registerIfAbsent(
id("claims"),
ClaimComponent.class
).attach(WorldComponentCallback.EVENT, WorldClaimComponent::new);
public class GetOffMyLawn implements ModInitializer, WorldComponentInitializer {

public static final ComponentKey<ClaimComponent> CLAIM = ComponentRegistryV3.INSTANCE.getOrCreate(id("claims"), ClaimComponent.class);
public static final GOMLConfig CONFIG = OmegaConfig.register(GOMLConfig.class);
public static final ItemGroup GROUP = FabricItemGroupBuilder.build(id("group"), () -> new ItemStack(GOMLItems.GOGGLES));
public static final Logger LOGGER = LogManager.getLogger();
Expand All @@ -41,14 +34,14 @@ public void onInitialize() {
GOMLEntities.init();
EventHandlers.init();
ClaimCommand.init();

// Register compat hooks
if(FabricLoader.getInstance().isModLoaded("vanilladeathchest")) {
DeathChestsCompat.register();
}
}

public static Identifier id(String name) {
return new Identifier("goml", name);
}

@Override
public void registerWorldComponentFactories(WorldComponentFactoryRegistry registry) {
registry.register(CLAIM, WorldClaimComponent::new);
}
}
24 changes: 12 additions & 12 deletions src/main/java/draylar/goml/api/Claim.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import net.fabricmc.fabric.api.util.NbtType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtHelper;
import net.minecraft.nbt.NbtList;
import net.minecraft.util.math.BlockPos;

import java.util.Collections;
Expand Down Expand Up @@ -100,26 +100,26 @@ public BlockPos getOrigin() {
}

/**
* Serializes this {@link Claim} to a {@link CompoundTag} and returns it.
* Serializes this {@link Claim} to a {@link NbtCompound} and returns it.
*
* <p>The following tags are stored at the top level of the tag:
* <ul>
* <li>"Owners" - list of {@link UUID}s of claim owners
* <li>"Pos" - origin {@link BlockPos} of claim
*
* @return this object serialized to a {@link CompoundTag}
* @return this object serialized to a {@link NbtCompound}
*/
public CompoundTag asTag() {
CompoundTag tag = new CompoundTag();
public NbtCompound asTag() {
NbtCompound tag = new NbtCompound();

// collect owner UUIDs into list
ListTag ownersTag = new ListTag();
NbtList ownersTag = new NbtList();
owners.forEach(ownerUUID -> {
ownersTag.add(NbtHelper.fromUuid(ownerUUID));
});

// collect trusted UUIDs into list
ListTag trustedTag = new ListTag();
NbtList trustedTag = new NbtList();
trusted.forEach(trustedUUID -> {
trustedTag.add(NbtHelper.fromUuid(trustedUUID));
});
Expand All @@ -132,7 +132,7 @@ public CompoundTag asTag() {
}

/**
* Uses the top level information in the given {@link CompoundTag} to construct a {@link Claim}.
* Uses the top level information in the given {@link NbtCompound} to construct a {@link Claim}.
*
* <p>This method expects to find the following tags at the top level of the tag:
* <ul>
Expand All @@ -142,20 +142,20 @@ public CompoundTag asTag() {
* @param tag tag to deserialize information from
* @return {@link Claim} instance with information from tag
*/
public static Claim fromTag(CompoundTag tag) {
public static Claim fromTag(NbtCompound tag) {
// Handle legacy data stored in "Owner" key, which is a single UUID
if(tag.containsUuid(OWNER_KEY)) {
return new Claim(Collections.singleton(tag.getUuid(OWNER_KEY)), BlockPos.fromLong(tag.getLong(POSITION_KEY)));
}

// Collect UUID of owners
Set<UUID> ownerUUIDs = new HashSet<>();
ListTag ownersTag = tag.getList(OWNERS_KEY, NbtType.INT_ARRAY);
NbtList ownersTag = tag.getList(OWNERS_KEY, NbtType.INT_ARRAY);
ownersTag.forEach(ownerUUID -> ownerUUIDs.add(NbtHelper.toUuid(ownerUUID)));

// Collect UUID of trusted
Set<UUID> trustedUUIDs = new HashSet<>();
ListTag trustedTag = tag.getList(TRUSTED_KEY, NbtType.INT_ARRAY);
NbtList trustedTag = tag.getList(TRUSTED_KEY, NbtType.INT_ARRAY);
trustedTag.forEach(trustedUUID -> trustedUUIDs.add(NbtHelper.toUuid(trustedUUID)));

return new Claim(ownerUUIDs, trustedUUIDs, BlockPos.fromLong(tag.getLong(POSITION_KEY)));
Expand Down
38 changes: 0 additions & 38 deletions src/main/java/draylar/goml/api/compat/DeathChestsCompat.java

This file was deleted.

7 changes: 4 additions & 3 deletions src/main/java/draylar/goml/block/ClaimAnchorBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;

import java.util.Collections;

Expand All @@ -37,7 +38,6 @@ public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity p
if(!world.isClient()) {
Claim claimInfo = new Claim(Collections.singleton(placer.getUuid()), pos);
GetOffMyLawn.CLAIM.get(world).add(new ClaimBox(pos, radius), claimInfo);
GetOffMyLawn.CLAIM.get(world).sync();

// Assign claim to BE
BlockEntity be = world.getBlockEntity(pos);
Expand Down Expand Up @@ -87,8 +87,9 @@ public int getRadius() {
return radius;
}

@Nullable
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new ClaimAnchorBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new ClaimAnchorBlockEntity(pos, state);
}
}
6 changes: 4 additions & 2 deletions src/main/java/draylar/goml/block/ClaimAugmentBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;

public class ClaimAugmentBlock extends Block implements Augment, BlockEntityProvider {

Expand Down Expand Up @@ -89,8 +90,9 @@ public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity pl
super.onBreak(world, pos, state, player);
}

@Nullable
@Override
public BlockEntity createBlockEntity(BlockView world) {
return new ClaimAugmentBlockEntity();
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new ClaimAugmentBlockEntity(pos, state);
}
}
7 changes: 4 additions & 3 deletions src/main/java/draylar/goml/cca/ClaimComponent.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package draylar.goml.cca;

import com.jamieswhiteshirt.rtree3i.RTreeMap;
import draylar.goml.api.ClaimBox;
import dev.onyxstudios.cca.api.v3.component.ComponentV3;
import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent;
import draylar.goml.api.Claim;
import nerdhub.cardinal.components.api.util.sync.WorldSyncedComponent;
import draylar.goml.api.ClaimBox;

public interface ClaimComponent extends WorldSyncedComponent {
public interface ClaimComponent extends ComponentV3, AutoSyncedComponent {
RTreeMap<ClaimBox, Claim> getClaims();
void add(ClaimBox box, Claim info);
void remove(ClaimBox box);
Expand Down
Loading

0 comments on commit 8b771aa

Please sign in to comment.