itemvault hunters

This commit is contained in:
Talrey 2022-05-13 13:01:29 -07:00
parent 71af841046
commit 5ca51bd58c
6 changed files with 65 additions and 14 deletions

View file

@ -225,6 +225,7 @@ public class ConnectivityHandler {
part.preventConnectivityUpdate();
cache.put(pos, be);
part.setHeight(height);
part.setWidth(width);
part.notifyMultiUpdated();
}
}

View file

@ -333,7 +333,7 @@ public class BlockMovementChecks {
if (state.getBlock() instanceof FluidTankBlock)
return ConnectivityHandler.isConnected(world, pos, pos.relative(direction)); //FluidTankConnectivityHandler.isConnected(world, pos, pos.relative(direction));
if (state.getBlock() instanceof ItemVaultBlock)
return ItemVaultConnectivityHandler.isConnected(world, pos, pos.relative(direction));
return ConnectivityHandler.isConnected(world, pos, pos.relative(direction)); //ItemVaultConnectivityHandler.isConnected(world, pos, pos.relative(direction));
if (AllBlocks.STICKER.has(state) && state.getValue(StickerBlock.EXTENDED)) {
return direction == state.getValue(StickerBlock.FACING)
&& !isNotSupportive(world.getBlockState(pos.relative(direction)), direction.getOpposite());

View file

@ -4,6 +4,7 @@ import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.api.connectivity.ConnectivityHandler;
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.item.ItemHelper;
@ -85,7 +86,8 @@ public class ItemVaultBlock extends Block implements IWrenchable, ITE<ItemVaultT
.getBlockEntity(context.getClickedPos());
if (te instanceof ItemVaultTileEntity) {
ItemVaultTileEntity vault = (ItemVaultTileEntity) te;
ItemVaultConnectivityHandler.splitVault(vault);
ConnectivityHandler.splitMulti(vault);
//ItemVaultConnectivityHandler.splitVault(vault);
vault.removeController(true);
}
state = state.setValue(LARGE, false);
@ -100,10 +102,11 @@ public class ItemVaultBlock extends Block implements IWrenchable, ITE<ItemVaultT
BlockEntity te = world.getBlockEntity(pos);
if (!(te instanceof ItemVaultTileEntity))
return;
ItemVaultTileEntity tankTE = (ItemVaultTileEntity) te;
ItemHelper.dropContents(world, pos, tankTE.inventory);
ItemVaultTileEntity vaultTE = (ItemVaultTileEntity) te;
ItemHelper.dropContents(world, pos, vaultTE.inventory);
world.removeBlockEntity(pos);
ItemVaultConnectivityHandler.splitVault(tankTE);
//ItemVaultConnectivityHandler.splitVault(tankTE);
ConnectivityHandler.splitMulti(vaultTE);
}
}

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.logistics.block.vault;
import com.simibubi.create.AllSpriteShifts;
import com.simibubi.create.api.connectivity.ConnectivityHandler;
import com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry;
import com.simibubi.create.foundation.block.connected.ConnectedTextureBehaviour;
@ -62,7 +63,7 @@ public class ItemVaultCTBehaviour extends ConnectedTextureBehaviour {
@Override
public boolean connectsTo(BlockState state, BlockState other, BlockAndTintGetter reader, BlockPos pos,
BlockPos otherPos, Direction face) {
return state == other && ItemVaultConnectivityHandler.isConnected(reader, pos, otherPos);
return state == other && ConnectivityHandler.isConnected(reader, pos, otherPos); //ItemVaultConnectivityHandler.isConnected(reader, pos, otherPos);
}
}

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.logistics.block.vault;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.api.connectivity.ConnectivityHandler;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.core.BlockPos;
@ -64,7 +65,8 @@ public class ItemVaultItem extends BlockItem {
if (!ItemVaultBlock.isVault(placedOnState))
return;
ItemVaultTileEntity tankAt = ItemVaultConnectivityHandler.vaultAt(AllTileEntities.ITEM_VAULT.get(), world, placedOnPos);
ItemVaultTileEntity tankAt = ConnectivityHandler.partAt(AllTileEntities.ITEM_VAULT.get(), world, placedOnPos);
//ItemVaultConnectivityHandler.vaultAt(AllTileEntities.ITEM_VAULT.get(), world, placedOnPos);
if (tankAt == null)
return;
ItemVaultTileEntity controllerTE = tankAt.getControllerTE();

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.vault;
import java.util.List;
import com.simibubi.create.AllTileEntities;
import com.simibubi.create.api.connectivity.ConnectivityHandler;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.tileEntity.IMultiTileContainer;
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
@ -62,7 +63,8 @@ public class ItemVaultTileEntity extends SmartTileEntity implements IMultiTileCo
return;
if (!isController())
return;
ItemVaultConnectivityHandler.formVaults(this);
//ItemVaultConnectivityHandler.formVaults(this);
ConnectivityHandler.formMulti(this);
}
protected void updateComparators() {
@ -94,7 +96,7 @@ public class ItemVaultTileEntity extends SmartTileEntity implements IMultiTileCo
if (updateConnectivity)
updateConnectivity();
}
@Override
public BlockPos getLastKnownPos() {
return lastKnownPos;
@ -105,7 +107,7 @@ public class ItemVaultTileEntity extends SmartTileEntity implements IMultiTileCo
return controller == null || worldPosition.getX() == controller.getX()
&& worldPosition.getY() == controller.getY() && worldPosition.getZ() == controller.getZ();
}
private void onPositionChanged() {
removeController(true);
lastKnownPos = worldPosition;
@ -155,7 +157,7 @@ public class ItemVaultTileEntity extends SmartTileEntity implements IMultiTileCo
public BlockPos getController() {
return isController() ? worldPosition : controller;
}
@Override
protected void read(CompoundTag compound, boolean clientPacket) {
super.read(compound, clientPacket);
@ -209,11 +211,11 @@ public class ItemVaultTileEntity extends SmartTileEntity implements IMultiTileCo
compound.put("Inventory", inventory.serializeNBT());
}
}
public ItemStackHandler getInventoryOfBlock() {
return inventory;
}
public void applyInventoryToBlock(ItemStackHandler handler) {
for (int i = 0; i < inventory.getSlots(); i++)
inventory.setStackInSlot(i, i < handler.getSlots() ? handler.getStackInSlot(i) : ItemStack.EMPTY);
@ -248,7 +250,8 @@ public class ItemVaultTileEntity extends SmartTileEntity implements IMultiTileCo
BlockPos vaultPos = alongZ ? worldPosition.offset(xOffset, zOffset, yOffset)
: worldPosition.offset(yOffset, xOffset, zOffset);
ItemVaultTileEntity vaultAt =
ItemVaultConnectivityHandler.vaultAt(AllTileEntities.ITEM_VAULT.get(), level, vaultPos);
//ItemVaultConnectivityHandler.vaultAt(AllTileEntities.ITEM_VAULT.get(), level, vaultPos);
ConnectivityHandler.partAt(AllTileEntities.ITEM_VAULT.get(), level, vaultPos);
invs[yOffset * radius * radius + xOffset * radius + zOffset] =
vaultAt != null ? vaultAt.inventory : new ItemStackHandler();
}
@ -263,4 +266,45 @@ public class ItemVaultTileEntity extends SmartTileEntity implements IMultiTileCo
return radius * 3;
}
@Override
public void preventConnectivityUpdate() { updateConnectivity = false; }
@Override
public void notifyMultiUpdated () {
BlockState state = this.getBlockState();
if (ItemVaultBlock.isVault(state)) { // safety
level.setBlock(getBlockPos(), state.setValue(ItemVaultBlock.LARGE, radius > 2), 22);
}
itemCapability.invalidate();
setChanged();
}
@Override
public Direction.Axis getMainConnectionAxis() { return getMainAxisOf(this); }
@Override
public int getMaxLength (Direction.Axis longAxis, int width) {
if (longAxis == Direction.Axis.Y) return getMaxWidth();
return getMaxLength(width);
}
@Override
public int getMaxWidth () {
return 3;
}
@Override
public int getHeight () { return length; }
@Override
public int getWidth () { return radius; }
@Override
public void setHeight (int height) { this.length = height; }
@Override
public void setWidth (int width) { this.radius = width; }
@Override
public boolean hasItems () { return true; }
}