tatwanshop
📎 1 file 8,688 chars
📄
pasted-code-1787022312384.txt
txt 555 lines
▶
Create a **Mindcraft AutoCompressor** system whose main function is to compress **64 blocks into 1 single compressed block**.

## CORE FUNCTION

The AutoCompressor must work like this:

**64 normal blocks → 1 compressed block**

When 64 blocks are detected inside the compression area, automatically remove/replace those 64 blocks with **1 AutoCompressed Block**.

The compressed block must remember the exact contents of the 64 original blocks so they can be restored later.

---

## BLOCK 1 — AUTO COMPRESSOR

Create an **AutoCompressor** block.

When placed in the world, it creates a compression area around itself.

Default capacity:

**64 blocks = 1 compressed block**

The AutoCompressor continuously scans the defined area for blocks.

---

## BLOCK 2 — INPUT AREA

Create an input area where blocks are placed.

The system should count blocks entering the compressor.

Example:

* 1 block → 1/64
* 16 blocks → 16/64
* 32 blocks → 32/64
* 48 blocks → 48/64
* 63 blocks → 63/64
* 64 blocks → COMPRESSION READY

Display the current count.

---

## BLOCK 3 — 64-BLOCK DETECTOR

Create a detector that checks whether exactly **64 compressible blocks** are available.

Logic:

```text
IF block_count >= 64
    THEN compress 64 blocks
ELSE
    continue counting
```

Do not compress until 64 valid blocks are available.

---

## BLOCK 4 — COMPRESSION PROCESS

When 64 blocks are detected:

1. Read all 64 blocks.
2. Save their block IDs/types.
3. Save their metadata/state if applicable.
4. Save their positions/order.
5. Remove the original 64 blocks.
6. Create 1 compressed block.
7. Store the saved information inside the compressed block.

Result:

```text
64 BLOCKS
     ↓
AUTO COMPRESSOR
     ↓
1 COMPRESSED BLOCK
```

---

## BLOCK 5 — COMPRESSED BLOCK

Create a special block called:

**Compressed Block {item}**

This block represents the 64 original blocks.

It should visually indicate that it contains compressed blocks.

Example label:

**Compressed ×64**

---

## BLOCK 6 — DATA STORAGE

Every compressed block must store:

* Number of blocks
* Block type of each block
* Original positions
* Block metadata
* Orientation/state where supported
* Compression version
* Original arrangement

Example data:

```text
CompressedBlock {
    count: 64,
    blocks: [
        block_1,
        block_2,
        block_3,
        ...
        block_64
    ]
}
```

Do not lose the original block information.

---

## BLOCK 7 — STACKING

Allow compressed blocks to be compressed again.

For example:

```text
64 blocks
↓
1 compressed block

64 compressed blocks
↓
1 super-compressed block
```

If a compressed block contains 64 normal blocks, calculate its total contents correctly.

Example:

```text
64 × 64 = 4,096 blocks
```

Therefore:

```text
4,096 normal blocks
↓
64 compressed blocks
↓
1 super-compressed block
```

---

## BLOCK 8 — DECOMPRESS

Create a **Decompress** function.

When the player activates a compressed block:

```text
1 compressed block
↓
64 original blocks
```

Restore the blocks to their saved positions/order.

The original structure must be reconstructed as accurately as possible.

---

## BLOCK 9 — PREVIEW

When looking at a compressed block, display:

**Compressed Block**

**Contains: 64 blocks**

Also show:

* Block types
* Total quantity
* Original dimensions
* Compression ratio

Example:

```text
Compressed Block
----------------
Blocks: 64
Size: 64 → 1
Compression: 98.4%
```

---

## BLOCK 10 — COMPRESSION RATIO

Calculate:

```text
compression_ratio = original_block_count / compressed_block_count
```

For the default system:

```text
64 / 1 = 64:1
```

Display:

**Compression Ratio: 64:1**

---

## BLOCK 11 — AUTOMATIC MODE

The AutoCompressor should operate automatically.

The player should not need to manually select 64 blocks.

Workflow:

```text
Detect blocks
↓
Count blocks
↓
Reach 64
↓
Automatically compress
↓
Create compressed block
```

---

## BLOCK 12 — MANUAL MODE

Also provide an optional manual mode.

Player activates the compressor and chooses:

**Compress 64 Blocks**

The system then performs the same compression operation.

---

## BLOCK 13 — VALID BLOCK TYPES

Allow configuration of which blocks can be compressed.

Example:

* Stone
* Dirt
* Cobblestone
* Wood
* Glass
* Bricks
* Ores
* Building blocks

Add an allowlist/denylist system.

---

## BLOCK 14 — PROTECTED BLOCKS

Do NOT automatically compress protected or special blocks unless explicitly enabled.

Examples:

* Player entities
* Chests with important inventories
* Machines
* Controllers
* Spawn-related blocks
* Special functional blocks

Provide a configuration option for administrators.

---

## BLOCK 15 — MIXED BLOCKS

Allow the compressor to handle mixed blocks.

Example:

```text
20 Stone
15 Dirt
10 Wood
10 Glass
9 Cobblestone
----------------
64 blocks
```

Compress them into:

```text
1 Mixed Compressed Block
```

The compressed block must remember every block type and quantity.

---

## BLOCK 16 — IDENTICAL BLOCK MODE

Add an optional mode that only compresses identical blocks.

Example:

```text
64 Stone
↓
1 Compressed Stone Block
```

If the input contains different block types, wait until 64 matching blocks are available.

---

## BLOCK 17 — MIXED MODE

Add a mode that allows any combination of approved blocks.

Example:

```text
64 approved blocks
↓
1 Mixed Compressed Block
```

---

## BLOCK 18 — OUTPUT

The compressor should output exactly:

**1 compressed block for every 64 input blocks.**

Example:

```text
64 → 1
128 → 2
192 → 3
256 → 4
640 → 10
```

Only complete groups of 64 should be compressed.

---

## BLOCK 19 — REMAINDER

If fewer than 64 blocks remain, do not compress them.

Example:

```text
100 blocks

64 → 1 compressed block
36 → remain uncompressed
```

---

## BLOCK 20 — USER INTERFACE

Create a simple UI showing:

```text
AUTO COMPRESSOR

Input:
████████████████░░░░ 48/64

Status:
Waiting for 16 more blocks

Compression:
64 → 1

Mode:
[Automatic]

Output:
0 compressed blocks
```

When full:

```text
64/64

COMPRESSING...

64 BLOCKS → 1 BLOCK

COMPLETE
```

---

## BLOCK 21 — REDSTONE / SIGNAL OR TRIGGER

If the Mindcraft environment supports signals/events, provide:

**Input Trigger**

* Starts compression detection.

**Output Trigger**

* Activates when compression completes.

Example:

```text
64 blocks detected
↓
Compression
↓
Output signal
```

---

## BLOCK 22 — SAFETY

Before compression:

1. Verify all 64 blocks.
2. Save their data.
3. Confirm the compressed-block data can be stored.
4. Only then remove the original blocks.
5. Create the compressed block.

If anything fails, restore the original blocks.

Never destroy blocks without successfully saving their contents.

---

## BLOCK 23 — PERFORMANCE

Optimize the compressor so it does not scan the entire world every tick.

Use:

* Local scan area
* Event-based detection where possible
* Efficient block counting
* Cached data
* Batch processing

Avoid unnecessary repeated scanning.

---

## BLOCK 24 — FINAL SYSTEM

The complete AutoCompressor must behave like this:

```text
        64 BLOCKS
             ↓
     ┌────────────────┐
     │ AUTO COMPRESSOR│
     └────────────────┘
             ↓
      SAVE BLOCK DATA
             ↓
       REMOVE 64 BLOCKS
             ↓
     CREATE 1 COMPRESSED
             ↓
       ┌─────────────┐
       │ COMPRESSED  │
       │    ×64      │
       └─────────────┘
```

### MAIN RULE

**64 blocks must always equal 1 compressed block.**

Support:

```text
64   → 1
128  → 2
192  → 3
256  → 4
512  → 8
1024 → 16
4096 → 64
```

Also support recursive compression:

```text
64 normal blocks
↓
1 compressed block

64 compressed blocks
↓
1 super-compressed block

64 super-compressed blocks
↓
1 ultra-compressed block
```

The system must preserve the contents and allow decompression back to the original blocks.

### FINAL REQUIREMENT

Build this as a **functional Mindcraft block system**, not merely a visual UI. All detection, counting, storage, compression, output, stacking, mixed-block handling, decompression, and safety logic must be connected and functional.

The fundamental rule is:

**64 BLOCKS → 1 BLOCK**
Kodari AI
KodariAug 18 at 3:09 am 3
AutoCompressorSystem
A Minecraft plugin implementing a functional block compression system. Players place an AutoCompressor block that creates a configurable compression area. The system automatically detects and counts compressible blocks, compressing exactly 64 blocks into 1 compressed block while storing complete block data including types, positions, metadata, and orientation. Features include recursive compression for stacking compressed blocks, decompression to restore original structures, mixed and identical block modes, configurable allow/deny lists for block types, protected block handling, GUI interface showing compression progress and ratios, manual/automatic operation modes, and safety verification ensuring data is saved before block removal. The plugin uses event-driven detection with cached scanning for performance, supporting both single and multi-level compression with full data preservation.
  1. Build the Gradle Bukkit/Paper plugin skeleton and configuration.

  2. Implement persistent compressor/compressed-block data with recursive nesting and safe restoration.

  3. Add automatic/manual compression, allowlist/denylist filtering, protected-block handling, and decompression events.

  4. Add placement/interact/break listeners plus the compressor status GUI and admin commands.

Implemented the Mindcraft AutoCompressor plugin from scratch.

  • Added Gradle project setup, plugin.yml, and configurable config.yml.

  • Added AutoCompressor placement and automatic scanning.

  • Added mixed and identical block compression modes.

  • Added 64-to-1 compression with remainder preservation.

  • Added recursive compressed-block storage using persistent block data.

  • Preserved block states and relative positions.

  • Added safe compression rollback on failure.

  • Added compressed-block preview, statistics, ratio display, and decompression.

  • Added protection for containers and tile entities.

  • Added configurable allowlist and denylist.

  • Added manual compressor GUI with status and compression controls.

  • Added /autocompressor give, /autocompressor reload, and /autocompressor status.

  • Added custom CompressionCompleteEvent for output-trigger integrations.

  • Added piston protection and compressed-block item handling.

tatwanshop

for version 1.21.4 in paper

Kodari AI
KodariAug 18 at 3:15 am 1
  1. Update the build and plugin metadata to target Paper 1.21.4.

  2. Fix any API/version incompatibilities in the existing compressor code.

Updated the plugin for Paper 1.21.4:

  • Replaced Spigot API with: io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT

  • Added the Paper Maven repository.

  • Updated Java toolchain from Java 8 to Java 21, required by Paper 1.21.4.

  • Updated plugin.yml to api-version: '1.21'.

  • Removed the remaining direct Material.STONE fallback in the GUI and switched it to XSeries-compatible material resolution.

tatwanshop

not working /autocompressor

Kodari AI
KodariAug 18 at 3:34 am 1

Fixed /autocompressor command handling.

Changes:

  • Added Paper plugin library loading for XSeries.

  • Added a working help response for /autocompressor and /autocompressor help.

  • Added a null check so the plugin reports a missing command instead of failing silently.

  • Fixed /autocompressor status to show the actual block count and capacity when not looking directly at a compressor.

Use:

Plain Text
/autocompressor
/autocompressor help
/autocompressor status
/autocompressor give <player> compressor
/autocompressor give <player> compressed
/autocompressor reload

After replacing the plugin JAR, restart the Paper 1.21.4 server rather than using /reload. If the command still says it is unknown, check the server console for a plugin loading error—especially whether the plugin is shown as enabled.

tatwanshop

its not working

Kodari AI
KodariAug 18 at 3:36 am 2

Fixed the most likely cause: the plugin was failing before command registration because XSeries was not reliably available at runtime.

Changes:

  • Removed XSeries from the plugin.

  • Removed the Paper libraries dependency entry.

  • Replaced XSeries material calls with native Paper 1.21.4 Material APIs.

  • /autocompressor can now register without an external library.

Build a new JAR, remove the old JAR from plugins, copy in the new one, and fully restart the server. Do not use /reload.

If it still fails, send the exact console error from server startup—especially the lines beginning with ERROR, Could not load, or Caused by.

tatwanshop

not compressing the block

Kodari AI
KodariAug 18 at 3:38 am 1
  1. Trace the block-break/compression flow and identify why eligible blocks are not being converted.

  2. Patch the listener/manager logic for Paper 1.21.4 while preserving the existing configuration.

The compression transaction is rolling back every time: it checks whether the original input block is a tile entity before replacing it with the configured compressed material. Ordinary blocks like stone fail that check, so no compression remains.

Fixed the compression rollback bug.

The plugin was incorrectly requiring the original block location to already be a tile entity before converting it into a compressed barrel. Normal blocks such as stone are not tile entities, so compression always rolled back.

Rebuild the plugin JAR, replace it on the server, and fully restart Paper. Ensure at least 64 valid blocks are within the configured radius of the dispenser, unless you changed capacity in config.yml.

tatwanshop

can you tell me how its work?

Kodari AI
KodariAug 18 at 3:43 am 2

The plugin works as an automatic block compressor.

1. Give yourself a compressor

As an operator, run:

Plain Text
/autocompressor give YourName compressor

Permission required:

Plain Text
autocompressor.admin

This gives you the custom compressor item, which is a dispenser by default.

2. Place the compressor

Place the item like a normal dispenser.

Only the custom item from the command becomes an active compressor. A regular dispenser will not work.

After placing it, you should see a message similar to:

Plain Text
AutoCompressor placed. Input radius: 3.

3. Put blocks near it

Place eligible blocks around the compressor within the configured radius.

Default settings:

YAML
capacity: 64
scan-radius: 3
automatic: true
scan-interval-ticks: 20

This means:

  • It scans a cube 3 blocks in every direction.

  • It checks approximately every second.

  • It needs 64 valid blocks for one compression.

  • The compressor itself is not included in the scan.

For example, if there are 64 stone blocks around it, they should become one compressed block.

4. Which blocks can be compressed?

The default allowed blocks are listed under:

YAML
valid-blocks:

For example:

YAML
- STONE
- COBBLESTONE
- DIRT
- SAND
- GRAVEL
- GLASS
- IRON_ORE
- DIAMOND_ORE

If the block is not listed there, it will not be compressed.

You can add more blocks to valid-blocks, for example:

YAML
valid-blocks:
  - STONE
  - COBBLESTONE
  - NETHERRACK
  - QUARTZ_BLOCK

Then run:

Plain Text
/autocompressor reload

or restart the server.

5. What does it create?

When enough blocks are found, they are replaced with a compressed block.

The default output material is:

YAML
compressed-material: BARREL

The compressed block stores the original block information. It can be broken and placed again without losing its contents.

6. Manual compression

Right-click the placed compressor to open its menu.

The menu shows:

  • Number of eligible blocks nearby

  • Required capacity

  • Automatic/manual mode

  • A manual compression button

You can also check its status with:

Plain Text
/autocompressor status

7. Decompressing

Right-click a compressed block to restore the original blocks.

Sneak and right-click it to preview its contents.

8. Important requirements

Check these first if it is not compressing:

YAML
automatic: true
capacity: 64
scan-radius: 3

Also verify:

  1. You used the custom item from /autocompressor give, not a normal dispenser.

  2. There are at least 64 valid blocks.

  3. The blocks are within 3 blocks in X, Y, and Z.

  4. The block material is listed under valid-blocks.

  5. The chunks containing the compressor are loaded.

  6. You restarted the server after installing the new JAR.

  7. You are not using /reload.

For a quick test, change the configuration temporarily to:

YAML
capacity: 2
scan-radius: 3
automatic: true

Place two stone blocks next to the compressor and wait a few seconds. If that works, the plugin is functioning and the original issue was likely the 64-block requirement or the block not being included in valid-blocks.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
14 949
src/main/java/com/kodari/mindcraft/AutoCompressorPlugin.java
package com.kodari.mindcraft;

import com.kodari.mindcraft.gui.GUIListener;
import com.kodari.mindcraft.gui.GUIManager;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public final class AutoCompressorPlugin extends JavaPlugin implements CommandExecutor, TabCompleter {
    private CompressorManager compressorManager;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        GUIManager guiManager = new GUIManager();
        this.compressorManager = new CompressorManager(this);
        Bukkit.getPluginManager().registerEvents(new CompressorListener(this, compressorManager, guiManager), this);
        Bukkit.getPluginManager().registerEvents(new GUIListener(guiManager), this);
        PluginCommand command = getCommand("autocompressor");
        if (command == null) {
            getLogger().severe("The autocompressor command is missing from plugin.yml; disabling plugin.");
            getServer().getPluginManager().disablePlugin(this);
            return;
        }
        command.setExecutor(this);
        command.setTabCompleter(this);
        compressorManager.start();
    }

    @Override
    public void onDisable() {
        if (compressorManager != null) compressorManager.stop();
    }

    public CompressorManager getCompressorManager() { return compressorManager; }

    public String message(String key) {
        return getConfig().getString("messages.prefix", "") + getConfig().getString("messages." + key, key);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
            sender.sendMessage("§bAutoCompressor §7commands:");
            sender.sendMessage("§f/autocompressor status §7- view the targeted compressor");
            sender.sendMessage("§f/autocompressor give <player> <compressor|compressed> [amount]");
            sender.sendMessage("§f/autocompressor reload");
            return true;
        }
        if (args[0].equalsIgnoreCase("status")) {
            if (!(sender instanceof Player)) {
                sender.sendMessage("Only players can view compressor status.");
                return true;
            }
            if (compressorManager.openLookingAt((Player) sender)) return true;
            Player player = (Player) sender;
            org.bukkit.block.Block target = player.getTargetBlock(null, 6);
            int count = target == null ? 0 : compressorManager.count(target.getLocation());
            sender.sendMessage(message("not-ready").replace('&', '§')
                    .replace("%count%", String.valueOf(count))
                    .replace("%capacity%", String.valueOf(compressorManager.getCapacity())));
            return true;
        }
        if (!sender.hasPermission("autocompressor.admin")) {
            sender.sendMessage(message("no-permission").replace('&', '§'));
            return true;
        }
        if (args[0].equalsIgnoreCase("reload")) {
            reloadConfig();
            compressorManager.reloadSettings();
            sender.sendMessage(message("reloaded").replace('&', '§'));
            return true;
        }
        if (!args[0].equalsIgnoreCase("give") || args.length < 3) {
            sender.sendMessage(message("invalid-usage").replace('&', '§'));
            return true;
        }
        Player target = Bukkit.getPlayerExact(args[1]);
        if (target == null) {
            sender.sendMessage("§cThat player is not online.");
            return true;
        }
        int amount = 1;
        if (args.length >= 4) {
            try { amount = Math.max(1, Math.min(64, Integer.parseInt(args[3]))); }
            catch (NumberFormatException exception) {
                sender.sendMessage(message("invalid-usage").replace('&', '§'));
                return true;
            }
        }
        ItemStack item;
        if (args[2].equalsIgnoreCase("compressor")) item = compressorManager.createCompressorItem(amount);
        else if (args[2].equalsIgnoreCase("compressed")) item = compressorManager.createCompressedItem(new CompressionData(Collections.emptyList()), amount);
        else {
            sender.sendMessage(message("invalid-usage").replace('&', '§'));
            return true;
        }
        target.getInventory().addItem(item);
        sender.sendMessage(message("given").replace('&', '§').replace("%amount%", String.valueOf(amount)).replace("%item%", args[2]));
        return true;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        if (args.length == 1) return filter(Arrays.asList("give", "reload", "status"), args[0]);
        if (args.length == 2 && args[0].equalsIgnoreCase("give")) {
            List<String> names = new ArrayList<>();
            for (Player player : Bukkit.getOnlinePlayers()) names.add(player.getName());
            return filter(names, args[1]);
        }
        if (args.length == 3 && args[0].equalsIgnoreCase("give")) return filter(Arrays.asList("compressor", "compressed"), args[2]);
        return Collections.emptyList();
    }

    private List<String> filter(List<String> values, String prefix) {
        List<String> result = new ArrayList<>();
        for (String value : values) if (value.toLowerCase().startsWith(prefix.toLowerCase())) result.add(value);
        return result;
    }
}