Skip to content

Commit

Permalink
Remove mud bricks in favor of the vanilla block
Browse files Browse the repository at this point in the history
The casting recipe now produces mud (water bottle + dirt is a vanilla recipe)
Still considering if there is a good way to get muddy mangrove roots or packed mud with the smeltery, both require a solid + solid so probably not
  • Loading branch information
KnightMiner committed May 20, 2024
1 parent e811288 commit 1bd76e9
Show file tree
Hide file tree
Showing 39 changed files with 157 additions and 395 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"values": [
"tconstruct:mud_bricks",
"tconstruct:cheese_block",
"tconstruct:earth_congealed_slime",
"tconstruct:sky_congealed_slime",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"type": "tconstruct:casting_basin",
"cast": {
"type": "tconstruct:block_tag",
"tag": "minecraft:convertable_to_mud"
},
"cast_consumed": true,
"cooling_time": 47,
"fluid": {
"amount": 250,
"fluid": "minecraft:water"
},
"result": "minecraft:mud"
}

This file was deleted.

4 changes: 4 additions & 0 deletions src/main/java/slimeknights/tconstruct/TConstruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ private static Block missingBlock(String name) {
case "lavawood" -> TinkerMaterials.blazewood.get();
case "lavawood_slab" -> TinkerMaterials.blazewood.getSlab();
case "lavawood_stairs" -> TinkerMaterials.blazewood.getStairs();
// migrate mud bricks to vanilla
case "mud_bricks" -> Blocks.MUD_BRICKS;
case "mud_bricks_slab" -> Blocks.MUD_BRICK_SLAB;
case "mud_bricks_stairs" -> Blocks.MUD_BRICK_STAIRS;
default -> null;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ private void addDecorative() {
}
this.dropSelf(TinkerCommons.soulGlass.get());
this.dropSelf(TinkerCommons.soulGlassPane.get());

this.registerBuildingLootTables(TinkerCommons.mudBricks);
}

private void addTools() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private void addFluids() {

private void addHarvest() {
// commons
tagBlocks(MINEABLE_WITH_SHOVEL, TinkerCommons.mudBricks, TinkerCommons.cheeseBlock);
tagBlocks(MINEABLE_WITH_SHOVEL, TinkerCommons.cheeseBlock);
tagBlocks(MINEABLE_WITH_AXE, TinkerGadgets.punji);
tagBlocks(MINEABLE_WITH_PICKAXE, NEEDS_DIAMOND_TOOL, TinkerCommons.obsidianPane);
tagBlocks(MINEABLE_WITH_PICKAXE, NEEDS_STONE_TOOL, TinkerCommons.ironPlatform);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package slimeknights.tconstruct.library.recipe.ingredient;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntComparators;
import it.unimi.dsi.fastutil.ints.IntList;
import lombok.RequiredArgsConstructor;
import net.minecraft.core.Registry;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.common.crafting.AbstractIngredient;
import net.minecraftforge.common.crafting.IIngredientSerializer;
import slimeknights.mantle.data.loadable.Loadables;
import slimeknights.mantle.util.RegistryHelper;
import slimeknights.tconstruct.TConstruct;

import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/** Item ingredient matching items with a block form in the given tag */
@RequiredArgsConstructor
public class BlockTagIngredient extends AbstractIngredient {
private final TagKey<Block> tag;
@Nullable
private Set<Item> matchingItems;
@Nullable
private ItemStack[] items;
@Nullable
private IntList stackingIds;

@Override
public boolean test(@Nullable ItemStack stack) {
return stack != null && getMatchingItems().contains(stack.getItem());
}

@Override
public boolean isSimple() {
return true;
}

@Override
protected void invalidate() {
this.matchingItems = null;
this.items = null;
this.stackingIds = null;
}

/** Gets the ordered matching items set */
private Set<Item> getMatchingItems() {
if (matchingItems == null || checkInvalidation()) {
markValid();
matchingItems = RegistryHelper.getTagValueStream(Registry.BLOCK, tag)
.map(Block::asItem)
.filter(item -> item != Items.AIR)
.collect(Collectors.toCollection(LinkedHashSet::new));
}
return matchingItems;
}

@Override
public ItemStack[] getItems() {
if (items == null || checkInvalidation()) {
markValid();
items = getMatchingItems().stream().map(ItemStack::new).toArray(ItemStack[]::new);
}
return items;
}

@Override
public IntList getStackingIds() {
if (stackingIds == null || checkInvalidation()) {
markValid();
Set<Item> items = getMatchingItems();
stackingIds = new IntArrayList(items.size());
for (Item item : items) {
stackingIds.add(Registry.ITEM.getId(item));
}
stackingIds.sort(IntComparators.NATURAL_COMPARATOR);
}
return stackingIds;
}

@Override
public IIngredientSerializer<? extends Ingredient> getSerializer() {
return Serializer.INSTANCE;
}

@Override
public JsonElement toJson() {
JsonObject json = new JsonObject();
json.addProperty("type", Serializer.ID.toString());
json.add("tag", Loadables.BLOCK_TAG.serialize(tag));
return json;
}

/** Serializer instance */
public enum Serializer implements IIngredientSerializer<Ingredient> {
INSTANCE;

public static final ResourceLocation ID = TConstruct.getResource("block_tag");

@Override
public Ingredient parse(JsonObject json) {
return new BlockTagIngredient(Loadables.BLOCK_TAG.getIfPresent(json, "tag"));
}

@Override
public void write(FriendlyByteBuf buffer, Ingredient ingredient) {
// just write the item list, will become a vanilla ingredient client side
buffer.writeCollection(Arrays.asList(ingredient.getItems()), FriendlyByteBuf::writeItem);
}

@Override
public Ingredient parse(FriendlyByteBuf buffer) {
int size = buffer.readVarInt();
return Ingredient.fromValues(Stream.generate(() -> new Ingredient.ItemValue(buffer.readItem())).limit(size));
}
}
}

0 comments on commit 1bd76e9

Please sign in to comment.