Skip to content

Commit

Permalink
1.19.4 port
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Jun 12, 2023
1 parent 9d2115e commit 7e8d72b
Show file tree
Hide file tree
Showing 31 changed files with 111 additions and 102 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ archivesBaseName = 'SimpleStorageNetwork'

println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {
mappings channel: 'official', version: '1.19.3'
mappings channel: 'official', version: "${mc_version}"


accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
Expand Down Expand Up @@ -72,8 +72,8 @@ dependencies {

implementation fg.deobf("top.theillusivec4.curios:curios-forge:${mc_version}-${curios_version}")

compileOnly fg.deobf("vazkii.patchouli:Patchouli:${mc_version}-${patchouli_version}-SNAPSHOT:api") //Change to actual version when it releases
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${mc_version}-${patchouli_version}-SNAPSHOT")
// compileOnly fg.deobf("vazkii.patchouli:Patchouli:${mc_version}-${patchouli_version}:api") //TODO actual version when it releases
// runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${mc_version}-${patchouli_version}")

}

Expand Down
11 changes: 6 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ org.gradle.daemon=false
# implementation fg.deobf("curse.maven:simple-storage-network-268495:3163007")
curse_id=268495

mod_version=1.8.0
mod_version=1.9.0


# optional dependencies

mc_version=1.19.3
forge_version=44.1.8
mc_version=1.19.4
forge_version=45.1.0

# optional dependencies
jei_version=12.1.1.9
curios_version=5.1.2.0
jei_version=13.1.0.11
curios_version=5.1.5.3
patchouli_version=78




# folder to copy the build output jar
dist_folder=

Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/lothrazar/storagenetwork/api/DimPos.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.items.IItemHandler;

public class BlockCable extends BaseBlock implements SimpleWaterloggedBlock {
Expand Down Expand Up @@ -77,7 +77,7 @@ public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState n
if (state.getBlock() != newState.getBlock()) {
BlockEntity tileentity = worldIn.getBlockEntity(pos);
if (tileentity != null) {
IItemHandler items = tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(null);
IItemHandler items = tileentity.getCapability(ForgeCapabilities.ITEM_HANDLER).orElse(null);
if (items != null) {
for (int i = 0; i < items.getSlots(); ++i) {
Containers.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), items.getStackInSlot(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.common.util.NonNullSupplier;
import net.minecraftforge.items.CapabilityItemHandler;

public class TileCollection extends TileConnectable implements MenuProvider {

Expand Down Expand Up @@ -53,7 +53,7 @@ public Component getDisplayName() {
@SuppressWarnings("unchecked")
@Override
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
if (cap == ForgeCapabilities.ITEM_HANDLER) {
IConnectable capabilityConnectable = super.getCapability(StorageNetworkCapabilities.CONNECTABLE_CAPABILITY, side).orElse(null);
DimPos m = getMain();
if (capabilityConnectable != null && m != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.common.util.NonNullSupplier;
import net.minecraftforge.items.CapabilityItemHandler;

public class TileExchange extends TileConnectable {

Expand All @@ -40,7 +40,7 @@ public void saveAdditional(CompoundTag compound) {
@SuppressWarnings("unchecked")
@Override
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
if (cap == ForgeCapabilities.ITEM_HANDLER) {
try {
IConnectable capabilityConnectable = super.getCapability(StorageNetworkCapabilities.CONNECTABLE_CAPABILITY, side).orElse(null);
DimPos m = getMain();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player
}
//sync
ServerPlayer sp = (ServerPlayer) player;
PacketRegistry.INSTANCE.sendTo(new SortClientMessage(pos, tile.isDownwards(), tile.getSort()), sp.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT);
PacketRegistry.INSTANCE.sendTo(new SortClientMessage(pos, tile.isDownwards(), tile.getSort()), sp.connection.connection, NetworkDirection.PLAY_TO_CLIENT);
//end sync
if (tile instanceof MenuProvider) {
NetworkHooks.openScreen((ServerPlayer) player, (MenuProvider) tile, tile.getBlockPos());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void init() {
addRenderableWidget(network.sortBtn);
addRenderableWidget(network.focusBtn);
if (this.getAutoFocus()) {
network.searchBar.setFocus(true);
network.searchBar.setFocused(true);
}
if (ModList.get().isLoaded("jei")) {
addRenderableWidget(network.jeiBtn);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.lothrazar.storagenetwork.block.main;

import java.util.Set;

import com.lothrazar.storagenetwork.StorageNetworkMod;
import com.lothrazar.storagenetwork.api.DimPos;
import com.lothrazar.storagenetwork.api.EnumStorageDirection;
Expand All @@ -22,7 +21,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.items.IItemHandler;

public class TileMain extends BlockEntity {
Expand Down Expand Up @@ -126,7 +125,7 @@ private void updateImports() {
if (storage.isStockMode()) {
int filterSize = storage.getFilters().getStackCount(stackCurrent);
BlockEntity tileEntity = level.getBlockEntity(connectable.getPos().getBlockPos().relative(storage.facingInventory()));
IItemHandler targetInventory = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).orElse(null);
IItemHandler targetInventory = tileEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, null).orElse(null);
//request with false to see how many even exist in there.
int chestHowMany = UtilInventory.countHowMany(targetInventory, stackCurrent);
//so if chest=37 items of that kind
Expand Down Expand Up @@ -187,7 +186,6 @@ private void updateProcess() {
private void updateExports() {
Set<IConnectable> conSet = nw.getConnectables();
RequestBatch requestBatch = new RequestBatch();

for (IConnectable connectable : conSet) {
if (connectable == null || connectable.getPos() == null) {
// StorageNetwork.log("null connectable or pos : updateExports() ");
Expand Down Expand Up @@ -218,7 +216,6 @@ private void updateExports() {
if (matcher.getStack().isEmpty()) {
continue;
}

Request request = new Request(storage);
// default amt to request. can be overriden by other upgrades
// check operations upgrade for export
Expand All @@ -229,7 +226,7 @@ private void updateExports() {
try {
BlockEntity tileEntity = level
.getBlockEntity(connectable.getPos().getBlockPos().relative(storage.facingInventory()));
IItemHandler targetInventory = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)
IItemHandler targetInventory = tileEntity.getCapability(ForgeCapabilities.ITEM_HANDLER, null)
.orElse(null);
// request with false to see how many even exist in there.
int stillNeeds = UtilInventory.containsAtLeastHowManyNeeded(targetInventory, matcher.getStack(),
Expand All @@ -241,7 +238,8 @@ private void updateExports() {
}
request.setCount(Math.min(stillNeeds, request.getCount()));
StorageNetworkMod.log("updateExports stock mode edited value: amtToRequest = " + request.getCount());
} catch (Throwable e) {
}
catch (Throwable e) {
StorageNetworkMod.LOGGER.error("Error thrown from a connected block" + e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player
}
//sync
ServerPlayer sp = (ServerPlayer) player;
PacketRegistry.INSTANCE.sendTo(new SortClientMessage(pos, tile.isDownwards(), tile.getSort()), sp.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT);
PacketRegistry.INSTANCE.sendTo(new SortClientMessage(pos, tile.isDownwards(), tile.getSort()), sp.connection.connection, NetworkDirection.PLAY_TO_CLIENT);
//end sync
if (tile instanceof MenuProvider) {
NetworkHooks.openScreen((ServerPlayer) player, (MenuProvider) tile, tile.getBlockPos());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void init() {
addRenderableWidget(network.sortBtn);
addRenderableWidget(network.focusBtn);
if (this.getAutoFocus()) {
network.searchBar.setFocus(true);
network.searchBar.setFocused(true);
}
if (ModList.get().isLoaded("jei")) {
addRenderableWidget(network.jeiBtn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;

Expand Down Expand Up @@ -80,7 +80,7 @@ public List<ItemStack> getStoredStacks(boolean isFiltered) {
}
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
// Test whether the connected block has the IItemHandler capability
IItemHandler itemHandler = inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventoryFace.getOpposite());
IItemHandler itemHandler = inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER, inventoryFace.getOpposite());
if (itemHandler == null) {
return Collections.emptyList();
}
Expand Down Expand Up @@ -191,7 +191,7 @@ public ItemStack insertStack(ItemStack stack, boolean simulate) {
}
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
// Test whether the connected block has the IItemHandler capability
IItemHandler itemHandler = inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventoryFace.getOpposite());
IItemHandler itemHandler = inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER, inventoryFace.getOpposite());
if (itemHandler == null) {
return stack;
}
Expand All @@ -204,7 +204,7 @@ public List<ItemStack> getStacksForFilter() {
}
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
// Test whether the connected block has the IItemHandler capability
IItemHandler itemHandler = inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventoryFace.getOpposite());
IItemHandler itemHandler = inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER, inventoryFace.getOpposite());
if (itemHandler == null) {
return Collections.emptyList();
}
Expand Down Expand Up @@ -238,7 +238,7 @@ public IItemHandler getItemHandler() {
return null;
}
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
return inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventoryFace.getOpposite());
return inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER, inventoryFace.getOpposite());
}

@Deprecated
Expand All @@ -257,7 +257,7 @@ public ItemStack extractNextStack(final int amtToRequestIn, boolean simulate) {
}
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
// Test whether the connected block has the IItemHandler capability
IItemHandler itemHandler = inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventoryFace.getOpposite());
IItemHandler itemHandler = inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER, inventoryFace.getOpposite());
if (itemHandler == null) {
return ItemStack.EMPTY;
}
Expand Down Expand Up @@ -365,8 +365,5 @@ public UpgradesItemStackHandler getUpgrades() {
return upgrades;
}

public void extractFromSlot(int slot){

}

public void extractFromSlot(int slot) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.lothrazar.storagenetwork.StorageNetworkMod;
import com.lothrazar.storagenetwork.api.DimPos;
import com.lothrazar.storagenetwork.api.EnumStorageDirection;
Expand All @@ -14,13 +13,12 @@
import com.lothrazar.storagenetwork.registry.StorageNetworkCapabilities;
import com.lothrazar.storagenetwork.util.StackProvider;
import com.lothrazar.storagenetwork.util.StackProviderBatch;

import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;

Expand Down Expand Up @@ -72,7 +70,7 @@ public List<ItemStack> getStoredStacks(boolean isFiltered) {
}
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
// Test whether the connected block has the IItemHandler capability
IItemHandler itemHandler = inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventoryFace.getOpposite());
IItemHandler itemHandler = inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER, inventoryFace.getOpposite());
if (itemHandler == null) {
return Collections.emptyList();
}
Expand Down Expand Up @@ -107,7 +105,7 @@ public ItemStack insertStack(ItemStack stack, boolean simulate) {
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
try {
// Test whether the connected block has the IItemHandler capability
IItemHandler itemHandler = inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventoryFace.getOpposite());
IItemHandler itemHandler = inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER, inventoryFace.getOpposite());
if (itemHandler == null) {
return stack;
}
Expand Down Expand Up @@ -139,7 +137,7 @@ public ItemStack extractStack(IItemStackMatcher matcher, int size, boolean simul
}
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
// Test whether the connected block has the IItemHandler capability
IItemHandler itemHandler = inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventoryFace.getOpposite());
IItemHandler itemHandler = inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER, inventoryFace.getOpposite());
if (itemHandler == null) {
return ItemStack.EMPTY;
}
Expand Down Expand Up @@ -197,7 +195,7 @@ public int getEmptySlots() {
}
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
// Test whether the connected block has the IItemHandler capability
IItemHandler itemHandler = inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, inventoryFace.getOpposite());
IItemHandler itemHandler = inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER, inventoryFace.getOpposite());
if (itemHandler == null) {
return 0;
}
Expand Down Expand Up @@ -269,17 +267,19 @@ public void deserializeNBT(CompoundTag nbt) {
}
}

@Override
public ItemStack extractFromSlot(int slot, int amount, boolean simulate) {
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
// Test whether the connected block has the IItemHandler capability
IItemHandler itemHandler = inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
IItemHandler itemHandler = inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER,
inventoryFace.getOpposite());
if (itemHandler == null) {
return ItemStack.EMPTY;
}
return itemHandler.extractItem(slot, amount, simulate);
}

@Override
public void addToStackProviderBatch(StackProviderBatch availableItems) {
// If this storage is configured to only export from the network, do not
// extract from the storage, but abort immediately.
Expand All @@ -291,7 +291,7 @@ public void addToStackProviderBatch(StackProviderBatch availableItems) {
}
DimPos inventoryPos = connectable.getPos().offset(inventoryFace);
// Test whether the connected block has the IItemHandler capability
IItemHandler itemHandler = inventoryPos.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
IItemHandler itemHandler = inventoryPos.getCapability(ForgeCapabilities.ITEM_HANDLER,
inventoryFace.getOpposite());
if (itemHandler == null) {
return;
Expand Down
Loading

0 comments on commit 7e8d72b

Please sign in to comment.