Skip to content

Commit dffe0d7

Browse files
committed
feat: cauldron mud functionality
1 parent 013a290 commit dffe0d7

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package me.machinemaker.papertweaks.modules.survival.cauldronmud;
2+
3+
import io.papermc.paper.event.entity.EntityInsideBlockEvent;
4+
import java.util.Set;
5+
import me.machinemaker.papertweaks.modules.ModuleListener;
6+
import org.bukkit.Material;
7+
import org.bukkit.entity.Item;
8+
import org.bukkit.event.EventHandler;
9+
import org.bukkit.event.EventPriority;
10+
import org.bukkit.inventory.ItemStack;
11+
12+
class CauldronListener implements ModuleListener {
13+
14+
private static final Set<Material> VALID_DIRT_TYPES = Set.of(
15+
Material.DIRT,
16+
Material.COARSE_DIRT,
17+
Material.ROOTED_DIRT
18+
);
19+
20+
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
21+
public void onEntityInsideBlock(final EntityInsideBlockEvent event) {
22+
if (event.getEntity() instanceof final Item item
23+
&& event.getBlock().getType() == Material.WATER_CAULDRON
24+
&& VALID_DIRT_TYPES.contains(item.getItemStack().getType())) {
25+
item.getWorld().dropItem(
26+
item.getLocation(),
27+
new ItemStack(CauldronMud.toMudFromDirt(item.getItemStack().getType()), item.getItemStack().getAmount())
28+
);
29+
item.remove();
30+
}
31+
}
32+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* GNU General Public License v3
3+
*
4+
* PaperTweaks, a performant replacement for the VanillaTweaks datapacks.
5+
*
6+
* Copyright (C) 2021-2025 Machine_Maker
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, version 3.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
package me.machinemaker.papertweaks.modules.survival.cauldronmud;
21+
22+
import java.util.Collection;
23+
import java.util.Set;
24+
import me.machinemaker.papertweaks.annotations.ModuleInfo;
25+
import me.machinemaker.papertweaks.modules.ModuleBase;
26+
import me.machinemaker.papertweaks.modules.ModuleLifecycle;
27+
import me.machinemaker.papertweaks.modules.ModuleListener;
28+
import org.bukkit.Material;
29+
30+
@ModuleInfo(name = "CauldronMud", configPath = "survival.cauldron-mud", description = "Make mud using cauldrons")
31+
public class CauldronMud extends ModuleBase {
32+
33+
static Material toMudFromDirt(final Material dirt) {
34+
if (!(dirt.equals(Material.DIRT) || dirt.equals(Material.COARSE_DIRT) || dirt.equals(Material.ROOTED_DIRT))) {
35+
throw new IllegalArgumentException(dirt + " is not a valid dirt type!");
36+
}
37+
38+
return Material.MUD;
39+
}
40+
41+
@Override
42+
protected Collection<Class<? extends ModuleListener>> listeners() {
43+
return Set.of(CauldronListener.class);
44+
}
45+
46+
@Override
47+
protected Class<? extends ModuleLifecycle> lifecycle() {
48+
return ModuleLifecycle.Empty.class;
49+
}
50+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* GNU General Public License v3
3+
*
4+
* PaperTweaks, a performant replacement for the VanillaTweaks datapacks.
5+
*
6+
* Copyright (C) 2021-2025 Machine_Maker
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, version 3.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
/**
21+
* Cauldron Mud module
22+
*/
23+
@DefaultQualifier(NonNull.class)
24+
package me.machinemaker.papertweaks.modules.survival.cauldronmud;
25+
26+
import org.checkerframework.checker.nullness.qual.NonNull;
27+
import org.checkerframework.framework.qual.DefaultQualifier;

0 commit comments

Comments
 (0)