Skip to content

Commit fd7de64

Browse files
committed
Oxidizing and Waxing API
1 parent 66197fe commit fd7de64

File tree

3 files changed

+84
-10
lines changed

3 files changed

+84
-10
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--- a/net/minecraft/world/item/HoneycombItem.java
2+
+++ b/net/minecraft/world/item/HoneycombItem.java
3+
@@ -2,6 +_,7 @@
4+
5+
import com.google.common.base.Suppliers;
6+
import com.google.common.collect.BiMap;
7+
+import com.google.common.collect.HashBiMap;
8+
import com.google.common.collect.ImmutableBiMap;
9+
import java.util.Optional;
10+
import java.util.function.Supplier;
11+
@@ -21,7 +_,7 @@
12+
13+
public class HoneycombItem extends Item implements SignApplicator {
14+
public static final Supplier<BiMap<Block, Block>> WAXABLES = Suppliers.memoize(
15+
- () -> ImmutableBiMap.<Block, Block>builder()
16+
+ () -> HashBiMap.create(ImmutableBiMap.<Block, Block>builder()
17+
.put(Blocks.COPPER_BLOCK, Blocks.WAXED_COPPER_BLOCK)
18+
.put(Blocks.EXPOSED_COPPER, Blocks.WAXED_EXPOSED_COPPER)
19+
.put(Blocks.WEATHERED_COPPER, Blocks.WAXED_WEATHERED_COPPER)
20+
@@ -58,7 +_,7 @@
21+
.put(Blocks.EXPOSED_COPPER_BULB, Blocks.WAXED_EXPOSED_COPPER_BULB)
22+
.put(Blocks.WEATHERED_COPPER_BULB, Blocks.WAXED_WEATHERED_COPPER_BULB)
23+
.put(Blocks.OXIDIZED_COPPER_BULB, Blocks.WAXED_OXIDIZED_COPPER_BULB)
24+
- .build()
25+
+ .build())
26+
);
27+
public static final Supplier<BiMap<Block, Block>> WAX_OFF_BY_BLOCK = Suppliers.memoize(() -> WAXABLES.get().inverse());
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--- a/net/minecraft/world/level/block/WeatheringCopper.java
2+
+++ b/net/minecraft/world/level/block/WeatheringCopper.java
3+
@@ -2,6 +_,7 @@
4+
5+
import com.google.common.base.Suppliers;
6+
import com.google.common.collect.BiMap;
7+
+import com.google.common.collect.HashBiMap;
8+
import com.google.common.collect.ImmutableBiMap;
9+
import com.mojang.serialization.Codec;
10+
import java.util.Optional;
11+
@@ -11,7 +_,7 @@
12+
13+
public interface WeatheringCopper extends ChangeOverTimeBlock<WeatheringCopper.WeatherState> {
14+
Supplier<BiMap<Block, Block>> NEXT_BY_BLOCK = Suppliers.memoize(
15+
- () -> ImmutableBiMap.<Block, Block>builder()
16+
+ () -> HashBiMap.create(ImmutableBiMap.<Block, Block>builder()
17+
.put(Blocks.COPPER_BLOCK, Blocks.EXPOSED_COPPER)
18+
.put(Blocks.EXPOSED_COPPER, Blocks.WEATHERED_COPPER)
19+
.put(Blocks.WEATHERED_COPPER, Blocks.OXIDIZED_COPPER)
20+
@@ -39,7 +_,7 @@
21+
.put(Blocks.COPPER_BULB, Blocks.EXPOSED_COPPER_BULB)
22+
.put(Blocks.EXPOSED_COPPER_BULB, Blocks.WEATHERED_COPPER_BULB)
23+
.put(Blocks.WEATHERED_COPPER_BULB, Blocks.OXIDIZED_COPPER_BULB)
24+
- .build()
25+
+ .build())
26+
);
27+
Supplier<BiMap<Block, Block>> PREVIOUS_BY_BLOCK = Suppliers.memoize(() -> NEXT_BY_BLOCK.get().inverse());
28+

Diff for: src/main/java/net/neoforged/neoforge/common/CommonHooks.java

+28-10
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,7 @@
9898
import net.minecraft.world.inventory.ClickAction;
9999
import net.minecraft.world.inventory.ContainerLevelAccess;
100100
import net.minecraft.world.inventory.Slot;
101-
import net.minecraft.world.item.AdventureModePredicate;
102-
import net.minecraft.world.item.BucketItem;
103-
import net.minecraft.world.item.CreativeModeTab;
104-
import net.minecraft.world.item.EnchantedBookItem;
105-
import net.minecraft.world.item.Item;
106-
import net.minecraft.world.item.ItemStack;
107-
import net.minecraft.world.item.PotionItem;
108-
import net.minecraft.world.item.SpawnEggItem;
109-
import net.minecraft.world.item.Tiers;
110-
import net.minecraft.world.item.TippedArrowItem;
101+
import net.minecraft.world.item.*;
111102
import net.minecraft.world.item.alchemy.Potion;
112103
import net.minecraft.world.item.alchemy.PotionContents;
113104
import net.minecraft.world.item.context.UseOnContext;
@@ -124,6 +115,7 @@
124115
import net.minecraft.world.level.biome.MobSpawnSettings;
125116
import net.minecraft.world.level.block.Block;
126117
import net.minecraft.world.level.block.Blocks;
118+
import net.minecraft.world.level.block.WeatheringCopper;
127119
import net.minecraft.world.level.block.entity.BlockEntity;
128120
import net.minecraft.world.level.block.state.BlockState;
129121
import net.minecraft.world.level.block.state.pattern.BlockInWorld;
@@ -1360,4 +1352,30 @@ public static void onChunkUnload(PoiManager poiManager, ChunkAccess chunkAccess)
13601352
poiManager.remove(sectionPosKey);
13611353
}
13621354
}
1355+
1356+
/**
1357+
* Registers a before and after blocks that can oxidize and de-oxidize
1358+
*
1359+
* @param before block with less oxidization
1360+
* @param after block with more oxidization
1361+
*/
1362+
public static void registerOxidizableBlock(Block before, Block after) {
1363+
Objects.requireNonNull(before, "Oxidizable Block before must not be null");
1364+
Objects.requireNonNull(after, "Oxidizable Block after must not be null");
1365+
1366+
WeatheringCopper.NEXT_BY_BLOCK.get().put(before, after);
1367+
}
1368+
1369+
/**
1370+
* Registers a before and after blocks that can be waxed and unwaxed
1371+
*
1372+
* @param before the unwaxed block
1373+
* @param after the waxed block
1374+
*/
1375+
public static void registerWaxableBlock(Block before, Block after) {
1376+
Objects.requireNonNull(before, "Waxable before before must not be null");
1377+
Objects.requireNonNull(after, "Waxable Block after must not be null");
1378+
1379+
HoneycombItem.WAXABLES.get().put(before, after);
1380+
}
13631381
}

0 commit comments

Comments
 (0)