mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
44 lines
1.1 KiB
Java
44 lines
1.1 KiB
Java
package vazkii.botania.common.crafting;
|
|
|
|
import com.google.gson.JsonObject;
|
|
import net.minecraft.block.BlockState;
|
|
import net.minecraft.network.PacketBuffer;
|
|
import net.minecraftforge.registries.ForgeRegistries;
|
|
import vazkii.botania.api.recipe.StateIngredient;
|
|
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
public class StateIngredientBlock implements StateIngredient {
|
|
private final net.minecraft.block.Block block;
|
|
|
|
public StateIngredientBlock(net.minecraft.block.Block block) {
|
|
this.block = block;
|
|
}
|
|
|
|
@Override
|
|
public boolean test(BlockState blockState) {
|
|
return block == blockState.getBlock();
|
|
}
|
|
|
|
@Override
|
|
public JsonObject serialize() {
|
|
JsonObject object = new JsonObject();
|
|
object.addProperty("type", "block");
|
|
object.addProperty("block", block.getRegistryName().toString());
|
|
return object;
|
|
}
|
|
|
|
@Override
|
|
public void write(PacketBuffer buffer) {
|
|
buffer.writeVarInt(1);
|
|
buffer.writeRegistryIdUnsafe(ForgeRegistries.BLOCKS, block);
|
|
}
|
|
|
|
@Override
|
|
public List<BlockState> getDisplayed() {
|
|
return Collections.singletonList(block.getDefaultState());
|
|
}
|
|
|
|
}
|