Skip to content

Commit

Permalink
1.7.0 for 1.18 snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
Draylar committed Nov 15, 2021
1 parent e65011b commit 34201ed
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 65 deletions.
13 changes: 6 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -10,11 +10,12 @@ archivesBaseName = project.archives_base_name
version = project.mod_version + "-" + project.minecraft_version
group = project.maven_group

minecraft {
accessWidener("src/main/resources/magna.accessWidener")
loom {
accessWidenerPath = file("src/main/resources/magna.accessWidener")
}

repositories {
maven { url 'https://jitpack.io' }
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.jamieswhiteshirt.com/libs-release/" }
maven { url "https://maven.terraformersmc.com/releases/" }
Expand All @@ -27,10 +28,8 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// config
include("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}")
modImplementation("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
modImplementation 'com.github.Draylar.omega-config:omega-config-base:1.0.8-1.17'
include 'com.github.Draylar.omega-config:omega-config-base:1.0.8-1.17'

// dev modmenu
modImplementation "com.terraformersmc:modmenu:${project.mod_menu_version}"
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.37
loader_version=0.11.6
minecraft_version=1.18-pre1
yarn_mappings=1.18-pre1+build.8
loader_version=0.12.5

# Mod Properties
mod_version=1.6.2
mod_version=1.7.0
maven_group=draylar
archives_base_name=magna

# 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.37.2+1.17
fabric_version=0.42.2+1.18
cloth_config_version=5.0.38
mod_menu_version=2.0.4
rea_version=2.1.1
13 changes: 6 additions & 7 deletions src/main/java/draylar/magna/Magna.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package draylar.magna;

import draylar.magna.config.MagnaConfig;
import me.shedaniel.autoconfig.AutoConfig;
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
import draylar.omegaconfig.OmegaConfig;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;

public class Magna implements ModInitializer {

public static MagnaConfig CONFIG = AutoConfig.register(MagnaConfig.class, GsonConfigSerializer::new).getConfig();
public static MagnaConfig CONFIG = OmegaConfig.register(MagnaConfig.class);

@Override
public void onInitialize() {
Expand All @@ -24,8 +23,8 @@ public void onInitialize() {
/**
* Returns an {@link Identifier} under the "magna" namespace.
*
* @param name path of the {@link Identifier} to return
* @return {@link Identifier} with namespace of "magna" and path of the given name
* @param name path of the {@link Identifier} to return
* @return {@link Identifier} with namespace of "magna" and path of the given name
*/
public static Identifier id(String name) {
return new Identifier("magna", name);
Expand All @@ -40,7 +39,7 @@ public static Identifier id(String name) {
* <p>
* For more information on Vanilla Hammers, visit the <a href=https://github.com/Draylar/vanilla-hammers">Vanilla Hammers GitHub repo</a>.
*
* @return whether Vanilla Hammers is installed
* @return whether Vanilla Hammers is installed
*/
public static boolean isVanillaHammersInstalled() {
return FabricLoader.getInstance().isModLoaded("vanilla-hammers");
Expand All @@ -55,7 +54,7 @@ public static boolean isVanillaHammersInstalled() {
* <p>
* For more information on Vanilla Excavators, visit the <a href=https://github.com/Draylar/vanilla-excavators">Vanilla Excavators GitHub repo</a>.
*
* @return whether Vanilla Excavators is installed
* @return whether Vanilla Excavators is installed
*/
public static boolean isVanillaExcavatorsInstalled() {
return FabricLoader.getInstance().isModLoaded("vanillaexcavators");
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/draylar/magna/config/MagnaConfig.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package draylar.magna.config;

import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Comment;
import draylar.omegaconfig.api.Comment;
import draylar.omegaconfig.api.Config;

@Config(name = "magna")
public class MagnaConfig implements ConfigData {
public class MagnaConfig implements Config {
@Comment(value = "Whether an extended hitbox should show air blocks (or other blocks without hitboxes).")
public boolean highlightAirBlocks = false;

Expand All @@ -14,7 +12,7 @@ public class MagnaConfig implements ConfigData {

@Comment(value = "Whether extended hitboxes should be enabled for the appropriate tools.")
public boolean enableExtendedHitbox = true;

@Comment(value = "Whether block breaking should show animation on all blocks.")
public boolean enableAllBlockBreakingAnimation = true;

Expand All @@ -29,4 +27,9 @@ public class MagnaConfig implements ConfigData {

@Comment(value = "If true, dropped items are automatically inserted into the inventory.")
public boolean autoPickup = false;

@Override
public String getName() {
return "magna";
}
}
17 changes: 0 additions & 17 deletions src/main/java/draylar/magna/integration/ModMenuIntegration.java

This file was deleted.

19 changes: 11 additions & 8 deletions src/main/java/draylar/magna/mixin/BlockMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ public abstract class BlockMixin {
at = @At("HEAD"),
cancellable = true
)
private static void smeltItems(BlockState state, World world, BlockPos pos, BlockEntity blockEntity, Entity entity, ItemStack tool, CallbackInfo ci) {
if(!world.isClient && tool.getItem() instanceof MagnaTool && entity instanceof PlayerEntity) {
MagnaTool magnaItem = (MagnaTool) tool.getItem();
private static void processItems(BlockState state, World world, BlockPos pos, BlockEntity blockEntity, Entity entity, ItemStack tool, CallbackInfo ci) {
if(!world.isClient && tool.getItem() instanceof MagnaTool magnaItem && entity instanceof PlayerEntity) {
BlockProcessor processor = magnaItem.getProcessor(world, (PlayerEntity) entity, pos, tool);

// drop each stack, smelted
getDroppedStacks(state, (ServerWorld)world, pos, blockEntity, entity, tool).forEach((drop) -> {
dropStack(world, pos, processor.process(tool, drop));
});
// Process each dropped stack using the given MagnaTool's processor.
// This is usually for implementing a mechanic such as Autosmelt.
List<ItemStack> dropped = getDroppedStacks(state, (ServerWorld) world, pos, blockEntity, entity, tool);
if(dropped != null) {
dropped.forEach((drop) -> {
dropStack(world, pos, processor.process(tool, drop));
});
}

// cancel
// Cancel the original drop.
state.onStacksDropped((ServerWorld) world, pos, tool);
ci.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ClientPlayerInteractionManagerMixin {
cancellable = true)
private void onBreakBlockClient(BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
// If the player is holding a Magna tool, we want to let the server handle breaking mechanics.
// This prevents a small quirk where the middle block in a 3x3 grid would break before the other lbocks.
// This prevents a small quirk where the middle block in a 3x3 grid would break before the other blocks.
if(client.player != null && client.player.getMainHandStack().getItem() instanceof MagnaTool) {
cir.cancel();
World world = this.client.world;
Expand Down
16 changes: 6 additions & 10 deletions src/main/java/draylar/magna/mixin/WorldRendererMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BlockBreakingInfo;
import net.minecraft.client.render.VertexConsumer;
Expand Down Expand Up @@ -43,14 +44,9 @@
public class WorldRendererMixin {

@Shadow @Final private MinecraftClient client;
@Shadow private double lastCameraX;
@Shadow private double lastCameraY;
@Shadow private double lastCameraZ;

@Shadow private ClientWorld world;

@Shadow @Final private Long2ObjectMap<SortedSet<BlockBreakingInfo>> blockBreakingProgressions;

@Inject(at = @At("HEAD"), method = "drawBlockOutline", cancellable = true)
private void drawBlockOutline(MatrixStack stack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos blockPos, BlockState blockState, CallbackInfo ci) {
MagnaConfig config = Magna.CONFIG;
Expand Down Expand Up @@ -122,10 +118,10 @@ private void drawBlockOutline(MatrixStack stack, VertexConsumer vertexConsumer,
WorldRenderer.drawShapeOutline(
stack,
vertexConsumer,
shape,
(double) crosshairPos.getX() - lastCameraX,
(double) crosshairPos.getY() - lastCameraY,
(double) crosshairPos.getZ() - lastCameraZ,
shape, // blockState.getOutlineShape(this.world, blockPos, ShapeContext.of(entity))
(double) crosshairPos.getX() - d,
(double) crosshairPos.getY() - e,
(double) crosshairPos.getZ() - f,
0.0F,
0.0F,
0.0F,
Expand Down
5 changes: 1 addition & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
"homepage": "https://github.com/Draylar/magna",
"issues": "https://github.com/Draylar/magna/issues"
},
"license": "CC0-1.0",
"license": "MIT",
"icon": "assets/magna/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"draylar.magna.Magna"
],
"modmenu": [
"draylar.magna.integration.ModMenuIntegration"
]
},
"custom": {
Expand Down

0 comments on commit 34201ed

Please sign in to comment.