Skip to content

Commit

Permalink
Merge branch '1.17-snap-update' into 1.17.x
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Jun 12, 2021
2 parents 27b1aa3 + 49e2f65 commit 45790f2
Show file tree
Hide file tree
Showing 24 changed files with 1,742 additions and 1,646 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Changelog

## Release [1.17] 0.6.0

### Added

- Blocks now are removed and added to the render system as they are placed / broken.

### Changed

- Updated to 1.17 Minecraft
- Fixed some minor UI issues
49 changes: 37 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
plugins {
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
id "com.matthewprenger.cursegradle" version "1.4.0" apply false
}

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

def ENV = System.getenv();
archivesBaseName = "${project.archives_base_name}-${project.minecraft_version}"
version = project.mod_version
version = "${project.mod_version}-build.${ENV.GITHUB_RUN_NUMBER ?: 9999}"
group = project.maven_group

if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand All @@ -27,6 +25,9 @@ dependencies {
// You may need to force-disable transitiveness on them.
}

minecraft {
}

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

Expand Down Expand Up @@ -69,9 +70,6 @@ publishing {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}

pom.withXml {
def node = asNode()
Expand All @@ -82,7 +80,34 @@ publishing {
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
url "https://maven.saps.dev/releases"
credentials {
username "mikeymods"
password "${ENV.SAPS_TOKEN}"
}
}
}
}

if (ENV.CURSE_DEPLOY_TOKEN) {
curseforge {
apiKey = ENV.CURSE_DEPLOY_TOKEN
project {
id = 444663
releaseType = "Release"
addGameVersion "Fabric"
addGameVersion "1.17"
mainArtifact(remapJar.archivePath)
relations {
requiredDependency 'architectury-fabric'
requiredDependency 'fabric-api'
requiredDependency 'ftb-teams-fabric'
requiredDependency 'ftb-library-fabric'
requiredDependency 'item-filters-fabric'
optionalDependency 'kubejs-fabric'
}
changelog = file(project.rootDir + "/CHANGELOG.md").text
changelogType = 'markdown'
}
}
}
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx4G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=21w06a
yarn_mappings=21w06a+build.20
loader_version=0.11.1
minecraft_version=1.17
yarn_mappings=1.17+build.10
loader_version=0.11.3
# Mod Properties
mod_version=0.5.0s
maven_group=pro.mikey.fabric.xray
mod_version=0.6.0
maven_group=pro.mikey.fabric
archives_base_name=advanced-xray-fabric
# 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.30.2+1.17
fabric_version=0.35.0+1.17
4 changes: 2 additions & 2 deletions 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/gradle-6.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
82 changes: 54 additions & 28 deletions src/main/java/pro/mikey/fabric/xray/ScanController.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package pro.mikey.fabric.xray;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import pro.mikey.fabric.xray.records.BlockPosWithColor;
import pro.mikey.fabric.xray.storage.Stores;

Expand All @@ -12,38 +19,57 @@
import java.util.Set;

public class ScanController {
public static Set<BlockPosWithColor> renderQueue = Collections.synchronizedSet(new HashSet<>());
private static ChunkPos playerLastChunk;

/** No point even running if the player is still in the same chunk. */
private static boolean playerLocationChanged() {
ClientPlayerEntity player = MinecraftClient.getInstance().player;
if (player == null) {
return false;
public static Set<BlockPosWithColor> renderQueue = Collections.synchronizedSet(new HashSet<>());
private static ChunkPos playerLastChunk;

/**
* No point even running if the player is still in the same chunk.
*/
private static boolean playerLocationChanged() {
ClientPlayerEntity player = MinecraftClient.getInstance().player;
if (player == null) {
return false;
}

return playerLastChunk == null || !playerLastChunk.equals(player.getChunkPos());
}

return playerLastChunk == null || !playerLastChunk.equals(player.getChunkPos());
}

/**
* Runs the scan task by checking if the thread is ready but first attempting to provide the cache
* if the cache is still valid.
*
* @param forceRerun if the task is required to re-run for instance, a block is broken in the
* world.
*/
public static synchronized void runTask(boolean forceRerun) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null && client.world == null) {
return;
/**
* Runs the scan task by checking if the thread is ready but first attempting to provide the cache
* if the cache is still valid.
*
* @param forceRerun if the task is required to re-run for instance, a block is broken in the
* world.
*/
public static synchronized void runTask(boolean forceRerun) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null && client.world == null) {
return;
}

if (!Stores.SETTINGS.get().isActive() || (!forceRerun && !playerLocationChanged())) {
return;
}

// Update the players last chunk to eval against above.
playerLastChunk = client.player.getChunkPos();
Util.getMainWorkerExecutor().execute(new ScanTask());
}

if (!Stores.SETTINGS.get().isActive() || (!forceRerun && !playerLocationChanged())) {
return;
public static void blockBroken(World world, PlayerEntity playerEntity, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity) {
if (!Stores.SETTINGS.get().isActive()) return;

if (renderQueue.stream().anyMatch(e -> e.getPos().equals(blockPos))) {
runTask(true);
}
}

// Update the players last chunk to eval against above.
playerLastChunk = client.player.getChunkPos();
Util.getMainWorkerExecutor().execute(new ScanTask());
}
public static void blockPlaced(ItemPlacementContext context) {
if (!Stores.SETTINGS.get().isActive()) return;

BlockState defaultState = Block.getBlockFromItem(context.getStack().getItem()).getDefaultState();
if (Stores.BLOCKS.getCache().get().stream().anyMatch(e -> e.getState() == defaultState)) {
runTask(true);
}
}
}

0 comments on commit 45790f2

Please sign in to comment.