fix portablegrid deadlock (#2696)

* fix portablegrid deadlock

* fix using wrong interface

* only delay serverside code

* remove client side calls

* replace with boolean

* changelog

* typos
This commit is contained in:
Darkere
2020-10-03 23:48:32 +02:00
committed by GitHub
parent 17b153d8b5
commit c0836f20ed
2 changed files with 15 additions and 3 deletions

View File

@@ -5,6 +5,7 @@
- Changed JEI transfer error mechanics (raoulvdberge) - Changed JEI transfer error mechanics (raoulvdberge)
- Fixed crash when opening Controller GUI (Darkere) - Fixed crash when opening Controller GUI (Darkere)
- Fixed dye being consumed without effect in some cases (Darkere) - Fixed dye being consumed without effect in some cases (Darkere)
- Fixed deadlock caused by Portable Grid (Darkere)
### 1.9.6 ### 1.9.6
- Port to Minecraft 1.16.3 (raoulvdberge) - Port to Minecraft 1.16.3 (raoulvdberge)

View File

@@ -58,6 +58,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.TranslationTextComponent;
@@ -76,7 +77,7 @@ import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PortableGridTile extends BaseTile implements IGrid, IPortableGrid, IRedstoneConfigurable, IStorageDiskContainerContext { public class PortableGridTile extends BaseTile implements ITickableTileEntity, IGrid, IPortableGrid, IRedstoneConfigurable, IStorageDiskContainerContext {
public static final TileDataParameter<Integer, PortableGridTile> REDSTONE_MODE = RedstoneMode.createParameter(); public static final TileDataParameter<Integer, PortableGridTile> REDSTONE_MODE = RedstoneMode.createParameter();
private static final TileDataParameter<Integer, PortableGridTile> SORTING_DIRECTION = new TileDataParameter<>(DataSerializers.VARINT, 0, PortableGridTile::getSortingDirection, (t, v) -> { private static final TileDataParameter<Integer, PortableGridTile> SORTING_DIRECTION = new TileDataParameter<>(DataSerializers.VARINT, 0, PortableGridTile::getSortingDirection, (t, v) -> {
if (IGrid.isValidSortingDirection(v)) { if (IGrid.isValidSortingDirection(v)) {
@@ -170,6 +171,8 @@ public class PortableGridTile extends BaseTile implements IGrid, IPortableGrid,
private ListNBT enchants = null; private ListNBT enchants = null;
private boolean loadNextTick;
public PortableGridTile(PortableGridBlockItem.Type type) { public PortableGridTile(PortableGridBlockItem.Type type) {
super(type == PortableGridBlockItem.Type.CREATIVE ? RSTiles.CREATIVE_PORTABLE_GRID : RSTiles.PORTABLE_GRID); super(type == PortableGridBlockItem.Type.CREATIVE ? RSTiles.CREATIVE_PORTABLE_GRID : RSTiles.PORTABLE_GRID);
@@ -225,8 +228,7 @@ public class PortableGridTile extends BaseTile implements IGrid, IPortableGrid,
this.loadStorage(); this.loadStorage();
active = isGridActive(); loadNextTick = true;
diskState = getDiskState();
} }
public void applyDataFromItemToTile(ItemStack stack) { public void applyDataFromItemToTile(ItemStack stack) {
@@ -749,4 +751,13 @@ public class PortableGridTile extends BaseTile implements IGrid, IPortableGrid,
public AccessType getAccessType() { public AccessType getAccessType() {
return AccessType.INSERT_EXTRACT; return AccessType.INSERT_EXTRACT;
} }
@Override
public void tick() {
if (loadNextTick) {
active = isGridActive();
diskState = getDiskState();
loadNextTick = false;
}
}
} }