use of net.minecraft.block.entity.ChestBlockEntity in project BleachHack by BleachDrinker420.
the class AutoSteal method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
currentTime++;
for (Entry<BlockPos, Integer> e : new HashMap<>(opened).entrySet()) {
if (e.getValue() <= 0)
opened.remove(e.getKey());
else
opened.replace(e.getKey(), e.getValue() - 1);
}
if (currentItems != null && currentSyncId != -1) {
if (currentTime - lastSteal >= getSetting(1).asSlider().getValue()) {
for (int i = 0; i < currentItems.size(); i++) {
if (!currentItems.get(i).isEmpty()) {
if (isBlacklisted(currentItems.get(i).getItem())) {
continue;
}
int fi = i;
boolean openSlot = InventoryUtils.getSlot(false, j -> mc.player.getInventory().getStack(j).isEmpty() || (mc.player.getInventory().getStack(j).isStackable() && mc.player.getInventory().getStack(j).getCount() < mc.player.getInventory().getStack(j).getMaxCount() && currentItems.get(fi).isItemEqual(mc.player.getInventory().getStack(j)))) != 1;
if (openSlot) {
mc.interactionManager.clickSlot(currentSyncId, i, 0, SlotActionType.QUICK_MOVE, mc.player);
currentItems.set(i, ItemStack.EMPTY);
lastSteal = currentTime + RandomUtils.nextInt(0, getSetting(2).asSlider().getValueInt() + 1);
}
return;
}
}
if (getSetting(0).asMode().getMode() >= 1 || getSetting(3).asToggle().getState()) {
mc.setScreen(null);
mc.player.networkHandler.sendPacket(new CloseHandledScreenC2SPacket(currentSyncId));
}
}
} else if (currentItems == null && currentSyncId == -1 && getSetting(3).asToggle().getState()) {
for (BlockEntity be : WorldUtils.getBlockEntities()) {
if (!opened.containsKey(be.getPos()) && be instanceof ChestBlockEntity && mc.player.getEyePos().distanceTo(Vec3d.ofCenter(be.getPos())) <= getSetting(3).asToggle().getChild(0).asSlider().getValue() + 0.25) {
Vec3d lookVec = Vec3d.ofCenter(be.getPos()).add(0, 0.5, 0);
if (getSetting(3).asToggle().getChild(2).asRotate().getState()) {
WorldUtils.facePosAuto(lookVec.x, lookVec.y, lookVec.z, getSetting(3).asToggle().getChild(2).asRotate());
}
mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, new BlockHitResult(lookVec, Direction.UP, be.getPos(), false));
opened.put(be.getPos(), getSetting(3).asToggle().getChild(1).asSlider().getValueInt() * 20);
return;
}
}
}
}
use of net.minecraft.block.entity.ChestBlockEntity in project SeedcrackerX by 19MisterX98.
the class ShipwreckFinder method findInChunk.
@Override
public List<BlockPos> findInChunk() {
Biome biome = this.world.getBiomeForNoiseGen((this.chunkPos.x << 2) + 2, 64, (this.chunkPos.z << 2) + 2).value();
if (!Features.SHIPWRECK.isValidBiome(BiomeFixer.swap(biome))) {
return new ArrayList<>();
}
List<BlockPos> result = super.findInChunk();
result.removeIf(pos -> {
BlockState state = this.world.getBlockState(pos);
if (state.get(ChestBlock.CHEST_TYPE) != ChestType.SINGLE)
return true;
BlockEntity blockEntity = this.world.getBlockEntity(pos);
if (!(blockEntity instanceof ChestBlockEntity))
return true;
return !this.onChestFound(pos);
});
return result;
}
use of net.minecraft.block.entity.ChestBlockEntity in project EdenClient by HahaOO7.
the class ContainerInfo method interactBlock.
private ActionResult interactBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult blockHitResult) {
BlockEntity be = world.getBlockEntity(blockHitResult.getBlockPos());
boolean isLeftChest = false;
if (be instanceof ChestBlockEntity) {
BlockState blockState = world.getBlockState(blockHitResult.getBlockPos());
isLeftChest = blockState.get(ChestBlock.CHEST_TYPE) == ChestType.LEFT;
}
if (be instanceof Inventory && !isLeftChest) {
lastInteractedBlock = blockHitResult.getBlockPos();
} else {
lastInteractedBlock = null;
}
return ActionResult.PASS;
}
use of net.minecraft.block.entity.ChestBlockEntity in project lithium-fabric by CaffeineMC.
the class HopperHelper method vanillaGetBlockInventory.
/**
* Gets the block inventory at the given position, exactly like vanilla gets it.
* Needed because we don't want to search for entity inventories like the vanilla method does.
*
* @param world world we are searching in
* @param blockPos position of the block inventory
* @return the block inventory at the given position
*/
@Nullable
public static Inventory vanillaGetBlockInventory(World world, BlockPos blockPos) {
// [VanillaCopy]
Inventory inventory = null;
BlockState blockState = world.getBlockState(blockPos);
Block block = blockState.getBlock();
if (block instanceof InventoryProvider) {
inventory = ((InventoryProvider) block).getInventory(blockState, world, blockPos);
} else if (blockState.hasBlockEntity()) {
BlockEntity blockEntity = world.getBlockEntity(blockPos);
if (blockEntity instanceof Inventory) {
inventory = (Inventory) blockEntity;
if (inventory instanceof ChestBlockEntity && block instanceof ChestBlock) {
inventory = ChestBlock.getInventory((ChestBlock) block, blockState, world, blockPos, true);
}
}
}
return inventory;
}
Aggregations