Skip to content

Commit

Permalink
Update to MC 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jul 12, 2024
1 parent 727b0c7 commit c56db38
Show file tree
Hide file tree
Showing 70 changed files with 171 additions and 154 deletions.
33 changes: 18 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'net.neoforged.gradle.userdev' version '7.0.97'
id 'net.neoforged.gradle.userdev' version '7.0.145'
id 'net.darkhax.curseforgegradle' version '1.0.8'
id 'com.github.kt3k.coveralls' version '2.12.0'
id 'com.diffplug.spotless' version '5.14.3'
Expand Down Expand Up @@ -34,7 +34,7 @@ base {
}

// Set Java details
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
compileJava.options.compilerArgs << "-Xmaxerrs" << "9999"
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

Expand Down Expand Up @@ -102,15 +102,16 @@ dependencies {
}

// Add something like 'integratedtunnelscompat_version_local=0.1.0-DEV' to your gradle.properties if you want to use a custom local Integrated Tunnels Compat version.
if(secrets.integratedtunnelscompat_version_local) {
shadow("org.cyclops.integratedtunnelscompat:integratedtunnelscompat-${project.minecraft_version}-neoforge:${secrets.integratedtunnelscompat_version_local}") {
transitive = false
}
} else {
shadow("org.cyclops.integratedtunnelscompat:integratedtunnelscompat-${project.minecraft_version}-neoforge:${project.integratedtunnelscompat_version}") {
transitive = false
}
}
// TODO
// if(secrets.integratedtunnelscompat_version_local) {
// shadow("org.cyclops.integratedtunnelscompat:integratedtunnelscompat-${project.minecraft_version}-neoforge:${secrets.integratedtunnelscompat_version_local}") {
// transitive = false
// }
// } else {
// shadow("org.cyclops.integratedtunnelscompat:integratedtunnelscompat-${project.minecraft_version}-neoforge:${project.integratedtunnelscompat_version}") {
// transitive = false
// }
// }

if(secrets.commoncapabilities_version_local) {
implementation "org.cyclops.commoncapabilities:commoncapabilities-${project.minecraft_version}-neoforge:${secrets.commoncapabilities_version_local}:deobf"
Expand All @@ -126,10 +127,10 @@ dependencies {
}

// Project lombok
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
testCompileOnly 'org.projectlombok:lombok:1.18.30'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'

testImplementation "junit:junit:4.12"
}
Expand Down Expand Up @@ -341,6 +342,8 @@ publishing {

idea {
module {
downloadSources = true
downloadJavadoc = true
for (String excludeDirName in ["run", "out", "logs", "gradle"]) {
File excludeDir = new File(projectDir, excludeDirName)
excludeDirs.add(excludeDir)
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
mod_id=integratedtunnels
mod_version=1.8.25
minecraft_version=1.20.4
neoforge_version=20.4.160-beta
cyclopscore_version=1.19.0-423
integrateddynamics_version=1.21.2-744
minecraft_version=1.21
neoforge_version=21.0.43-beta
cyclopscore_version=1.19.1-452
integrateddynamics_version=1.21.4-770
integratedtunnelscompat_version=1.0.0-36
release_type=release
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44

commoncapabilities_version=2.9.1-115
commoncapabilities_version=2.9.1-126

# Workaround for Spotless bug
# https://github.com/diffplug/spotless/issues/834
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 8 additions & 8 deletions src/main/java/org/cyclops/integratedtunnels/Capabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@
*/
public class Capabilities {
public static final class ItemNetwork {
public static final NetworkCapability<IItemNetwork> NETWORK = NetworkCapability.create(new ResourceLocation(Reference.MOD_ID, "item_network"), IItemNetwork.class);
public static final NetworkCapability<IItemNetwork> NETWORK = NetworkCapability.create(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "item_network"), IItemNetwork.class);
}
public static final class ItemHandler {
public static final NetworkCapability<IItemHandler> NETWORK = NetworkCapability.create(new ResourceLocation(Reference.MOD_ID, "item_handler"), IItemHandler.class);
public static final PartCapability<IItemHandler> PART = PartCapability.create(new ResourceLocation(Reference.MOD_ID, "item_handler"), IItemHandler.class);
public static final NetworkCapability<IItemHandler> NETWORK = NetworkCapability.create(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "item_handler"), IItemHandler.class);
public static final PartCapability<IItemHandler> PART = PartCapability.create(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "item_handler"), IItemHandler.class);
}
public static final class SlotlessItemHandler {
public static final PartCapability<ISlotlessItemHandler> PART = PartCapability.create(new ResourceLocation(Reference.MOD_ID, "slotless_item_handler"), ISlotlessItemHandler.class);
public static final PartCapability<ISlotlessItemHandler> PART = PartCapability.create(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "slotless_item_handler"), ISlotlessItemHandler.class);
}
public static final class FluidNetwork {
public static final NetworkCapability<IFluidNetwork> NETWORK = NetworkCapability.create(new ResourceLocation(Reference.MOD_ID, "fluid_network"), IFluidNetwork.class);
public static final NetworkCapability<IFluidNetwork> NETWORK = NetworkCapability.create(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "fluid_network"), IFluidNetwork.class);
}
public static final class FluidHandler {
public static final NetworkCapability<IFluidHandler> NETWORK = NetworkCapability.create(new ResourceLocation(Reference.MOD_ID, "fluid_handler"), IFluidHandler.class);
public static final PartCapability<IFluidHandler> PART = PartCapability.create(new ResourceLocation(Reference.MOD_ID, "fluid_handler"), IFluidHandler.class);
public static final NetworkCapability<IFluidHandler> NETWORK = NetworkCapability.create(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "fluid_handler"), IFluidHandler.class);
public static final PartCapability<IFluidHandler> PART = PartCapability.create(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "fluid_handler"), IFluidHandler.class);
}
public static final class EnergyStorage {
public static final PartCapability<IEnergyStorage> PART = PartCapability.create(new ResourceLocation(Reference.MOD_ID, "energy_storage"), IEnergyStorage.class);
public static final PartCapability<IEnergyStorage> PART = PartCapability.create(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "energy_storage"), IEnergyStorage.class);
}

public static void registerPartCapabilities(RegisterPartCapabilitiesEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*/
public class RegistryEntries {

public static final DeferredHolder<Item, Item> ITEM_PART_INTERFACE = DeferredHolder.create(Registries.ITEM, new ResourceLocation("integratedtunnels:part_interface_item"));
public static final DeferredHolder<Item, Item> ITEM_DUMMY_PICKAXE = DeferredHolder.create(Registries.ITEM, new ResourceLocation("integratedtunnels:dummy_pickaxe"));
public static final DeferredHolder<Item, Item> ITEM_PART_INTERFACE = DeferredHolder.create(Registries.ITEM, ResourceLocation.parse("integratedtunnels:part_interface_item"));
public static final DeferredHolder<Item, Item> ITEM_DUMMY_PICKAXE = DeferredHolder.create(Registries.ITEM, ResourceLocation.parse("integratedtunnels:dummy_pickaxe"));

public static final DeferredHolder<MenuType<?>, MenuType<ContainerInterfaceSettings>> CONTAINER_INTERFACE_SETTINGS = DeferredHolder.create(Registries.MENU, new ResourceLocation("integratedtunnels:part_interface_settings"));
public static final DeferredHolder<MenuType<?>, MenuType<ContainerInterfaceSettings>> CONTAINER_INTERFACE_SETTINGS = DeferredHolder.create(Registries.MENU, ResourceLocation.parse("integratedtunnels:part_interface_settings"));

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ public void exceptionCaught(ChannelHandlerContext p_exceptionCaught_1_, Throwabl

}

@Override
public void setListener(PacketListener handler) {

}

@Override
public void send(Packet<?> packetIn) {

Expand Down Expand Up @@ -87,11 +82,6 @@ public PacketListener getPacketListener() {
return null;
}

@Override
public Component getDisconnectedReason() {
return null;
}

@Override
public void setReadOnly() {

Expand Down Expand Up @@ -180,11 +170,6 @@ public void handlePaddleBoat(ServerboundPaddleBoatPacket packetIn) {

}

@Override
public void onDisconnect(Component reason) {

}

@Override
public void send(final Packet<?> packetIn) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public int getTanks() {
public FluidStack getFluidInTank(int tank) {
Block block = this.state.getBlock();
if (block instanceof LiquidBlock && this.state.getValue(LiquidBlock.LEVEL) == 0) {
return new FluidStack(((LiquidBlock) block).getFluid(), FluidHelpers.BUCKET_VOLUME);
return new FluidStack(((LiquidBlock) block).fluid, FluidHelpers.BUCKET_VOLUME);
} else {
return FluidStack.EMPTY;
}
Expand Down Expand Up @@ -70,7 +70,7 @@ public int fill(FluidStack resource, FluidAction action) {
public FluidStack drain(FluidStack resource, FluidAction action) {
Block block = this.state.getBlock();
if (block instanceof LiquidBlock
&& ((LiquidBlock) block).getFluid() == resource.getFluid()) {
&& ((LiquidBlock) block).fluid == resource.getFluid()) {
return this.drain(resource.getAmount(), action);
}
return FluidStack.EMPTY;
Expand All @@ -86,7 +86,7 @@ public FluidStack drain(int maxDrain, FluidAction action) {
if (action.execute()) {
this.world.setBlock(this.blockPos, Blocks.AIR.defaultBlockState(), 11);
}
return new FluidStack(((LiquidBlock) block).getFluid(), FluidHelpers.BUCKET_VOLUME);
return new FluidStack(((LiquidBlock) block).fluid, FluidHelpers.BUCKET_VOLUME);
}
return FluidStack.EMPTY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ public boolean isEmpty() {
}

@Override
public int addItem(ItemStack stack) {
public ItemStack insertItem(ItemStack stack) {
handleDispenseResult(this.dispenseResultHandler, this.blockSource.get(), stack);
return 0;
return ItemStack.EMPTY;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
package org.cyclops.integratedtunnels.core;

import com.google.common.collect.HashMultimap;
import com.google.common.collect.Iterators;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
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.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.neoforged.bus.api.Event;
import net.neoforged.neoforge.common.CommonHooks;
import net.neoforged.neoforge.common.NeoForgeMod;
import net.neoforged.neoforge.common.util.TriState;
import net.neoforged.neoforge.event.EventHooks;
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent;
Expand Down Expand Up @@ -147,7 +152,7 @@ public ItemStack insert(@Nonnull ItemStack stack, boolean simulate) {
}

// Use item first
if (rightClickBlockActionResult.getUseItem() != Event.Result.DENY) {
if (rightClickBlockActionResult.getUseItem() != TriState.FALSE) {
if (!stack.isEmpty()) {
UseOnContext itemUseContext = new UseOnContext(player, hand, blockRayTraceResult);
InteractionResult actionResult = stack.getItem().onItemUseFirst(stack, itemUseContext);
Expand All @@ -166,14 +171,22 @@ public ItemStack insert(@Nonnull ItemStack stack, boolean simulate) {
boolean flag1 = (player.isSecondaryUseActive() && playerHasHeldItem)
&& !(player.getMainHandItem().doesSneakBypassUse(world, pos, player)
&& player.getOffhandItem().doesSneakBypassUse(world, pos, player));
if (rightClickBlockActionResult.getUseBlock() == Event.Result.ALLOW
|| (rightClickBlockActionResult.getUseBlock() != Event.Result.DENY && !flag1)) {
if (rightClickBlockActionResult.getUseBlock() == TriState.TRUE
|| (rightClickBlockActionResult.getUseBlock() != TriState.FALSE && !flag1)) {
BlockState blockState = world.getBlockState(pos);
if (!player.isCrouching() || stack.isEmpty()) {
if (blockState.use(world, player, hand, blockRayTraceResult).consumesAction()) {
ItemInteractionResult iteminteractionresult = blockState.useItemOn(player.getItemInHand(hand), world, player, hand, blockRayTraceResult);
if (iteminteractionresult.consumesAction()) {
returnPlayerInventory(player);
return ItemStack.EMPTY;
}

if (iteminteractionresult == ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION && hand == InteractionHand.MAIN_HAND) {
if (blockState.useWithoutItem(world, player, blockRayTraceResult).consumesAction()) {
returnPlayerInventory(player);
return ItemStack.EMPTY;
}
}
}
}

Expand All @@ -191,7 +204,7 @@ public ItemStack insert(@Nonnull ItemStack stack, boolean simulate) {
}

// Use itemstack
if (rightClickBlockActionResult.getUseItem() != Event.Result.DENY && !stack.isEmpty()) {
if (rightClickBlockActionResult.getUseItem() != TriState.FALSE && !stack.isEmpty()) {
InteractionResult cancelResult = CommonHooks.onItemRightClick(player, hand);
if (cancelResult != null) {
if (cancelResult == InteractionResult.FAIL) {
Expand Down Expand Up @@ -226,10 +239,10 @@ public ItemStack insert(@Nonnull ItemStack stack, boolean simulate) {
}

// Use item
if (rightClickBlockActionResult.getUseItem() != Event.Result.DENY && !stack.isEmpty()) {
if (rightClickBlockActionResult.getUseItem() != TriState.FALSE && !stack.isEmpty()) {
// Increase reach position.
BlockPos targetPos = pos;
double reachDistance = player.getAttribute(NeoForgeMod.BLOCK_REACH.value()).getValue() + 3;
double reachDistance = player.getAttribute(Attributes.BLOCK_INTERACTION_RANGE).getValue() + 3;
int i = 0;
while (i++ < reachDistance && world.isEmptyBlock(targetPos)) {
targetPos = targetPos.relative(side.getOpposite());
Expand All @@ -252,7 +265,7 @@ public ItemStack insert(@Nonnull ItemStack stack, boolean simulate) {
// Check if left clicking is allowed
PlayerInteractEvent.LeftClickBlock event = CommonHooks.onLeftClickBlock(player, pos, side, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK);
BlockState blockState = world.getBlockState(pos);
if (event.isCanceled() || (event.getUseItem() == Event.Result.DENY)) { // Restore block and te data
if (event.isCanceled() || (event.getUseItem() == TriState.FALSE)) { // Restore block and te data
world.sendBlockUpdated(pos, blockState, world.getBlockState(pos), 3);
return stack;
}
Expand Down Expand Up @@ -290,9 +303,11 @@ public ItemStack insert(@Nonnull ItemStack stack, boolean simulate) {
if (entities.size() > 0) {
Entity entity = getEntity(entities);
EquipmentSlot equipmentSlotType = hand == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND;
player.getAttributes().addTransientAttributeModifiers(stack.getAttributeModifiers(equipmentSlotType));
HashMultimap<Holder<Attribute>, AttributeModifier> modifiers = HashMultimap.create();
stack.getAttributeModifiers().forEach(equipmentSlotType, modifiers::put);
player.getAttributes().addTransientAttributeModifiers(modifiers);
player.attack(entity);
player.getAttributes().removeAttributeModifiers(stack.getAttributeModifiers(equipmentSlotType));
player.getAttributes().removeAttributeModifiers(modifiers);
returnPlayerInventory(player);
return ItemStack.EMPTY;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.cyclops.integratedtunnels.part.aspect.ITunnelConnection;

import javax.annotation.Nullable;
import java.util.Objects;
import java.util.Optional;

/**
Expand Down Expand Up @@ -66,7 +67,7 @@ public boolean test(FluidStack input) {
protected static int getFluidStackMatchFlags(final boolean checkFluid, final boolean checkAmount, final boolean checkNbt) {
int matchFlags = FluidMatch.ANY;
if (checkFluid) matchFlags = matchFlags | FluidMatch.FLUID;
if (checkNbt) matchFlags = matchFlags | FluidMatch.TAG;
if (checkNbt) matchFlags = matchFlags | FluidMatch.DATA;
if (checkAmount) matchFlags = matchFlags | FluidMatch.AMOUNT;
return matchFlags;
}
Expand Down Expand Up @@ -110,7 +111,7 @@ public static boolean areFluidStackEqual(FluidStack stackA, FluidStack stackB,
if (stackA != null && stackB != null) {
if (checkAmount && stackA.getAmount() != stackB.getAmount()) return false;
if (checkFluid && stackA.getFluid() != stackB.getFluid()) return false;
if (checkNbt && !FluidStack.areFluidStackTagsEqual(stackA, stackB)) return false;
if (checkNbt && !Objects.equals(stackA.getComponents(), stackB.getComponents())) return false;
return true;
}
return false;
Expand Down Expand Up @@ -189,7 +190,7 @@ public static FluidStack prototypeWithCount(FluidStack prototype, int count) {
if (prototype == null) {
return count == 0 ? null : new FluidStack(Fluids.WATER, count);
} else {
prototype = new FluidStack(prototype, count);
prototype = new FluidStack(prototype.getFluidHolder(), count, prototype.getComponentsPatch());
}
}
return prototype;
Expand Down
Loading

0 comments on commit c56db38

Please sign in to comment.