Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ dependencies {

// Maps
modCompileOnly(forge.ftbchunks)
modCompileOnly(forge.xaeroslib)
modCompileOnly(forge.xaerosminimap)
modCompileOnly(forge.xaerosworldmap)
modCompileOnly(forge.journeymap.api)
Expand Down
3 changes: 2 additions & 1 deletion docs/content/Modpacks/Changes/v8.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ A large number of machine feature interfaces have been removed, and have had the
- `BlastingRecipeBuilder`, `CampfireRecipeBuilder`, `SmeltingRecipeBuilder` and `SmokingRecipeBuilder` have been merged into `SimpleCookingRecipeBuilder`
- Example usage: `SimpleCookingRecipeBuilder.campfireCooking("cooking_chicken").input(new ItemStack(Items.CHICKEN)).output(new ItemStacks(Items.COOKED_CHICKEN)).cookingTime(100).experience(100).save(provider);`
- `GTFluidImpl` has been merged into `GTFluid`, use `GTFluid.Flowing` and `GTFluid.Source` instead of `GTFluidImpl.Flowing` and `GTFluidImpl.Source`.
- Item behaviors have been moved to `common/item/behavior`, and some items have been moved from `api/item` to `common/item`
- Item behaviors have been moved to `common/item/behavior`, and some items have been moved from `api/item` to `common/item`.
- Methods for processing machine interactions have changed, and all now take a single `ExtendedUseOnContext` argument.
10 changes: 6 additions & 4 deletions gradle/forge.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ ccTweaked = "1.114.3"
create = "6.0.6-150"
ponder = "1.0.80"
flywheel = "1.0.4"
xaerosLib = "1.1.0"
xaerosWorldMap = "1.40.11"
xaerosMinimap = "25.3.10"

## modrinth maven ##
jade = "11.6.3"
Expand All @@ -36,8 +39,6 @@ modernfix = "DdUByV9S" # 5.24.1+mc1.20.1
worldStripper = "4578579"
javd = "4803995"
trenzalore = "4848244"
xaerosWorldMap = "5658224"
xaerosMinimap = "5773012"
journeyMap = "5789363"
resourcefullib = "5659871"
argonauts = "5263580"
Expand Down Expand Up @@ -90,6 +91,9 @@ jade = { module = "maven.modrinth:jade", version.ref = "jade" }
embeddium = { module = "maven.modrinth:embeddium", version.ref = "embeddium" }
oculus = { module = "maven.modrinth:oculus", version.ref = "oculus" }
modernfix = { module = "maven.modrinth:modernfix", version.ref = "modernfix" }
xaeroslib = { module = "xaero.lib:xaerolib-forge-1.20.1", version.ref = "xaerosLib" }
xaerosworldmap = { module = "xaero.map:xaeroworldmap-forge-1.20.1", version.ref = "xaerosWorldMap" }
xaerosminimap = { module = "xaero.minimap:xaerominimap-forge-1.20.1", version.ref = "xaerosMinimap" }


cc-tweaked-core-api = { module = "cc.tweaked:cc-tweaked-1.20.1-core-api", version.ref = "ccTweaked" }
Expand All @@ -99,8 +103,6 @@ cc-tweaked-forge-impl = { module = "cc.tweaked:cc-tweaked-1.20.1-forge", version
worldstripper = { module = "curse.maven:worldStripper-250603", version.ref = "worldStripper" }
javd = { module = "curse.maven:javd-370890", version.ref = "javd" }
trenzalore = { module = "curse.maven:trenzalore-870210", version.ref = "trenzalore" }
xaerosworldmap = { module = "curse.maven:xaeros-world-map-317780", version.ref = "xaerosWorldMap" }
xaerosminimap = { module = "curse.maven:xaeros-minimap-263420", version.ref = "xaerosMinimap" }
journeymap-forge = { module = "curse.maven:journeymap-32274", version.ref = "journeyMap" }
resourcefullib = { module = "curse.maven:resourceful-lib-570073", version.ref = "resourcefullib" }
argonauts = { module = "curse.maven:argonauts-845833", version.ref = "argonauts" }
Expand Down
4 changes: 4 additions & 0 deletions gradle/scripts/repositories.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,8 @@ repositories {
forRepository { maven { url = "https://maven.squiddev.cc" } }
filter { includeGroup("cc.tweaked") }
}
exclusiveContent { // Xaero's
forRepository { maven { url = "https://chocolateminecraft.com/maven/" } }
filter { includeGroupAndSubgroups("xaero") }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.gregtechceu.gtceu.api.sync_system.ManagedSyncBlockEntity;
import com.gregtechceu.gtceu.common.data.GTItems;
import com.gregtechceu.gtceu.common.machine.owner.MachineOwner;
import com.gregtechceu.gtceu.utils.ExtendedUseOnContext;
import com.gregtechceu.gtceu.utils.GTUtil;

import net.minecraft.MethodsReturnNonnullByDefault;
Expand Down Expand Up @@ -273,7 +274,13 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player
machine.setOwnerUUID(sPlayer.getUUID());
}

InteractionResult machineInteractResult = machine.onUse(state, world, pos, player, hand, hit);
InteractionResult machineInteractResult;
if (itemStack.isEmpty()) {
machineInteractResult = machine.onUse(new ExtendedUseOnContext(player, hand, hit));
} else {
machineInteractResult = machine.onUseWithItem(new ExtendedUseOnContext(player, hand, hit));
}

if (machineInteractResult != InteractionResult.PASS) return machineInteractResult;

if (itemStack.is(GTItems.PORTABLE_SCANNER.get())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.gregtechceu.gtceu.common.item.behavior.CoverPlaceBehavior;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper;
import com.gregtechceu.gtceu.utils.ExtendedUseOnContext;
import com.gregtechceu.gtceu.utils.GTMath;
import com.gregtechceu.gtceu.utils.GTUtil;

Expand Down Expand Up @@ -352,8 +353,8 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
}

Set<GTToolType> types = ToolHelper.getToolTypes(itemStack);
if ((!types.isEmpty() && ToolHelper.canUse(itemStack)) || (types.isEmpty() && player.isShiftKeyDown())) {
var result = pipeBlockEntity.onToolClick(types, itemStack, new UseOnContext(player, hand, hit));
if ((!types.isEmpty() && ToolHelper.canUse(itemStack))) {
var result = pipeBlockEntity.onToolClick(new ExtendedUseOnContext(player, hand, hit));
if (result.getSecond() == InteractionResult.CONSUME && player instanceof ServerPlayer serverPlayer) {
ToolHelper.playToolSound(result.getFirst(), serverPlayer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.gregtechceu.gtceu.api.GTValues;
import com.gregtechceu.gtceu.api.block.MaterialPipeBlock;
import com.gregtechceu.gtceu.api.capability.ICoverable;
import com.gregtechceu.gtceu.api.capability.IToolable;
import com.gregtechceu.gtceu.api.cover.CoverBehavior;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.data.tag.TagPrefix;
Expand All @@ -18,6 +16,7 @@
import com.gregtechceu.gtceu.api.sync_system.annotations.SyncToClient;
import com.gregtechceu.gtceu.common.data.GTMaterialBlocks;
import com.gregtechceu.gtceu.common.data.GTMaterials;
import com.gregtechceu.gtceu.utils.ExtendedUseOnContext;
import com.gregtechceu.gtceu.utils.GTUtil;

import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture;
Expand All @@ -32,13 +31,11 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;

import com.mojang.datafixers.util.Pair;
import lombok.Getter;
Expand All @@ -55,7 +52,7 @@
@MethodsReturnNonnullByDefault
public abstract class PipeBlockEntity<PipeType extends Enum<PipeType> & IPipeType<NodeDataType>, NodeDataType>
extends ManagedSyncBlockEntity
implements IPipeNode<PipeType, NodeDataType>, IToolGridHighlight, IToolable,
implements IPipeNode<PipeType, NodeDataType>, IToolGridHighlight,
ICopyable {

private final long offset = GTValues.RNG.nextInt(20);
Expand Down Expand Up @@ -350,56 +347,41 @@ public ResourceTexture getPipeTexture(boolean isBlock) {
return null;
}

@Override
public Pair<@Nullable GTToolType, InteractionResult> onToolClick(Set<GTToolType> toolTypes, ItemStack itemStack,
UseOnContext context) {
public Pair<@Nullable GTToolType, InteractionResult> onToolClick(ExtendedUseOnContext context) {
// the side hit from the machine grid
var playerIn = context.getPlayer();
if (playerIn == null) return Pair.of(null, InteractionResult.PASS);

var hand = context.getHand();
var hitResult = new BlockHitResult(context.getClickLocation(), context.getClickedFace(),
context.getClickedPos(), false);
Direction gridSide = ICoverable.determineGridSideHit(hitResult);
CoverBehavior coverBehavior = gridSide == null ? null : coverContainer.getCoverAtSide(gridSide);
if (gridSide == null) gridSide = hitResult.getDirection();

// Prioritize covers where they apply (Screwdriver, Soft Mallet)
if (toolTypes.isEmpty() && playerIn.isShiftKeyDown()) {
if (coverBehavior != null) {
return Pair.of(null, coverBehavior.onScrewdriverClick(playerIn, hand, hitResult));
var player = context.getPlayer();
var toolType = context.getToolType();
var gridSide = context.getGridSide();

if (player == null) return Pair.of(null, InteractionResult.PASS);

// Prioritize covers
var cover = getCoverContainer().getCoverAtSide(context.getClickedFace());
if (cover != null) {
var result = cover.onToolClick(context);
if (result.getSecond() != InteractionResult.PASS) return result;

if (toolType.contains(GTToolType.CROWBAR) && !isRemote()) {
getCoverContainer().removeCover(context.getGridSide(), player);
return Pair.of(GTToolType.CROWBAR, InteractionResult.SUCCESS);
}
}
if (toolTypes.contains(GTToolType.SCREWDRIVER)) {
if (coverBehavior != null) {
return Pair.of(GTToolType.SCREWDRIVER, coverBehavior.onScrewdriverClick(playerIn, hand, hitResult));
}
} else if (toolTypes.contains(GTToolType.SOFT_MALLET)) {
if (coverBehavior != null) {
return Pair.of(GTToolType.SOFT_MALLET, coverBehavior.onSoftMalletClick(playerIn, hand, hitResult));
}
} else if (toolTypes.contains(getPipeTuneTool())) {
if (playerIn.isShiftKeyDown() && this.canHaveBlockedFaces()) {

if (toolType.contains(getPipeTuneTool())) {
if (player.isShiftKeyDown() && this.canHaveBlockedFaces()) {
boolean isBlocked = this.isBlocked(gridSide);
this.setBlocked(gridSide, !isBlocked);
} else {
boolean isOpen = this.isConnected(gridSide);
this.setConnection(gridSide, !isOpen, false);
}
return Pair.of(getPipeTuneTool(), InteractionResult.sidedSuccess(playerIn.level().isClientSide));
} else if (toolTypes.contains(GTToolType.CROWBAR)) {
if (coverBehavior != null) {
if (!isRemote()) {
getCoverContainer().removeCover(gridSide, playerIn);
return Pair.of(GTToolType.CROWBAR, InteractionResult.sidedSuccess(playerIn.level().isClientSide));
}
} else {
if (!frameMaterial.isNull()) {
Block.popResource(getLevel(), this.getBlockPos(),
GTMaterialBlocks.MATERIAL_BLOCKS.get(TagPrefix.frameGt, frameMaterial).asStack());
frameMaterial = GTMaterials.NULL;
return Pair.of(GTToolType.CROWBAR, InteractionResult.sidedSuccess(playerIn.level().isClientSide));
}
return Pair.of(getPipeTuneTool(), InteractionResult.sidedSuccess(isRemote()));
} else if (toolType.contains(GTToolType.CROWBAR)) {
if (!frameMaterial.isNull()) {
Block.popResource(context.getLevel(), this.getBlockPos(),
GTMaterialBlocks.MATERIAL_BLOCKS.get(TagPrefix.frameGt, frameMaterial).asStack());
frameMaterial = GTMaterials.NULL;
return Pair.of(GTToolType.CROWBAR, InteractionResult.sidedSuccess(isRemote()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class GTCapability {
public static final Capability<IEnergyInfoProvider> CAPABILITY_ENERGY_INFO_PROVIDER = CapabilityManager
.get(new CapabilityToken<>() {});
public static final Capability<ICoverable> CAPABILITY_COVERABLE = CapabilityManager.get(new CapabilityToken<>() {});
public static final Capability<IToolable> CAPABILITY_TOOLABLE = CapabilityManager.get(new CapabilityToken<>() {});
public static final Capability<IWorkable> CAPABILITY_WORKABLE = CapabilityManager.get(new CapabilityToken<>() {});
public static final Capability<IControllable> CAPABILITY_CONTROLLABLE = CapabilityManager
.get(new CapabilityToken<>() {});
Expand All @@ -40,7 +39,6 @@ public static void register(RegisterCapabilitiesEvent event) {
event.register(IEnergyContainer.class);
event.register(IEnergyInfoProvider.class);
event.register(ICoverable.class);
event.register(IToolable.class);
event.register(IWorkable.class);
event.register(IControllable.class);
event.register(IElectricItem.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ public static ICoverable getCoverable(Level level, BlockPos pos, @Nullable Direc
return getBlockEntityCapability(GTCapability.CAPABILITY_COVERABLE, level, pos, side);
}

@Nullable
public static IToolable getToolable(Level level, BlockPos pos, @Nullable Direction side) {
return getBlockEntityCapability(GTCapability.CAPABILITY_TOOLABLE, level, pos, side);
}

@Nullable
public static IWorkable getWorkable(Level level, BlockPos pos, @Nullable Direction side) {
return getBlockEntityCapability(GTCapability.CAPABILITY_WORKABLE, level, pos, side);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
import com.gregtechceu.gtceu.api.transfer.fluid.IFluidHandlerModifiable;
import com.gregtechceu.gtceu.client.renderer.cover.ICoverRenderer;
import com.gregtechceu.gtceu.client.renderer.cover.IDynamicCoverRenderer;
import com.gregtechceu.gtceu.utils.ExtendedUseOnContext;

import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture;

import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.items.IItemHandlerModifiable;

import com.mojang.datafixers.util.Pair;
import lombok.Getter;
import org.jetbrains.annotations.MustBeInvokedByOverriders;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -147,17 +147,28 @@ public boolean canConnectRedstone() {
//////////////////////////////////////
// ******* Interaction *******//
//////////////////////////////////////
public InteractionResult onScrewdriverClick(Player playerIn, InteractionHand hand, BlockHitResult hitResult) {

public final Pair<@Nullable GTToolType, InteractionResult> onToolClick(ExtendedUseOnContext context) {
var toolType = context.getToolType();
if (toolType.contains(GTToolType.SCREWDRIVER)) {
return Pair.of(GTToolType.SCREWDRIVER, onScrewdriverClick(context));
} else if (toolType.contains(GTToolType.SOFT_MALLET)) {
return Pair.of(GTToolType.SOFT_MALLET, onSoftMalletClick(context));
}
return Pair.of(null, InteractionResult.PASS);
}

public InteractionResult onScrewdriverClick(ExtendedUseOnContext context) {
if (this instanceof IMuiCover muiCover) {
if (playerIn instanceof ServerPlayer serverPlayer) {
if (context.getPlayer() instanceof ServerPlayer serverPlayer) {
com.gregtechceu.gtceu.common.mui.factory.CoverUIFactory.INSTANCE.open(serverPlayer, muiCover);
}
return InteractionResult.sidedSuccess(playerIn.level().isClientSide);
return InteractionResult.sidedSuccess(coverHolder.isRemote());
}
return InteractionResult.PASS;
}

public InteractionResult onSoftMalletClick(Player playerIn, InteractionHand hand, BlockHitResult hitResult) {
public InteractionResult onSoftMalletClick(ExtendedUseOnContext context) {
return InteractionResult.PASS;
}

Expand Down
Loading
Loading