Merge branch 'mc1.20.1/feature-dev' into mc1.21.1/dev

# Conflicts:
#	build.gradle
#	gradle.properties
#	src/generated/resources/.cache/3055aa55530438925fbff1670d3e8dc6cc209bf3
#	src/generated/resources/data/create/recipe/milling/cactus.json
#	src/generated/resources/data/create/tags/block/sugar_cane_variants.json
#	src/generated/resources/data/minecraft/tags/block/combination_step_sound_blocks.json
#	src/generated/resources/data/minecraft/tags/block/inside_step_sound_blocks.json
#	src/main/java/com/simibubi/create/AllBlocks.java
#	src/main/java/com/simibubi/create/api/equipment/goggles/IHaveGoggleInformation.java
#	src/main/java/com/simibubi/create/compat/Mods.java
#	src/main/java/com/simibubi/create/compat/jei/CreateJEI.java
#	src/main/java/com/simibubi/create/compat/jei/category/BasinCategory.java
#	src/main/java/com/simibubi/create/compat/jei/category/CreateRecipeCategory.java
#	src/main/java/com/simibubi/create/compat/jei/category/ItemDrainCategory.java
#	src/main/java/com/simibubi/create/compat/jei/category/SpoutCategory.java
#	src/main/java/com/simibubi/create/compat/jei/category/sequencedAssembly/SequencedAssemblySubCategory.java
#	src/main/java/com/simibubi/create/content/equipment/armor/BacktankBlock.java
#	src/main/java/com/simibubi/create/content/equipment/armor/BacktankBlockEntity.java
#	src/main/java/com/simibubi/create/content/equipment/goggles/GoggleOverlayRenderer.java
#	src/main/java/com/simibubi/create/content/equipment/tool/CardboardSwordItem.java
#	src/main/java/com/simibubi/create/content/equipment/toolbox/ToolboxBlock.java
#	src/main/java/com/simibubi/create/content/fluids/drain/ItemDrainBlockEntity.java
#	src/main/java/com/simibubi/create/content/fluids/potion/PotionFluid.java
#	src/main/java/com/simibubi/create/content/fluids/potion/PotionFluidHandler.java
#	src/main/java/com/simibubi/create/content/fluids/spout/SpoutBlockEntity.java
#	src/main/java/com/simibubi/create/content/fluids/tank/FluidTankBlockEntity.java
#	src/main/java/com/simibubi/create/content/kinetics/base/KineticBlockEntity.java
#	src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerBlockEntity.java
#	src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerHandler.java
#	src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java
#	src/main/java/com/simibubi/create/content/kinetics/steamEngine/SteamEngineBlockEntity.java
#	src/main/java/com/simibubi/create/content/kinetics/waterwheel/WaterWheelStructuralBlock.java
#	src/main/java/com/simibubi/create/content/logistics/chute/ChuteBlockEntity.java
#	src/main/java/com/simibubi/create/content/logistics/filter/FilterItemStack.java
#	src/main/java/com/simibubi/create/content/logistics/funnel/FunnelBlockEntity.java
#	src/main/java/com/simibubi/create/content/logistics/packagePort/frogport/FrogportBlockEntity.java
#	src/main/java/com/simibubi/create/content/logistics/stockTicker/StockTickerBlockEntity.java
#	src/main/java/com/simibubi/create/content/logistics/tunnel/BrassTunnelBlockEntity.java
#	src/main/java/com/simibubi/create/content/logistics/vault/ItemVaultBlock.java
#	src/main/java/com/simibubi/create/content/processing/basin/BasinBlockEntity.java
#	src/main/java/com/simibubi/create/content/processing/burner/BlockBasedTrainConductorInteractionBehaviour.java
#	src/main/java/com/simibubi/create/content/redstone/link/controller/LecternControllerBlockEntity.java
#	src/main/java/com/simibubi/create/content/trains/track/AllPortalTracks.java
#	src/main/java/com/simibubi/create/foundation/data/CreateRegistrate.java
#	src/main/java/com/simibubi/create/foundation/item/ItemHelper.java
#	src/main/java/com/simibubi/create/foundation/utility/DyeHelper.java
#	src/main/java/com/simibubi/create/infrastructure/debugInfo/ServerDebugInfoPacket.java
#	src/main/resources/META-INF/mods.toml
This commit is contained in:
IThundxr 2025-01-28 11:56:14 -05:00
commit 667a252f4e
Failed to generate hash of commit
95 changed files with 3102 additions and 2736 deletions

View file

@ -114,9 +114,8 @@ configurations {
}
repositories {
maven { url = "https://maven.createmod.net" } // Ponder
maven { url = "https://maven.tterrag.com" } // Flywheel
maven { url = "https://maven.ithundxr.dev/snapshots" } // Registrate
maven { url = "https://maven.createmod.net" } // Ponder, Flywheel
maven { url = "https://mvn.devos.one/snapshots" } // Registrate
maven { url = "https://maven.blamejared.com" } // JEI, Vazkii's Mods
maven { url = "https://harleyoconnor.com/maven" } // Dynamic Trees
maven { url = "https://maven.theillusivec4.top/" } // Curios API
@ -132,16 +131,20 @@ repositories {
includeGroup "mysticdrew"
}
}
// todo - temp
maven { url = "https://maven.ithundxr.dev/hidden" } // Flywheel 1.21 PR
}
dependencies {
jarJar(implementation("com.tterrag.registrate:Registrate:${registrate_version}"))
compileOnly("dev.engine_room.flywheel:flywheel-neoforge-api-${flywheel_minecraft_version}:${flywheel_version}")
jarJar(runtimeOnly("dev.engine_room.flywheel:flywheel-neoforge-${flywheel_minecraft_version}:${flywheel_version}"))
jarJar("dev.engine-room.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") {
version {
strictly "[1.0,2.0)"
}
}
compileOnly("dev.engine-room.flywheel:flywheel-neoforge-api-${flywheel_minecraft_version}:${flywheel_version}")
runtimeOnly("dev.engine-room.flywheel:flywheel-neoforge-${flywheel_minecraft_version}:${flywheel_version}")
runtimeOnly("dev.engine-room.vanillin:vanillin-neoforge-${flywheel_minecraft_version}:${flywheel_version}")
if (ponderInWorkspace) {
implementation(project(":ponder:Common"))

View file

@ -23,17 +23,15 @@ parchment_version = 2024.11.17
# From maven.ithundxr.dev/snapshots
registrate_version = MC1.21-1.3.0+61
# From maven.ithundxr.dev/hidden
flywheel_minecraft_version = 1.21.1
flywheel_version = 1.0.0-beta-fork.16
flywheel_version_range = [1.0.0-alpha,2.0)
# Dependency Versions
jei_minecraft_version = 1.21
jei_version = 19.5.0.33
flywheel_minecraft_version = 1.21.1
flywheel_version = 1.0.0-beta-1
flywheel_version_range = [1.0.0-alpha,2.0)
ponder_version = 1.0.26
jei_minecraft_version = 1.21.1
jei_version = 19.21.0.247
curios_minecraft_version = 1.21.1
curios_version = 9.2.2
ponder_version = 1.0.24
cc_tweaked_enable = true
cc_tweaked_minecraft_version = 1.21.1

View file

@ -1,13 +1,4 @@
{
"neoforge:conditions": [
{
"type": "neoforge:not",
"value": {
"type": "neoforge:mod_loaded",
"modid": "quark"
}
}
],
"type": "create:milling",
"ingredients": [
{

View file

@ -7,6 +7,12 @@
},
{
"item": "minecraft:dirt"
},
{
"item": "minecraft:coarse_dirt"
},
{
"item": "minecraft:rooted_dirt"
}
]
],

View file

@ -0,0 +1,5 @@
{
"values": [
"minecraft:sugar_cane"
]
}

View file

@ -0,0 +1,20 @@
{
"values": [
"create:white_table_cloth",
"create:orange_table_cloth",
"create:magenta_table_cloth",
"create:light_blue_table_cloth",
"create:yellow_table_cloth",
"create:lime_table_cloth",
"create:pink_table_cloth",
"create:gray_table_cloth",
"create:light_gray_table_cloth",
"create:cyan_table_cloth",
"create:purple_table_cloth",
"create:blue_table_cloth",
"create:brown_table_cloth",
"create:green_table_cloth",
"create:red_table_cloth",
"create:black_table_cloth"
]
}

View file

@ -0,0 +1,7 @@
{
"values": [
"create:andesite_table_cloth",
"create:brass_table_cloth",
"create:copper_table_cloth"
]
}

View file

@ -1,5 +1,21 @@
{
"values": [
"create:copper_shingle_slab",
"create:exposed_copper_shingle_slab",
"create:weathered_copper_shingle_slab",
"create:oxidized_copper_shingle_slab",
"create:waxed_copper_shingle_slab",
"create:waxed_exposed_copper_shingle_slab",
"create:waxed_weathered_copper_shingle_slab",
"create:waxed_oxidized_copper_shingle_slab",
"create:copper_tile_slab",
"create:exposed_copper_tile_slab",
"create:weathered_copper_tile_slab",
"create:oxidized_copper_tile_slab",
"create:waxed_copper_tile_slab",
"create:waxed_exposed_copper_tile_slab",
"create:waxed_weathered_copper_tile_slab",
"create:waxed_oxidized_copper_tile_slab",
"create:cut_granite_slab",
"create:polished_cut_granite_slab",
"create:cut_granite_brick_slab",

View file

@ -1,5 +1,21 @@
{
"values": [
"create:copper_shingle_stairs",
"create:exposed_copper_shingle_stairs",
"create:weathered_copper_shingle_stairs",
"create:oxidized_copper_shingle_stairs",
"create:waxed_copper_shingle_stairs",
"create:waxed_exposed_copper_shingle_stairs",
"create:waxed_weathered_copper_shingle_stairs",
"create:waxed_oxidized_copper_shingle_stairs",
"create:copper_tile_stairs",
"create:exposed_copper_tile_stairs",
"create:weathered_copper_tile_stairs",
"create:oxidized_copper_tile_stairs",
"create:waxed_copper_tile_stairs",
"create:waxed_exposed_copper_tile_stairs",
"create:waxed_weathered_copper_tile_stairs",
"create:waxed_oxidized_copper_tile_stairs",
"create:cut_granite_stairs",
"create:polished_cut_granite_stairs",
"create:cut_granite_brick_stairs",

View file

@ -17,6 +17,7 @@ import static com.simibubi.create.foundation.data.TagGen.tagBlockAndItem;
import com.simibubi.create.AllTags.AllBlockTags;
import com.simibubi.create.AllTags.AllItemTags;
import com.simibubi.create.api.contraption.train.TrainConductorHandler;
import com.simibubi.create.content.contraptions.actors.contraptionControls.ContraptionControlsBlock;
import com.simibubi.create.content.contraptions.actors.contraptionControls.ContraptionControlsMovement;
import com.simibubi.create.content.contraptions.actors.contraptionControls.ContraptionControlsMovingInteraction;
@ -209,7 +210,6 @@ import com.simibubi.create.content.processing.basin.BasinGenerator;
import com.simibubi.create.content.processing.basin.BasinMovementBehaviour;
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
import com.simibubi.create.content.processing.burner.BlazeBurnerBlockItem;
import com.simibubi.create.content.processing.burner.BlazeBurnerInteractionBehaviour;
import com.simibubi.create.content.processing.burner.BlazeBurnerMovementBehaviour;
import com.simibubi.create.content.processing.burner.LitBlazeBurnerBlock;
import com.simibubi.create.content.redstone.RoseQuartzLampBlock;
@ -362,7 +362,7 @@ public class AllBlocks {
.when(survivesExplosion)
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(AllBlocks.SCHEMATICANNON.get()
.asItem())
.asItem())
.apply(CopyComponentsFunction.copyComponents(CopyComponentsFunction.Source.BLOCK_ENTITY)
.include(AllDataComponents.SCHEMATICANNON_OPTIONS)))));
})
@ -772,7 +772,7 @@ public class AllBlocks {
.loot((lt, block) -> lt.add(block, BlazeBurnerBlock.buildLootTable()))
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
.onRegister(movementBehaviour(new BlazeBurnerMovementBehaviour()))
.onRegister(interactionBehaviour(new BlazeBurnerInteractionBehaviour()))
.onRegister(block -> TrainConductorHandler.registerBlazeBurner())
.item(BlazeBurnerBlockItem::withBlaze)
.model(AssetLookup.customBlockItemModel("blaze_burner", "block_with_blaze"))
.build()
@ -793,8 +793,8 @@ public class AllBlocks {
.modelFile(p.models()
.getExistingFile(p.modLoc("block/blaze_burner/"
+ (state.getValue(LitBlazeBurnerBlock.FLAME_TYPE) == LitBlazeBurnerBlock.FlameType.SOUL
? "block_with_soul_fire"
: "block_with_fire"))))
? "block_with_soul_fire"
: "block_with_fire"))))
.build()))
.register();
@ -2702,10 +2702,10 @@ public class AllBlocks {
public static final CopperBlockSet COPPER_SHINGLES = new CopperBlockSet(REGISTRATE, "copper_shingles",
"copper_roof_top", CopperBlockSet.DEFAULT_VARIANTS, (c, p) -> {
p.stonecutting(DataIngredient.tag(Tags.Items.INGOTS_COPPER), RecipeCategory.BUILDING_BLOCKS,
c::get, 2);
}, (ws, block) -> connectedTextures(() -> new RoofBlockCTBehaviour(AllSpriteShifts.COPPER_SHINGLES.get(ws)))
.accept(block));
p.stonecutting(DataIngredient.tag(Tags.Items.INGOTS_COPPER), RecipeCategory.BUILDING_BLOCKS,
c::get, 2);
}, (ws, block) -> connectedTextures(() -> new RoofBlockCTBehaviour(AllSpriteShifts.COPPER_SHINGLES.get(ws)))
.accept(block));
public static final CopperBlockSet COPPER_TILES =
new CopperBlockSet(REGISTRATE, "copper_tiles", "copper_roof_top", CopperBlockSet.DEFAULT_VARIANTS, (c, p) -> {
@ -2716,6 +2716,7 @@ public class AllBlocks {
// Load this class
public static void register() {}
public static void register() {
}
}

View file

@ -7,13 +7,14 @@ import java.util.function.Supplier;
import javax.annotation.Nullable;
import com.simibubi.create.content.fluids.VirtualFluid;
import org.jetbrains.annotations.NotNull;
import org.joml.Vector3f;
import com.mojang.blaze3d.shaders.FogShape;
import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.content.decoration.palettes.AllPaletteStoneTypes;
import com.simibubi.create.content.fluids.VirtualFluid;
import com.simibubi.create.content.fluids.potion.PotionFluid;
import com.simibubi.create.content.fluids.potion.PotionFluid.PotionFluidType;
import com.simibubi.create.infrastructure.config.AllConfigs;
@ -46,7 +47,7 @@ public class AllFluids {
}
public static final FluidEntry<PotionFluid> POTION =
REGISTRATE.virtualFluid("potion", PotionFluidType::new, PotionFluid::new)
REGISTRATE.virtualFluid("potion", PotionFluidType::new, PotionFluid::createSource, PotionFluid::createFlowing)
.lang("Potion")
.register();

View file

@ -105,6 +105,7 @@ public class AllTags {
SIMPLE_MOUNTED_STORAGE,
FALLBACK_MOUNTED_STORAGE_BLACKLIST,
ROOTS,
SUGAR_CANE_VARIANTS,
CORALS,

View file

@ -0,0 +1,54 @@
package com.simibubi.create.api.contraption.train;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllInteractionBehaviours;
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
import com.simibubi.create.content.processing.burner.BlockBasedTrainConductorInteractionBehaviour;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.ApiStatus;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;
/**
* All required methods to make your block a train conductor similar to the blaze burner
*/
public interface TrainConductorHandler {
@ApiStatus.Internal
List<TrainConductorHandler> CONDUCTOR_HANDLERS = new ArrayList<>();
boolean isValidConductor(BlockState state);
private static void registerHandler(TrainConductorHandler handler) {
CONDUCTOR_HANDLERS.add(handler);
}
static void registerConductor(ResourceLocation blockRl, Predicate<BlockState> isValidConductor, UpdateScheduleCallback updateScheduleCallback) {
AllInteractionBehaviours.registerBehaviour(blockRl, new BlockBasedTrainConductorInteractionBehaviour(isValidConductor, updateScheduleCallback));
registerHandler(isValidConductor::test);
}
@ApiStatus.Internal
static void registerBlazeBurner() {
registerConductor(AllBlocks.BLAZE_BURNER.getId(), blockState -> AllBlocks.BLAZE_BURNER.has(blockState)
&& blockState.getValue(BlazeBurnerBlock.HEAT_LEVEL) != BlazeBurnerBlock.HeatLevel.NONE, UpdateScheduleCallback.EMPTY);
}
interface UpdateScheduleCallback {
UpdateScheduleCallback EMPTY = (hasSchedule, blockState, blockStateSetter) -> {};
void update(boolean hasSchedule, BlockState currentBlockState, Consumer<BlockState> blockStateSetter);
}
}

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.equipment.goggles;
package com.simibubi.create.api.equipment.goggles;
import com.simibubi.create.AllItems;
@ -7,8 +7,9 @@ import net.minecraft.world.level.block.entity.BlockEntity;
public sealed interface IHaveCustomOverlayIcon permits IHaveGoggleInformation, IHaveHoveringInformation {
/**
* This method will be called when looking at a {@link BlockEntity} that implements this interface
* <p>
* This method will be called when looking at a {@link BlockEntity} that implements {@link IHaveGoggleInformation}
* or {@link IHaveHoveringInformation}
*
* @return The {@link ItemStack} you want the overlay to show instead of the goggles
*/
default ItemStack getIcon(boolean isPlayerSneaking) {

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.equipment.goggles;
package com.simibubi.create.api.equipment.goggles;
import java.util.List;
import java.util.Optional;
@ -9,6 +9,7 @@ import net.createmod.catnip.lang.LangBuilder;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
@ -20,14 +21,14 @@ public non-sealed interface IHaveGoggleInformation extends IHaveCustomOverlayIco
* This method will be called when looking at a {@link BlockEntity} that implements this interface
*
* @return {@code true} if the tooltip creation was successful and should be
* displayed, or {@code false} if the overlay should not be displayed
* displayed, or {@code false} if the overlay should not be displayed
*/
default boolean addToGoggleTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
return false;
}
default boolean containedFluidTooltip(List<Component> tooltip, boolean isPlayerSneaking,
IFluidHandler handler) {
IFluidHandler handler) {
if (handler == null)
return false;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.equipment.goggles;
package com.simibubi.create.api.equipment.goggles;
import java.util.List;
@ -6,14 +6,14 @@ import net.minecraft.network.chat.Component;
import net.minecraft.world.level.block.entity.BlockEntity;
/**
* Implement this interface on the {@link BlockEntity} that wants to add info to the goggle overlay
* Implement this interface on the {@link BlockEntity} that wants to add info to the hovering overlay
*/
public non-sealed interface IHaveHoveringInformation extends IHaveCustomOverlayIcon{
public non-sealed interface IHaveHoveringInformation extends IHaveCustomOverlayIcon {
/**
* This method will be called when looking at a {@link BlockEntity} that implements this interface
*
* @return {@code true} if the tooltip creation was successful and should be
* displayed, or {@code false} if the overlay should not be displayed
* displayed, or {@code false} if the overlay should not be displayed
*/
default boolean addToTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
return false;

View file

@ -1,4 +1,4 @@
package com.simibubi.create.content.equipment.goggles;
package com.simibubi.create.api.equipment.goggles;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
@ -6,7 +6,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
/**
* Implement this interface on the {@link BlockEntity} that wants to add info to the goggle overlay
* Implement this interface on the {@link BlockEntity} that wants proxy the information
*/
public interface IProxyHoveringInformation {
BlockPos getInformationSource(Level level, BlockPos pos, BlockState state);

View file

@ -19,6 +19,7 @@ import net.neoforged.fml.ModList;
public enum Mods {
AETHER,
AETHER_II,
BETTEREND,
COMPUTERCRAFT,
CONNECTIVITY,
CURIOS,

View file

@ -36,6 +36,7 @@ public class DisplayLinkPeripheral extends SyncedPeripheral<DisplayLinkBlockEnti
@LuaFunction(mainThread = true)
public final Object[] getSize() {
blockEntity.updateGatheredData();
DisplayTargetStats stats = blockEntity.activeTarget.provideStats(new DisplayLinkContext(blockEntity.getLevel(), blockEntity));
return new Object[]{stats.maxRows(), stats.maxColumns()};
}

View file

@ -55,7 +55,6 @@ import com.simibubi.create.content.kinetics.fan.processing.SplashingRecipe;
import com.simibubi.create.content.kinetics.press.MechanicalPressBlockEntity;
import com.simibubi.create.content.kinetics.press.PressingRecipe;
import com.simibubi.create.content.kinetics.saw.CuttingRecipe;
import com.simibubi.create.content.kinetics.saw.SawBlockEntity;
import com.simibubi.create.content.logistics.filter.AbstractFilterScreen;
import com.simibubi.create.content.logistics.redstoneRequester.RedstoneRequesterScreen;
import com.simibubi.create.content.processing.basin.BasinRecipe;
@ -78,6 +77,7 @@ import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.helpers.IPlatformFluidHelper;
import mezz.jei.api.neoforge.NeoForgeTypes;
import mezz.jei.api.recipe.category.IRecipeCategory;
import mezz.jei.api.registration.IExtraIngredientRegistration;
import mezz.jei.api.registration.IGuiHandlerRegistration;
import mezz.jei.api.registration.IRecipeCatalystRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
@ -87,10 +87,14 @@ import mezz.jei.api.registration.ISubtypeRegistration;
import mezz.jei.api.runtime.IIngredientManager;
import net.createmod.catnip.config.ConfigBase.ConfigBool;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Holder.Reference;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.alchemy.PotionContents;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
import net.minecraft.world.item.crafting.CraftingRecipe;
import net.minecraft.world.item.crafting.Recipe;
@ -101,7 +105,8 @@ import net.minecraft.world.item.crafting.ShapedRecipe;
import net.minecraft.world.item.crafting.SmokingRecipe;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Blocks;
import net.neoforged.fml.ModList;
import net.neoforged.neoforge.fluids.FluidStack;
@JeiPlugin
@SuppressWarnings("unused")
@ -358,6 +363,25 @@ public class CreateJEI implements IModPlugin {
registration.registerSubtypeInterpreter(NeoForgeTypes.FLUID_STACK, potionFluid.getFlowing(), interpreter);
}
@Override
public void registerExtraIngredients(IExtraIngredientRegistration registration) {
RegistryAccess registryAccess = Minecraft.getInstance().level.registryAccess();
List<Reference<Potion>> potions = registryAccess.lookupOrThrow(Registries.POTION)
.listElements()
.toList();
Collection<FluidStack> potionFluids = new ArrayList<>(potions.size() * 3);
for (Reference<Potion> potion : potions) {
// @goshante: Ingame potion fluids always have Bottle tag that specifies
// to what bottle type this potion belongs
// Potion fluid without this tag wouldn't be recognized by other mods
for (PotionFluid.BottleType bottleType : PotionFluid.BottleType.values()) {
FluidStack potionFluid = PotionFluid.of(1000, new PotionContents(potion), bottleType);
potionFluids.add(potionFluid);
}
}
registration.addExtraIngredients(NeoForgeTypes.FLUID_STACK, potionFluids);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void registerGuiHandlers(IGuiHandlerRegistration registration) {

View file

@ -2,22 +2,25 @@ package com.simibubi.create.compat.jei;
import java.util.List;
import org.jetbrains.annotations.Nullable;
import com.simibubi.create.AllDataComponents;
import com.simibubi.create.content.fluids.potion.PotionFluid.BottleType;
import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter;
import mezz.jei.api.ingredients.subtypes.ISubtypeInterpreter;
import mezz.jei.api.ingredients.subtypes.UidContext;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.item.alchemy.PotionContents;
import net.neoforged.neoforge.fluids.FluidStack;
/* From JEI's Potion item subtype interpreter */
public class PotionFluidSubtypeInterpreter implements IIngredientSubtypeInterpreter<FluidStack> {
public class PotionFluidSubtypeInterpreter implements ISubtypeInterpreter<FluidStack> {
@Override
public String apply(FluidStack ingredient, UidContext context) {
public @Nullable Object getSubtypeData(FluidStack ingredient, UidContext context) {
if (ingredient.getComponentsPatch().isEmpty())
return IIngredientSubtypeInterpreter.NONE;
return null;
PotionContents contents = ingredient.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY);
String potionTypeString = ingredient.getDescriptionId();
@ -31,11 +34,16 @@ public class PotionFluidSubtypeInterpreter implements IIngredientSubtypeInterpre
contents.potion().ifPresent(p -> {
for (MobEffectInstance effect : p.value().getEffects())
stringBuilder.append(";")
.append(effect);
.append(effect);
});
for (MobEffectInstance effect : effects)
stringBuilder.append(";")
.append(effect);
return stringBuilder.toString();
}
@Override
public String getLegacyStringSubtypeInfo(FluidStack ingredient, UidContext context) {
return "";
}
}

View file

@ -23,9 +23,8 @@ import com.simibubi.create.foundation.utility.CreateLang;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import mezz.jei.api.recipe.transfer.IUniversalRecipeTransferHandler;
import mezz.jei.common.transfer.RecipeTransferOperationsResult;
import mezz.jei.common.transfer.RecipeTransferUtil;
import mezz.jei.library.transfer.RecipeTransferErrorMissingSlots;
@ -45,8 +44,7 @@ import net.neoforged.neoforge.items.ItemStackHandler;
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class StockKeeperTransferHandler implements IRecipeTransferHandler<StockKeeperRequestMenu, Object> {
public class StockKeeperTransferHandler implements IUniversalRecipeTransferHandler<StockKeeperRequestMenu> {
private IJeiHelpers helpers;
public StockKeeperTransferHandler(IJeiHelpers helpers) {
@ -63,11 +61,6 @@ public class StockKeeperTransferHandler implements IRecipeTransferHandler<StockK
return Optional.of(AllMenuTypes.STOCK_KEEPER_REQUEST.get());
}
@Override
public RecipeType<Object> getRecipeType() {
return null;
}
@Override
public @Nullable IRecipeTransferError transferRecipe(StockKeeperRequestMenu container, Object object,
IRecipeSlotsView recipeSlots, Player player, boolean maxTransfer, boolean doTransfer) {
@ -137,5 +130,4 @@ public class StockKeeperTransferHandler implements IRecipeTransferHandler<StockK
return null;
}
}

View file

@ -68,7 +68,7 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
.addSlot(RecipeIngredientRole.INPUT, 17 + xOffset + (i % 3) * 19, 51 - (i / 3) * 19)
.setBackground(getRenderedSlot(), -1, -1)
.addIngredients(NeoForgeTypes.FLUID_STACK, withImprovedVisibility(fluidIngredient.getMatchingFluidStacks()))
.addTooltipCallback(addFluidTooltip(fluidIngredient.getRequiredAmount()));
.addRichTooltipCallback(addFluidTooltip(fluidIngredient.getRequiredAmount()));
i++;
}
@ -83,7 +83,7 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
.addSlot(RecipeIngredientRole.OUTPUT, xPosition, yPosition)
.setBackground(getRenderedSlot(result), -1, -1)
.addItemStack(result.getStack())
.addTooltipCallback(addStochasticTooltip(result));
.addRichTooltipCallback(addStochasticTooltip(result));
i++;
}
@ -95,7 +95,7 @@ public class BasinCategory extends CreateRecipeCategory<BasinRecipe> {
.addSlot(RecipeIngredientRole.OUTPUT, xPosition, yPosition)
.setBackground(getRenderedSlot(), -1, -1)
.addIngredient(NeoForgeTypes.FLUID_STACK, withImprovedVisibility(fluidResult))
.addTooltipCallback(addFluidTooltip(fluidResult.getAmount()));
.addRichTooltipCallback(addFluidTooltip(fluidResult.getAmount()));
i++;
}

View file

@ -8,7 +8,6 @@ import java.util.stream.Collectors;
import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.network.chat.MutableComponent;
import org.jetbrains.annotations.NotNull;
import com.simibubi.create.AllFluids;
@ -18,7 +17,7 @@ import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.utility.CreateLang;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IRecipeSlotTooltipCallback;
import mezz.jei.api.gui.ingredient.IRecipeSlotRichTooltipCallback;
import mezz.jei.api.neoforge.NeoForgeTypes;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.category.IRecipeCategory;
@ -110,11 +109,11 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
return recipe.getResultItem(level.registryAccess());
}
public static IRecipeSlotTooltipCallback addStochasticTooltip(ProcessingOutput output) {
public static IRecipeSlotRichTooltipCallback addStochasticTooltip(ProcessingOutput output) {
return (view, tooltip) -> {
float chance = output.getChance();
if (chance != 1)
tooltip.add(1, CreateLang.translateDirect("recipe.processing.chance", chance < 0.01 ? "<1" : (int) (chance * 100))
tooltip.add(CreateLang.translateDirect("recipe.processing.chance", chance < 0.01 ? "<1" : (int) (chance * 100))
.withStyle(ChatFormatting.GOLD));
};
}
@ -132,11 +131,11 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
return display;
}
public static IRecipeSlotTooltipCallback addFluidTooltip() {
public static IRecipeSlotRichTooltipCallback addFluidTooltip() {
return addFluidTooltip(-1);
}
public static IRecipeSlotTooltipCallback addFluidTooltip(int mbAmount) {
public static IRecipeSlotRichTooltipCallback addFluidTooltip(int mbAmount) {
return (view, tooltip) -> {
Optional<FluidStack> displayed = view.getDisplayedIngredient(NeoForgeTypes.FLUID_STACK);
if (displayed.isEmpty())
@ -145,26 +144,14 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
FluidStack fluidStack = displayed.get();
if (fluidStack.getFluid().isSame(AllFluids.POTION.get())) {
Component name = fluidStack.getHoverName();
if (tooltip.isEmpty())
tooltip.add(0, name);
else
tooltip.set(0, name);
ArrayList<Component> potionTooltip = new ArrayList<>();
PotionFluidHandler.addPotionTooltip(fluidStack, potionTooltip, 1);
tooltip.addAll(1, potionTooltip.stream().toList());
tooltip.addAll(potionTooltip.stream().toList());
}
int amount = mbAmount == -1 ? fluidStack.getAmount() : mbAmount;
Component text = Component.literal(String.valueOf(amount)).append(CreateLang.translateDirect("generic.unit.millibuckets")).withStyle(ChatFormatting.GOLD);
if (tooltip.isEmpty())
tooltip.add(0, text);
else {
List<Component> siblings = tooltip.get(0).getSiblings();
siblings.add(Component.literal(" "));
siblings.add(text);
}
Component text = Component.literal(String.valueOf(amount)).append(CreateLang.translateDirect("generic.unit.millibuckets")).withStyle(ChatFormatting.GOLD);
tooltip.add(text);
};
}
@ -187,7 +174,9 @@ public abstract class CreateRecipeCategory<T extends Recipe<?>> implements IReci
};
}
public record Info<T extends Recipe<?>>(RecipeType<T> recipeType, Component title, IDrawable background, IDrawable icon, Supplier<List<RecipeHolder<T>>> recipes, List<Supplier<? extends ItemStack>> catalysts) {
public record Info<T extends Recipe<?>>(RecipeType<T> recipeType, Component title, IDrawable background,
IDrawable icon, Supplier<List<RecipeHolder<T>>> recipes,
List<Supplier<? extends ItemStack>> catalysts) {
}
public interface Factory<T extends Recipe<?>> {

View file

@ -41,7 +41,7 @@ public class CrushingCategory extends CreateRecipeCategory<AbstractCrushingRecip
.addSlot(RecipeIngredientRole.OUTPUT, (xOffset) + layoutEntry.posX() + 1, yOffset + layoutEntry.posY() + 1)
.setBackground(getRenderedSlot(layoutEntry.output()), -1, -1)
.addItemStack(layoutEntry.output().getStack())
.addTooltipCallback(addStochasticTooltip(layoutEntry.output()))
.addRichTooltipCallback(addStochasticTooltip(layoutEntry.output()))
);
}

View file

@ -45,7 +45,7 @@ public class DeployingCategory extends CreateRecipeCategory<DeployerApplicationR
builder.addSlot(RecipeIngredientRole.OUTPUT, single ? 132 : 132 + xOffset, 51 + yOffset)
.setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output));
.addRichTooltipCallback(addStochasticTooltip(output));
}
if (recipe.shouldKeepHeldItem())

View file

@ -56,7 +56,7 @@ public class ItemApplicationCategory extends CreateRecipeCategory<ItemApplicatio
builder.addSlot(RecipeIngredientRole.OUTPUT, single ? 132 : 132 + xOffset, 38 + yOffset)
.setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output));
.addRichTooltipCallback(addStochasticTooltip(output));
}
}

View file

@ -11,6 +11,9 @@ import com.simibubi.create.content.fluids.transfer.EmptyingRecipe;
import com.simibubi.create.content.processing.recipe.ProcessingRecipeBuilder;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.item.ItemHelper;
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
@ -22,6 +25,7 @@ import net.createmod.catnip.registry.RegisteredObjectsHelper;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemStackLinkedSet;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeHolder;
@ -40,6 +44,7 @@ public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
}
public static void consumeRecipes(Consumer<RecipeHolder<EmptyingRecipe>> consumer, IIngredientManager ingredientManager) {
ObjectOpenCustomHashSet<ItemStack> emptiedItems = new ObjectOpenCustomHashSet<>(ItemStackLinkedSet.TYPE_AND_TAG);
for (ItemStack stack : ingredientManager.getAllIngredients(VanillaTypes.ITEM_STACK)) {
if (PotionFluidHandler.isPotionItem(stack)) {
FluidStack fluidFromPotionItem = PotionFluidHandler.getFluidFromPotionItem(stack);
@ -67,6 +72,11 @@ public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
if (result.isEmpty())
continue;
// There can be a lot of duplicate empty tanks (e.g. from emptying tanks with different fluids). Merge
// them to reduce memory usage. If the item is exactly the same as the input, just use the input stack
// instead of the copy.
result = ItemHelper.sameItem(stack, result) ? stack : emptiedItems.addOrGet(result);
Ingredient ingredient = Ingredient.of(stack);
ResourceLocation itemName = RegisteredObjectsHelper.getKeyOrThrow(stack.getItem());
ResourceLocation fluidName = RegisteredObjectsHelper.getKeyOrThrow(extracted.getFluid());
@ -92,7 +102,7 @@ public class ItemDrainCategory extends CreateRecipeCategory<EmptyingRecipe> {
.addSlot(RecipeIngredientRole.OUTPUT, 132, 8)
.setBackground(getRenderedSlot(), -1, -1)
.addIngredient(NeoForgeTypes.FLUID_STACK, withImprovedVisibility(recipe.getResultingFluid()))
.addTooltipCallback(addFluidTooltip(recipe.getResultingFluid().getAmount()));
.addRichTooltipCallback(addFluidTooltip(recipe.getResultingFluid().getAmount()));
builder
.addSlot(RecipeIngredientRole.OUTPUT, 132, 27)
.setBackground(getRenderedSlot(), -1, -1)

View file

@ -40,7 +40,7 @@ public class MillingCategory extends CreateRecipeCategory<AbstractCrushingRecipe
.addSlot(RecipeIngredientRole.OUTPUT, single ? 139 : 133 + xOffset, 27 + yOffset)
.setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output));
.addRichTooltipCallback(addStochasticTooltip(output));
i++;
}

View file

@ -40,7 +40,7 @@ public class PolishingCategory extends CreateRecipeCategory<SandPaperPolishingRe
.addSlot(RecipeIngredientRole.OUTPUT, 132, 29)
.setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output));
.addRichTooltipCallback(addStochasticTooltip(output));
}
@Override

View file

@ -35,7 +35,7 @@ public class PressingCategory extends CreateRecipeCategory<PressingRecipe> {
builder.addSlot(RecipeIngredientRole.OUTPUT, 131 + 19 * i, 50)
.setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output));
.addRichTooltipCallback(addStochasticTooltip(output));
i++;
}
}

View file

@ -117,7 +117,7 @@ public abstract class ProcessingViaFanCategory<T extends Recipe<?>> extends Crea
.addSlot(RecipeIngredientRole.OUTPUT, 141 + xOffset, 48 + yOffset)
.setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output));
.addRichTooltipCallback(addStochasticTooltip(output));
i++;
}
}

View file

@ -38,7 +38,7 @@ public class SawingCategory extends CreateRecipeCategory<CuttingRecipe> {
.addSlot(RecipeIngredientRole.OUTPUT, 118 + xOffset, 48 + yOffset)
.setBackground(getRenderedSlot(output), -1, -1)
.addItemStack(output.getStack())
.addTooltipCallback(addStochasticTooltip(output));
.addRichTooltipCallback(addStochasticTooltip(output));
i++;
}
}

View file

@ -29,7 +29,8 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.Capabilities.FluidHandler;
import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.fluids.capability.IFluidHandler.FluidAction;
import net.neoforged.neoforge.fluids.capability.IFluidHandlerItem;
@ -59,13 +60,21 @@ public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
continue;
}
IFluidHandlerItem capability = stack.getCapability(Capabilities.FluidHandler.ITEM);
IFluidHandlerItem capability = stack.getCapability(FluidHandler.ITEM);
if (capability == null)
continue;
int numTanks = capability.getTanks();
FluidStack existingFluid = numTanks == 1 ? capability.getFluidInTank(0) : FluidStack.EMPTY;
for (FluidStack fluidStack : fluidStacks) {
// Hoist the fluid equality check to avoid the work of copying the stack + populating capabilities
// when most fluids will not match
if (numTanks == 1 && (!existingFluid.isEmpty() && !FluidStack.isSameFluidSameComponents(existingFluid, fluidStack))) {
continue;
}
ItemStack copy = stack.copy();
IFluidHandlerItem fhi = copy.getCapability(Capabilities.FluidHandler.ITEM);
IFluidHandlerItem fhi = copy.getCapability(FluidHandler.ITEM);
if (fhi != null) {
if (!GenericItemFilling.isFluidHandlerValid(copy, fhi))
return;
@ -104,7 +113,7 @@ public class SpoutCategory extends CreateRecipeCategory<FillingRecipe> {
.addSlot(RecipeIngredientRole.INPUT, 27, 32)
.setBackground(getRenderedSlot(), -1, -1)
.addIngredients(NeoForgeTypes.FLUID_STACK, withImprovedVisibility(recipe.getRequiredFluid().getMatchingFluidStacks()))
.addTooltipCallback(addFluidTooltip(recipe.getRequiredFluid().getRequiredAmount()));
.addRichTooltipCallback(addFluidTooltip(recipe.getRequiredFluid().getRequiredAmount()));
builder
.addSlot(RecipeIngredientRole.OUTPUT, 132, 51)
.setBackground(getRenderedSlot(), -1, -1)

View file

@ -76,7 +76,7 @@ public abstract class SequencedAssemblySubCategory {
.addSlot(RecipeIngredientRole.INPUT, x + 4, 15)
.setBackground(CreateRecipeCategory.getRenderedSlot(), -1, -1)
.addIngredients(NeoForgeTypes.FLUID_STACK, CreateRecipeCategory.withImprovedVisibility(fluidIngredient.getMatchingFluidStacks()))
.addTooltipCallback(CreateRecipeCategory.addFluidTooltip(fluidIngredient.getRequiredAmount()));
.addRichTooltipCallback(CreateRecipeCategory.addFluidTooltip(fluidIngredient.getRequiredAmount()));
}
@Override

View file

@ -14,7 +14,6 @@ import org.apache.commons.lang3.mutable.MutableFloat;
import org.apache.commons.lang3.mutable.MutableObject;
import org.apache.commons.lang3.tuple.MutablePair;
import com.google.common.base.Predicates;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllMovementBehaviours;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity.ContraptionRotationState;
@ -159,8 +158,7 @@ public class ContraptionCollider {
List<AABB> bbs = new ArrayList<>();
List<VoxelShape> potentialHits =
getPotentiallyCollidedShapes(world, contraption, localBB.expandTowards(motionCopy));
potentialHits.forEach(shape -> shape.toAabbs()
.forEach(bbs::add));
potentialHits.forEach(shape -> bbs.addAll(shape.toAabbs()));
return bbs;
});
@ -663,19 +661,23 @@ public class ContraptionCollider {
BlockPos min = BlockPos.containing(blockScanBB.minX, blockScanBB.minY, blockScanBB.minZ);
BlockPos max = BlockPos.containing(blockScanBB.maxX, blockScanBB.maxY, blockScanBB.maxZ);
List<VoxelShape> potentialHits = BlockPos.betweenClosedStream(min, max)
.filter(contraption.getBlocks()::containsKey)
.filter(Predicates.not(contraption::isHiddenInPortal))
.map(p -> {
BlockState blockState = contraption.getBlocks()
.get(p).state();
BlockPos pos = contraption.getBlocks()
.get(p).pos();
VoxelShape collisionShape = blockState.getCollisionShape(world, p);
return collisionShape.move(pos.getX(), pos.getY(), pos.getZ());
})
.filter(Predicates.not(VoxelShape::isEmpty))
.toList();
List<VoxelShape> potentialHits = new ArrayList<>();
for (BlockPos p : BlockPos.betweenClosed(min, max)) {
if (contraption.blocks.containsKey(p) && !contraption.isHiddenInPortal(p)) {
StructureBlockInfo info = contraption.getBlocks().get(p);
BlockState blockState = info.state();
BlockPos pos = info.pos();
VoxelShape collisionShape = blockState.getCollisionShape(world, p)
.move(pos.getX(), pos.getY(), pos.getZ());
if (!collisionShape.isEmpty()) {
potentialHits.add(collisionShape);
}
}
}
return potentialHits;
}

View file

@ -109,7 +109,7 @@ public class ContraptionControlsBlockEntity extends SmartBlockEntity {
public static void sendStatus(Player player, ItemStack filter, boolean enabled) {
MutableComponent state = CreateLang.translate("contraption.controls.actor_toggle." + (enabled ? "on" : "off"))
.color(DyeHelper.DYE_TABLE.get(enabled ? DyeColor.LIME : DyeColor.ORANGE)
.color(DyeHelper.getDyeColors(enabled ? DyeColor.LIME : DyeColor.ORANGE)
.getFirst())
.component();

View file

@ -83,7 +83,7 @@ public class ContraptionControlsRenderer extends SmartBlockEntityRenderer<Contra
: ctx.position.distanceToSqr(cameraEntity.getEyePosition()));
float flicker = r.nextFloat();
Couple<Integer> couple = DyeHelper.DYE_TABLE.get(efs.targetYEqualsSelection ? DyeColor.WHITE : DyeColor.ORANGE);
Couple<Integer> couple = DyeHelper.getDyeColors(efs.targetYEqualsSelection ? DyeColor.WHITE : DyeColor.ORANGE);
int brightColor = couple.getFirst();
int darkColor = couple.getSecond();
int flickeringBrightColor = Color.mixColors(brightColor, darkColor, flicker / 4);

View file

@ -6,6 +6,7 @@ import net.neoforged.neoforge.common.SpecialPlantable;
import org.apache.commons.lang3.mutable.MutableBoolean;
import com.simibubi.create.AllTags;
import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour;
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
import com.simibubi.create.content.contraptions.render.ActorVisual;
@ -174,7 +175,7 @@ public class HarvesterMovementBehaviour implements MovementBehaviour {
if (block == Blocks.SWEET_BERRY_BUSH) {
return state.setValue(BlockStateProperties.AGE_3, Integer.valueOf(1));
}
if (block == Blocks.SUGAR_CANE || block instanceof GrowingPlantBlock) {
if (state.is(AllTags.AllBlockTags.SUGAR_CANE_VARIANTS.tag) || block instanceof GrowingPlantBlock) {
if (state.getFluidState()
.isEmpty())
return Blocks.AIR.defaultBlockState();

View file

@ -162,6 +162,11 @@ public class CopycatPanelBlock extends WaterloggedCopycatBlock {
return false;
}
@Override
public boolean skipRendering(BlockState state, BlockState adjacentState, Direction direction) {
return state.equals(adjacentState) && direction.getAxis().isHorizontal();
}
@Override
public boolean supportsExternalFaceHiding(BlockState state) {
return true;

View file

@ -5,9 +5,9 @@ import java.util.List;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.decoration.steamWhistle.WhistleBlock.WhistleSize;
import com.simibubi.create.content.decoration.steamWhistle.WhistleExtenderBlock.WhistleExtenderShape;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.fluids.tank.FluidTankBlockEntity;
import com.simibubi.create.content.kinetics.steamEngine.SteamJetParticleData;
import com.simibubi.create.foundation.advancement.AllAdvancements;
@ -89,7 +89,7 @@ public class WhistleBlockEntity extends SmartBlockEntity implements IHaveGoggleI
FluidTankBlockEntity tank = getTank();
boolean powered = isPowered()
&& (tank != null && tank.boiler.isActive() && (tank.boiler.passiveHeat || tank.boiler.activeHeat > 0)
|| isVirtual());
|| isVirtual());
animation.chase(powered ? 1 : 0, powered ? .5f : .4f, powered ? Chaser.EXP : Chaser.LINEAR);
animation.tickChaser();
CatnipServices.PLATFORM.executeOnClientOnly(() -> () -> this.tickAudio(getOctave(), powered));

View file

@ -8,14 +8,13 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
public class BuildersTeaItem extends Item {
public BuildersTeaItem(Properties properties) {
super(properties);
}
public @NotNull ItemStack finishUsingItem(@NotNull ItemStack stack, @NotNull Level level, @NotNull LivingEntity livingEntity) {
@Override
public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity livingEntity) {
ItemStack eatResult = super.finishUsingItem(stack, level, livingEntity);
if (livingEntity instanceof Player player && !player.getAbilities().instabuild) {
if (eatResult.isEmpty()) {
@ -27,11 +26,13 @@ public class BuildersTeaItem extends Item {
return eatResult;
}
public int getUseDuration(@NotNull ItemStack stack) {
@Override
public int getUseDuration(ItemStack stack, LivingEntity entity) {
return 42;
}
public @NotNull UseAnim getUseAnimation(@NotNull ItemStack stack) {
@Override
public UseAnim getUseAnimation(ItemStack stack) {
return UseAnim.DRINK;
}
}

View file

@ -8,6 +8,10 @@ import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems;
import com.simibubi.create.api.equipment.goggles.IHaveCustomOverlayIcon;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.api.equipment.goggles.IHaveHoveringInformation;
import com.simibubi.create.api.equipment.goggles.IProxyHoveringInformation;
import com.simibubi.create.compat.Mods;
import com.simibubi.create.content.contraptions.IDisplayAssemblyExceptions;
import com.simibubi.create.content.contraptions.piston.MechanicalPistonBlock;
@ -20,9 +24,9 @@ import com.simibubi.create.foundation.utility.CreateLang;
import com.simibubi.create.infrastructure.config.AllConfigs;
import com.simibubi.create.infrastructure.config.CClient;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.gui.element.BoxElement;
import net.createmod.catnip.gui.element.GuiGameElement;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.lang.Lang;
import net.createmod.catnip.outliner.Outline;
import net.createmod.catnip.outliner.Outliner;
@ -98,12 +102,11 @@ public class GoggleOverlayRenderer {
boolean hoverAddedInformation = false;
ItemStack item = AllItems.GOGGLES.asStack();
List<Component> tooltip = new ArrayList<>();
if (be instanceof IHaveCustomOverlayIcon customOverlayIcon)
item = customOverlayIcon.getIcon(isShifting);
List<Component> tooltip = new ArrayList<>();
if (hasGoggleInformation && wearingGoggles) {
IHaveGoggleInformation gte = (IHaveGoggleInformation) be;
goggleAddedInformation = gte.addToGoggleTooltip(tooltip, isShifting);

View file

@ -56,12 +56,6 @@ public class CardboardSwordItem extends SwordItem {
return enchantment == Enchantments.KNOCKBACK;
}
@Override
public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) {
AllSoundEvents.CARDBOARD_SWORD.playFrom(entity, 0.75f, 1.85f);
return super.onLeftClickEntity(stack, player, entity);
}
@SubscribeEvent
public static void cardboardSwordsMakeNoiseOnClick(PlayerInteractEvent.LeftClickBlock event) {
ItemStack itemStack = event.getItemStack();
@ -85,9 +79,8 @@ public class CardboardSwordItem extends SwordItem {
if (!(AllItems.CARDBOARD_SWORD.isIn(stack)))
return;
// Previously this was listening to LivingEntityAttackEvent, but that got merged, and so if we cancel this event
// onLeftClickEntity won't be called, so lets just call it manually over here
stack.getItem().onLeftClickEntity(stack, attacker, target);
AllSoundEvents.CARDBOARD_SWORD.playFrom(attacker, 0.75f, 1.85f);
event.setCanceled(true);
// Reference player.attack()

View file

@ -12,6 +12,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllDataComponents;
import com.simibubi.create.AllShapes;
import com.simibubi.create.foundation.block.IBE;
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.mixin.accessor.ItemStackHandlerAccessor;
import com.simibubi.create.foundation.utility.BlockHelper;
@ -28,7 +29,6 @@ import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.ItemContainerContents;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
@ -45,6 +45,7 @@ import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.neoforged.neoforge.common.util.FakePlayer;
public class ToolboxBlock extends HorizontalDirectionalBlock implements SimpleWaterloggedBlock, IBE<ToolboxBlockEntity> {
@ -184,9 +185,14 @@ public class ToolboxBlock extends HorizontalDirectionalBlock implements SimpleWa
return color;
}
public static Ingredient getMainBox() {
return Ingredient.of(AllBlocks.TOOLBOXES.get(DyeColor.BROWN)
.get());
@Override
public boolean hasAnalogOutputSignal(BlockState pState) {
return true;
}
@Override
public int getAnalogOutputSignal(BlockState pState, Level pLevel, BlockPos pPos) {
return ItemHelper.calcRedstoneFromBlockEntity(this, pLevel, pPos);
}
@Override

View file

@ -215,7 +215,7 @@ public class OpenEndedPipe extends FlowSource {
if (!FluidHelper.hasBlockState(fluid.getFluid()))
return true;
if (!fluidState.isEmpty() && fluidState.getType() != fluid.getFluid()) {
if (!fluidState.isEmpty() && FluidHelper.convertToStill(fluidState.getType()) != fluid.getFluid()) {
FluidReactions.handlePipeSpillCollision(world, outputPos, fluid.getFluid(), fluidState);
return false;
}

View file

@ -1,5 +1,7 @@
package com.simibubi.create.content.fluids;
import com.simibubi.create.content.fluids.potion.PotionFluid;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
@ -10,17 +12,35 @@ import net.neoforged.neoforge.fluids.BaseFlowingFluid;
public class VirtualFluid extends BaseFlowingFluid {
public VirtualFluid(Properties properties) {
public static VirtualFluid createSource(Properties properties) {
return new VirtualFluid(properties, true);
}
public static VirtualFluid createFlowing(Properties properties) {
return new VirtualFluid(properties, false);
}
private final boolean source;
public VirtualFluid(Properties properties, boolean source) {
super(properties);
this.source = source;
}
@Override
public Fluid getSource() {
if (source) {
return this;
}
return super.getSource();
}
@Override
public Fluid getFlowing() {
if (source) {
return super.getFlowing();
}
return this;
}
@ -36,7 +56,7 @@ public class VirtualFluid extends BaseFlowingFluid {
@Override
public boolean isSource(FluidState p_207193_1_) {
return false;
return source;
}
@Override

View file

@ -5,7 +5,7 @@ import java.util.List;
import java.util.Map;
import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.fluids.transfer.GenericItemEmptying;
import com.simibubi.create.content.kinetics.belt.behaviour.DirectBeltInputBehaviour;
import com.simibubi.create.content.kinetics.belt.transport.TransportedItemStack;
@ -28,6 +28,7 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.fluids.FluidStack;

View file

@ -31,19 +31,28 @@ import net.neoforged.neoforge.fluids.FluidStack;
public class PotionFluid extends VirtualFluid {
public PotionFluid(Properties properties) {
super(properties);
public static PotionFluid createSource(Properties properties) {
return new PotionFluid(properties, true);
}
public static FluidStack of(int amount, PotionContents potionContents) {
FluidStack fluidStack = new FluidStack(AllFluids.POTION.get()
.getSource(), amount);
public static PotionFluid createFlowing(Properties properties) {
return new PotionFluid(properties, false);
}
public PotionFluid(Properties properties, boolean source) {
super(properties, source);
}
public static FluidStack of(int amount, PotionContents potionContents, BottleType bottleType) {
FluidStack fluidStack;
fluidStack = new FluidStack(AllFluids.POTION.get().getSource(), amount);
addPotionToFluidStack(fluidStack, potionContents);
fluidStack.set(AllDataComponents.POTION_FLUID_BOTTLE_TYPE, bottleType);
return fluidStack;
}
public static FluidStack withEffects(int amount, PotionContents potionContents) {
FluidStack fluidStack = of(amount, potionContents);
FluidStack fluidStack = of(amount, potionContents, BottleType.REGULAR);
appendEffects(fluidStack, potionContents.customEffects());
return fluidStack;
}

View file

@ -68,9 +68,7 @@ public class PotionFluidHandler {
public static FluidStack getFluidFromPotion(PotionContents potionContents, BottleType bottleType, int amount) {
if (potionContents.is(Potions.WATER) && bottleType == BottleType.REGULAR)
return new FluidStack(Fluids.WATER, amount);
FluidStack fluid = PotionFluid.of(amount, potionContents);
fluid.set(AllDataComponents.POTION_FLUID_BOTTLE_TYPE, bottleType);
return fluid;
return PotionFluid.of(amount, potionContents, bottleType);
}
public static BottleType bottleTypeFromItem(Item item) {

View file

@ -10,7 +10,7 @@ import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.api.behaviour.BlockSpoutingBehaviour;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.fluids.FluidFX;
import com.simibubi.create.content.kinetics.belt.behaviour.BeltProcessingBehaviour;
import com.simibubi.create.content.kinetics.belt.behaviour.BeltProcessingBehaviour.ProcessingResult;
@ -23,11 +23,10 @@ import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import com.simibubi.create.foundation.blockEntity.behaviour.fluid.SmartFluidTankBehaviour;
import com.simibubi.create.foundation.fluid.FluidHelper;
import com.simibubi.create.impl.behaviour.BlockSpoutingBehaviourImpl;
import net.createmod.catnip.nbt.NBTHelper;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.nbt.NBTHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
@ -39,6 +38,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.fluids.FluidStack;
@ -91,7 +91,7 @@ public class SpoutBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
}
protected ProcessingResult onItemReceived(TransportedItemStack transported,
TransportedItemStackHandlerBehaviour handler) {
TransportedItemStackHandlerBehaviour handler) {
if (handler.blockEntity.isVirtual())
return PASS;
if (!FillingBySpout.canItemBeFilled(level, transported.stack))
@ -104,7 +104,7 @@ public class SpoutBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
}
protected ProcessingResult whenItemHeld(TransportedItemStack transported,
TransportedItemStackHandlerBehaviour handler) {
TransportedItemStackHandlerBehaviour handler) {
if (processingTicks != -1 && processingTicks != 5)
return HOLD;
if (!FillingBySpout.canItemBeFilled(level, transported.stack))
@ -121,7 +121,7 @@ public class SpoutBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
if (processingTicks == -1) {
processingTicks = FILLING_TIME;
notifyUpdate();
AllSoundEvents.SPOUTING.playOnServer(level, worldPosition, 0.75f, 0.9f + 0.2f * (float)Math.random());
AllSoundEvents.SPOUTING.playOnServer(level, worldPosition, 0.75f, 0.9f + 0.2f * (float) Math.random());
return HOLD;
}
@ -232,13 +232,15 @@ public class SpoutBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
if (processingTicks >= 8 && level.isClientSide) {
spawnProcessingParticles(tank.getPrimaryTank()
.getRenderedFluid());
.getRenderedFluid());
}
}
protected void spawnProcessingParticles(FluidStack fluid) {
if (isVirtual())
return;
if (fluid.isEmpty())
return;
Vec3 vec = VecHelper.getCenterOf(worldPosition);
vec = vec.subtract(0, 8 / 16f, 0);
ParticleOptions particle = FluidFX.getFluidParticle(fluid);

View file

@ -65,9 +65,9 @@ public class SpoutRenderer extends SafeBlockEntityRenderer<SpoutBlockEntity> {
processingProgress = Mth.clamp(processingProgress, 0, 1);
float radius = 0;
if (processingTicks != -1) {
if (!fluidStack.isEmpty() && processingTicks != -1) {
radius = (float) (Math.pow(((2 * processingProgress) - 1), 2) - 1);
AABB bb = new AABB(0.5, .5, 0.5, 0.5, -1.2, 0.5).inflate(radius / 32f);
AABB bb = new AABB(0.5, 0.0, 0.5, 0.5, -1.2, 0.5).inflate(radius / 32f);
FluidRenderer.renderFluidBox(fluidStack.getFluid(), fluidStack.getAmount(), (float) bb.minX, (float) bb.minY, (float) bb.minZ,
(float) bb.maxX, (float) bb.maxY, (float) bb.maxZ, buffer, ms, light, true, true, fluidStack.getComponentsPatch());
}

View file

@ -9,7 +9,7 @@ import javax.annotation.Nullable;
import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.api.connectivity.ConnectivityHandler;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.fluids.tank.FluidTankBlock.Shape;
import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.blockEntity.IMultiBlockEntityContainer;
@ -31,6 +31,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.fluids.FluidStack;

View file

@ -113,7 +113,7 @@ public abstract class BlockBreakingKineticBlockEntity extends KineticBlockEntity
float breakSpeed = getBreakSpeed();
destroyProgress += Mth.clamp((int) (breakSpeed / blockHardness), 1, 10 - destroyProgress);
level.playSound(null, worldPosition, stateToBreak.getSoundType()
.getHitSound(), SoundSource.NEUTRAL, .25f, 1);
.getHitSound(), SoundSource.BLOCKS, .25f, 1);
if (destroyProgress >= 10) {
onBlockBroken(stateToBreak);

View file

@ -9,8 +9,8 @@ import java.util.Objects;
import javax.annotation.Nullable;
import com.simibubi.create.Create;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.equipment.goggles.IHaveHoveringInformation;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.api.equipment.goggles.IHaveHoveringInformation;
import com.simibubi.create.content.kinetics.BlockStressValues;
import com.simibubi.create.content.kinetics.KineticNetwork;
import com.simibubi.create.content.kinetics.RotationPropagator;
@ -48,6 +48,7 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
@ -405,7 +406,8 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI
}
@Override
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {}
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
}
@Override
public boolean addToTooltip(List<Component> tooltip, boolean isPlayerSneaking) {
@ -529,10 +531,10 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI
* @param connectedViaCogs whether these kinetic blocks are connected via mutual
* IRotate.hasIntegratedCogwheel()
* @return factor of rotation speed from this BE to other. 0 if no rotation is
* transferred, or the standard rules apply (integrated shafts/cogs)
* transferred, or the standard rules apply (integrated shafts/cogs)
*/
public float propagateRotationTo(KineticBlockEntity target, BlockState stateFrom, BlockState stateTo, BlockPos diff,
boolean connectedViaAxes, boolean connectedViaCogs) {
boolean connectedViaAxes, boolean connectedViaCogs) {
return 0;
}
@ -572,7 +574,7 @@ public class KineticBlockEntity extends SmartBlockEntity implements IHaveGoggleI
* @param state
* @param otherState
* @return true if this and the other component should check their propagation
* factor and are not already connected via integrated cogs or shafts
* factor and are not already connected via integrated cogs or shafts
*/
public boolean isCustomConnection(KineticBlockEntity other, BlockState state, BlockState otherState) {
return false;

View file

@ -5,19 +5,18 @@ import org.joml.Vector3f;
import dev.engine_room.flywheel.api.instance.InstanceHandle;
import dev.engine_room.flywheel.api.instance.InstanceType;
import dev.engine_room.flywheel.lib.instance.ColoredLitInstance;
import dev.engine_room.flywheel.lib.instance.ColoredLitOverlayInstance;
import net.createmod.catnip.theme.Color;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Vec3i;
import net.minecraft.world.level.block.state.BlockState;
public class RotatingInstance extends ColoredLitInstance {
public class RotatingInstance extends ColoredLitOverlayInstance {
public static final float SPEED_MULTIPLIER = 6;
public byte rotationAxisX;
public byte rotationAxisY;
public byte rotationAxisZ;
public byte rotationAxisX;
public byte rotationAxisY;
public byte rotationAxisZ;
public float x;
public float y;
public float z;
@ -98,12 +97,12 @@ public class RotatingInstance extends ColoredLitInstance {
}
public RotatingInstance setRotationAxis(Direction.Axis axis) {
Direction orientation = Direction.get(Direction.AxisDirection.POSITIVE, axis);
return setRotationAxis(orientation.step());
}
Direction orientation = Direction.get(Direction.AxisDirection.POSITIVE, axis);
return setRotationAxis(orientation.step());
}
public RotatingInstance setRotationAxis(Vector3f axis) {
return setRotationAxis(axis.x(), axis.y(), axis.z());
public RotatingInstance setRotationAxis(Vector3f axis) {
return setRotationAxis(axis.x(), axis.y(), axis.z());
}
public RotatingInstance setRotationAxis(float rotationAxisX, float rotationAxisY, float rotationAxisZ) {
@ -114,8 +113,8 @@ public class RotatingInstance extends ColoredLitInstance {
}
public RotatingInstance setPosition(Vec3i pos) {
return setPosition(pos.getX(), pos.getY(), pos.getZ());
}
return setPosition(pos.getX(), pos.getY(), pos.getZ());
}
public RotatingInstance setPosition(Vector3f pos) {
return setPosition(pos.x(), pos.y(), pos.z());

View file

@ -27,10 +27,10 @@ import com.simibubi.create.foundation.item.TooltipHelper;
import com.simibubi.create.foundation.utility.CreateLang;
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
import net.createmod.catnip.lang.Lang;
import net.createmod.catnip.nbt.NBTHelper;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.animation.LerpedFloat;
import net.createmod.catnip.lang.Lang;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.nbt.NBTHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -60,6 +60,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.capabilities.Capabilities;
@ -557,7 +558,10 @@ public class DeployerBlockEntity extends KineticBlockEntity {
ItemStack heldItemMainhand = player.getMainHandItem();
if (heldItemMainhand.getItem() instanceof SandPaperItem) {
return checkRecipe(AllRecipeTypes.SANDPAPER_POLISHING, new SingleRecipeInput(stack), level).orElse(null);
Optional<RecipeHolder<Recipe<RecipeInput>>> polishingRecipe = checkRecipe(AllRecipeTypes.SANDPAPER_POLISHING, new SingleRecipeInput(stack), level);
if (polishingRecipe.isPresent()) {
return polishingRecipe.get();
}
}
recipeInv.setStackInSlot(0, stack);

View file

@ -193,8 +193,9 @@ public class DeployerHandler {
if (stack.has(DataComponents.FOOD)) {
FoodProperties foodProperties = item.getFoodProperties(stack, player);
if (foodProperties != null && playerEntity.canEat(foodProperties.canAlwaysEat())) {
playerEntity.eat(world, stack);
player.spawnedItemEffects = stack.copy();
ItemStack copy = stack.copy();
player.setItemInHand(hand, stack.finishUsingItem(world, playerEntity));
player.spawnedItemEffects = copy;
success = true;
}
}

View file

@ -2,7 +2,7 @@ package com.simibubi.create.content.kinetics.gauge;
import java.util.List;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
import com.simibubi.create.foundation.utility.CreateLang;

View file

@ -5,6 +5,7 @@ import java.util.Optional;
import javax.annotation.Nullable;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.jetbrains.annotations.ApiStatus.Internal;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllRegistries;
@ -41,7 +42,6 @@ import net.minecraft.core.component.DataComponents;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.WorldlyContainer;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.CampfireCookingRecipe;
@ -65,8 +65,6 @@ import net.neoforged.neoforge.items.ItemHandlerHelper;
import net.neoforged.neoforge.items.wrapper.SidedInvWrapper;
import net.neoforged.neoforge.registries.DeferredRegister;
import org.jetbrains.annotations.ApiStatus.Internal;
public class AllArmInteractionPointTypes {
private static final DeferredRegister<ArmInteractionPointType> REGISTER = DeferredRegister.create(AllRegistries.Keys.ARM_INTERACTION_POINT_TYPES, Create.ID);
@ -607,45 +605,30 @@ public class AllArmInteractionPointTypes {
@Override
public ItemStack insert(ItemStack stack, boolean simulate) {
Item item = stack.getItem();
if (stack.get(DataComponents.JUKEBOX_PLAYABLE) == null)
return stack;
if (cachedState.getOptionalValue(JukeboxBlock.HAS_RECORD)
.orElse(true))
if (cachedState.getOptionalValue(JukeboxBlock.HAS_RECORD).orElse(true))
return stack;
BlockEntity blockEntity = level.getBlockEntity(pos);
if (!(blockEntity instanceof JukeboxBlockEntity jukeboxBE))
if (!(level.getBlockEntity(pos) instanceof JukeboxBlockEntity jukeboxBE))
return stack;
if (!jukeboxBE.getTheItem()
.isEmpty())
if (!jukeboxBE.getTheItem().isEmpty())
return stack;
ItemStack remainder = stack.copy();
ItemStack toInsert = remainder.split(1);
if (!simulate) {
if (!simulate)
jukeboxBE.setTheItem(toInsert);
level.setBlock(pos, cachedState.setValue(JukeboxBlock.HAS_RECORD, true), 2);
level.levelEvent(null, 1010, pos, Item.getId(item));
}
return remainder;
}
@Override
public ItemStack extract(int slot, int amount, boolean simulate) {
if (!cachedState.getOptionalValue(JukeboxBlock.HAS_RECORD)
.orElse(false))
if (!cachedState.getOptionalValue(JukeboxBlock.HAS_RECORD).orElse(false))
return ItemStack.EMPTY;
BlockEntity blockEntity = level.getBlockEntity(pos);
if (!(blockEntity instanceof JukeboxBlockEntity jukeboxBE))
if (!(level.getBlockEntity(pos) instanceof JukeboxBlockEntity jukeboxBE))
return ItemStack.EMPTY;
ItemStack record = jukeboxBE.getTheItem();
if (record.isEmpty())
return ItemStack.EMPTY;
if (!simulate) {
level.levelEvent(1010, pos, 0);
jukeboxBE.clearContent();
level.setBlock(pos, cachedState.setValue(JukeboxBlock.HAS_RECORD, false), 2);
}
return record;
if (!simulate)
return jukeboxBE.removeItem(slot, amount);
return jukeboxBE.getTheItem();
}
}

View file

@ -9,10 +9,8 @@ import com.simibubi.create.foundation.render.AllInstanceTypes;
import dev.engine_room.flywheel.api.instance.Instance;
import dev.engine_room.flywheel.api.instance.InstancerProvider;
import dev.engine_room.flywheel.api.model.Model;
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
import dev.engine_room.flywheel.lib.model.Models;
import net.createmod.ponder.render.VirtualRenderHelper;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.world.level.block.state.BlockState;
@ -63,10 +61,6 @@ public class SawVisual extends KineticBlockEntityVisual<SawBlockEntity> {
rotatingModel.delete();
}
protected Model model() {
return VirtualRenderHelper.blockModel(blockState);
}
@Override
public void collectCrumblingInstances(Consumer<Instance> consumer) {
consumer.accept(rotatingModel);

View file

@ -37,7 +37,10 @@ public abstract class AbstractSimpleShaftBlock extends AbstractShaftBlock implem
@Override
public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean isMoving) {
if (state != newState && !isMoving)
boolean wasWaterLogged = state.hasProperty(WATERLOGGED) &&
newState.hasProperty(WATERLOGGED) &&
(state.getValue(WATERLOGGED) != newState.getValue(WATERLOGGED));
if (state != newState && !isMoving && !wasWaterLogged)
removeBracket(world, pos, true).ifPresent(stack -> Block.popResource(world, pos, stack));
super.onRemove(state, world, pos, newState, isMoving);
}

View file

@ -6,8 +6,8 @@ import java.util.List;
import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.contraptions.bearing.WindmillBearingBlockEntity.RotationDirection;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.fluids.tank.FluidTankBlockEntity;
import com.simibubi.create.content.kinetics.base.GeneratingKineticBlockEntity;
import com.simibubi.create.content.kinetics.base.IRotate;
@ -21,6 +21,7 @@ import com.simibubi.create.foundation.utility.CreateLang;
import net.createmod.catnip.platform.CatnipServices;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.math.AngleHelper;
import net.createmod.catnip.math.VecHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
@ -32,6 +33,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
@ -62,7 +64,8 @@ public class SteamEngineBlockEntity extends SmartBlockEntity implements IHaveGog
registerAwardables(behaviours, AllAdvancements.STEAM_ENGINE);
}
private void onDirectionChanged() {}
private void onDirectionChanged() {
}
@Override
public void tick() {
@ -90,7 +93,7 @@ public class SteamEngineBlockEntity extends SmartBlockEntity implements IHaveGog
boolean verticalTarget = false;
BlockState shaftState = shaft.getBlockState();
Axis targetAxis = Axis.X;
if (shaftState.getBlock()instanceof IRotate ir)
if (shaftState.getBlock() instanceof IRotate ir)
targetAxis = ir.getRotationAxis(shaftState);
verticalTarget = targetAxis == Axis.Y;

View file

@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
import com.mojang.serialization.MapCodec;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.equipment.goggles.IProxyHoveringInformation;
import com.simibubi.create.api.equipment.goggles.IProxyHoveringInformation;
import com.simibubi.create.content.equipment.wrench.IWrenchable;
import com.simibubi.create.foundation.block.render.MultiPosDestructionHandler;
@ -39,6 +39,7 @@ import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.neoforged.neoforge.client.extensions.common.IClientBlockExtensions;
public class WaterWheelStructuralBlock extends DirectionalBlock implements IWrenchable, IProxyHoveringInformation {
@ -94,7 +95,7 @@ public class WaterWheelStructuralBlock extends DirectionalBlock implements IWren
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) {
if (!stillValid(level, pos, state, false))
return ItemInteractionResult.FAIL;
if (!(level.getBlockEntity(getMaster(level, pos, state))instanceof WaterWheelBlockEntity wwt))
if (!(level.getBlockEntity(getMaster(level, pos, state)) instanceof WaterWheelBlockEntity wwt))
return ItemInteractionResult.FAIL;
return wwt.applyMaterialIfValid(stack);
}
@ -117,7 +118,7 @@ public class WaterWheelStructuralBlock extends DirectionalBlock implements IWren
@Override
public BlockState updateShape(BlockState pState, Direction pFacing, BlockState pFacingState, LevelAccessor pLevel,
BlockPos pCurrentPos, BlockPos pFacingPos) {
BlockPos pCurrentPos, BlockPos pFacingPos) {
if (stillValid(pLevel, pCurrentPos, pState, false)) {
BlockPos masterPos = getMaster(pLevel, pCurrentPos, pState);
if (!pLevel.getBlockTicks()
@ -164,7 +165,7 @@ public class WaterWheelStructuralBlock extends DirectionalBlock implements IWren
@Override
public boolean addLandingEffects(BlockState state1, ServerLevel level, BlockPos pos, BlockState state2,
LivingEntity entity, int numberOfParticles) {
LivingEntity entity, int numberOfParticles) {
return true;
}

View file

@ -13,7 +13,7 @@ import org.jetbrains.annotations.Nullable;
import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.Create;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.kinetics.belt.behaviour.DirectBeltInputBehaviour;
import com.simibubi.create.content.kinetics.belt.behaviour.TransportedItemStackHandlerBehaviour;
import com.simibubi.create.content.kinetics.belt.behaviour.TransportedItemStackHandlerBehaviour.TransportedResult;
@ -754,10 +754,10 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
.style(ChatFormatting.YELLOW)
.forGoggles(tooltip);
if (!item.isEmpty())
CreateLang.translate("tooltip.chute.contains", Component.translatable(item.getDescriptionId())
.getString(), item.getCount())
.style(ChatFormatting.GREEN)
.forGoggles(tooltip);
CreateLang.translate("tooltip.chute.contains", Component.translatable(item.getDescriptionId())
.getString(), item.getCount())
.style(ChatFormatting.GREEN)
.forGoggles(tooltip);
return true;
}

View file

@ -6,10 +6,8 @@ import java.util.List;
import com.simibubi.create.AllDataComponents;
import com.simibubi.create.AllItems;
import com.simibubi.create.content.fluids.transfer.GenericItemEmptying;
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttribute;
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttribute;
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttribute;
import com.simibubi.create.content.logistics.box.PackageItem;
import com.simibubi.create.content.logistics.item.filter.attribute.ItemAttribute;
import net.createmod.catnip.data.Pair;
import net.minecraft.core.HolderLookup;
@ -17,6 +15,7 @@ import net.minecraft.core.component.DataComponents;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.items.ItemStackHandler;
@ -27,15 +26,18 @@ public class FilterItemStack {
public static FilterItemStack of(ItemStack filter) {
if (!filter.isComponentsPatchEmpty()) {
filter.remove(DataComponents.ENCHANTMENTS);
filter.remove(DataComponents.STORED_ENCHANTMENTS);
filter.remove(DataComponents.ATTRIBUTE_MODIFIERS);
if (AllItems.FILTER.isIn(filter))
if (AllItems.FILTER.isIn(filter)) {
trimFilterComponents(filter);
return new ListFilterItemStack(filter);
if (AllItems.ATTRIBUTE_FILTER.isIn(filter))
}
if (AllItems.ATTRIBUTE_FILTER.isIn(filter)) {
trimFilterComponents(filter);
return new AttributeFilterItemStack(filter);
if (AllItems.PACKAGE_FILTER.isIn(filter))
}
if (AllItems.PACKAGE_FILTER.isIn(filter)) {
trimFilterComponents(filter);
return new PackageFilterItemStack(filter);
}
}
return new FilterItemStack(filter);
@ -49,6 +51,11 @@ public class FilterItemStack {
return of(ItemStack.EMPTY);
}
private static void trimFilterComponents(ItemStack filter) {
filter.remove(DataComponents.ENCHANTMENTS);
filter.remove(DataComponents.ATTRIBUTE_MODIFIERS);
}
public boolean isEmpty() {
return filterItemStack.isEmpty();
}
@ -197,35 +204,35 @@ public class FilterItemStack {
boolean matches = attribute.appliesTo(stack, world) != inverted;
if (matches) {
switch (whitelistMode) {
case BLACKLIST -> {
return false;
}
case WHITELIST_CONJ -> {
switch (whitelistMode) {
case BLACKLIST -> {
return false;
}
case WHITELIST_CONJ -> {
continue;
}
case WHITELIST_DISJ -> {
return true;
}
}
}
case WHITELIST_DISJ -> {
return true;
}
}
} else {
switch (whitelistMode) {
case BLACKLIST, WHITELIST_DISJ -> {
switch (whitelistMode) {
case BLACKLIST, WHITELIST_DISJ -> {
continue;
}
case WHITELIST_CONJ -> {
return false;
}
}
}
case WHITELIST_CONJ -> {
return false;
}
}
}
}
return switch (whitelistMode) {
case BLACKLIST, WHITELIST_CONJ -> true;
case WHITELIST_DISJ -> false;
};
return switch (whitelistMode) {
case BLACKLIST, WHITELIST_CONJ -> true;
case WHITELIST_DISJ -> false;
};
}
}
}

View file

@ -11,7 +11,7 @@ import org.apache.commons.lang3.mutable.MutableBoolean;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.content.equipment.goggles.IHaveHoveringInformation;
import com.simibubi.create.api.equipment.goggles.IHaveHoveringInformation;
import com.simibubi.create.content.kinetics.belt.BeltBlockEntity;
import com.simibubi.create.content.kinetics.belt.BeltHelper;
import com.simibubi.create.content.kinetics.belt.behaviour.DirectBeltInputBehaviour;
@ -28,10 +28,10 @@ import com.simibubi.create.foundation.item.ItemHelper.ExtractionCountMode;
import com.simibubi.create.infrastructure.config.AllConfigs;
import dev.engine_room.flywheel.lib.visualization.VisualizationHelper;
import net.createmod.catnip.math.BlockFace;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.animation.LerpedFloat;
import net.createmod.catnip.animation.LerpedFloat.Chaser;
import net.createmod.catnip.math.BlockFace;
import net.createmod.catnip.math.VecHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
@ -346,14 +346,14 @@ public class FunnelBlockEntity extends SmartBlockEntity implements IHaveHovering
if (!(blockState.getBlock() instanceof BeltFunnelBlock))
return -1 / 16f;
switch (blockState.getValue(BeltFunnelBlock.SHAPE)) {
default:
case RETRACTED:
return 0;
case EXTENDED:
return 8 / 16f;
case PULLING:
case PUSHING:
return -2 / 16f;
default:
case RETRACTED:
return 0;
case EXTENDED:
return 8 / 16f;
case PULLING:
case PUSHING:
return -2 / 16f;
}
}

View file

@ -4,7 +4,7 @@ import java.util.List;
import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.equipment.goggles.IHaveHoveringInformation;
import com.simibubi.create.api.equipment.goggles.IHaveHoveringInformation;
import com.simibubi.create.content.logistics.box.PackageItem;
import com.simibubi.create.content.logistics.box.PackageStyles;
import com.simibubi.create.content.logistics.packagePort.PackagePortBlockEntity;
@ -15,10 +15,10 @@ import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour
import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.foundation.item.TooltipHelper;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.nbt.NBTHelper;
import net.createmod.catnip.animation.LerpedFloat;
import net.createmod.catnip.animation.LerpedFloat.Chaser;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.nbt.NBTHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.HolderLookup;
@ -35,6 +35,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.Capabilities.ItemHandler;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
@ -255,7 +256,8 @@ public class FrogportBlockEntity extends PackagePortBlockEntity implements IHave
}
@Override
protected void onOpenChange(boolean open) {}
protected void onOpenChange(boolean open) {
}
public void tryPullingFromOwnAndAdjacentInventories() {
if (isAnimationInProgress())

View file

@ -10,8 +10,8 @@ import java.util.stream.IntStream;
import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.api.equipment.goggles.IHaveHoveringInformation;
import com.simibubi.create.content.contraptions.actors.seat.SeatEntity;
import com.simibubi.create.content.equipment.goggles.IHaveHoveringInformation;
import com.simibubi.create.content.logistics.BigItemStack;
import com.simibubi.create.content.logistics.filter.FilterItem;
import com.simibubi.create.content.logistics.filter.FilterItemStack;
@ -101,7 +101,7 @@ public class StockTickerBlockEntity extends StockCheckingBlockEntity implements
@Override
public boolean broadcastPackageRequest(RequestType type, PackageOrder order, IItemHandler ignoredHandler,
String address) {
String address) {
boolean result = super.broadcastPackageRequest(type, order, ignoredHandler, address);
previouslyUsedAddress = address;
notifyUpdate();
@ -182,7 +182,7 @@ public class StockTickerBlockEntity extends StockCheckingBlockEntity implements
List<BigItemStack> inCategory = new ArrayList<>();
if (!filter.isEmpty()) {
FilterItemStack filterItemStack = FilterItemStack.of(filter);
for (Iterator<BigItemStack> iterator = newlyReceivedStockSnapshot.iterator(); iterator.hasNext();) {
for (Iterator<BigItemStack> iterator = newlyReceivedStockSnapshot.iterator(); iterator.hasNext(); ) {
BigItemStack bigStack = iterator.next();
if (!filterItemStack.test(level, bigStack.stack))
continue;
@ -266,8 +266,8 @@ public class StockTickerBlockEntity extends StockCheckingBlockEntity implements
@Override
public Component getDisplayName() {
return Component.empty();
}
return Component.empty();
}
}
@ -280,8 +280,8 @@ public class StockTickerBlockEntity extends StockCheckingBlockEntity implements
@Override
public Component getDisplayName() {
return Component.empty();
}
return Component.empty();
}
}

View file

@ -15,7 +15,7 @@ import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.kinetics.belt.BeltBlockEntity;
import com.simibubi.create.content.kinetics.belt.BeltHelper;
import com.simibubi.create.content.kinetics.belt.behaviour.DirectBeltInputBehaviour;
@ -34,8 +34,8 @@ import com.simibubi.create.infrastructure.config.AllConfigs;
import net.createmod.catnip.data.Couple;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.nbt.NBTHelper;
import net.createmod.catnip.lang.Lang;
import net.createmod.catnip.nbt.NBTHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -53,6 +53,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.items.IItemHandler;
@ -180,7 +181,7 @@ public class BrassTunnelBlockEntity extends BeltTunnelBlockEntity implements IHa
if (distributionTargets.getFirst()
.isEmpty()
&& distributionTargets.getSecond()
.isEmpty())
.isEmpty())
return;
if (newItemArrived) {
@ -383,7 +384,7 @@ public class BrassTunnelBlockEntity extends BeltTunnelBlockEntity implements IHa
@Nullable
protected ItemStack insertIntoTunnel(BrassTunnelBlockEntity tunnel, Direction side, ItemStack stack,
boolean simulate) {
boolean simulate) {
if (stack.isEmpty())
return stack;
if (!tunnel.testFlapFilter(side, stack))
@ -521,7 +522,7 @@ public class BrassTunnelBlockEntity extends BeltTunnelBlockEntity implements IHa
}
private void addValidOutputsOf(BrassTunnelBlockEntity tunnelBE,
List<Pair<BrassTunnelBlockEntity, Direction>> validOutputs) {
List<Pair<BrassTunnelBlockEntity, Direction>> validOutputs) {
syncSet.add(tunnelBE);
BeltBlockEntity below = BeltHelper.getSegmentBE(level, tunnelBE.worldPosition.below());
if (below == null)
@ -795,9 +796,9 @@ public class BrassTunnelBlockEntity extends BeltTunnelBlockEntity implements IHa
CreateLang.translate("tooltip.brass_tunnel.contains").style(ChatFormatting.WHITE).forGoggles(tooltip);
for (ItemStack item : allStacks) {
CreateLang.translate("tooltip.brass_tunnel.contains_entry",
CreateLang.translate("tooltip.brass_tunnel.contains_entry",
Component.translatable(item.getDescriptionId()).getString(), item.getCount())
.style(ChatFormatting.GRAY).forGoggles(tooltip);
.style(ChatFormatting.GRAY).forGoggles(tooltip);
}
CreateLang.translate("tooltip.brass_tunnel.retrieve").style(ChatFormatting.DARK_GRAY).forGoggles(tooltip);

View file

@ -159,10 +159,7 @@ public class ItemVaultBlock extends Block implements IWrenchable, IBE<ItemVaultB
@Override
public int getAnalogOutputSignal(BlockState pState, Level pLevel, BlockPos pPos) {
return getBlockEntityOptional(pLevel, pPos)
.map(vte -> pLevel.getCapability(Capabilities.ItemHandler.BLOCK, vte.getBlockPos(), null))
.map(ItemHelper::calcRedstoneFromInventory)
.orElse(0);
return ItemHelper.calcRedstoneFromBlockEntity(this, pLevel, pPos);
}
@Override

View file

@ -10,7 +10,7 @@ import com.google.common.collect.ImmutableList;
import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllParticleTypes;
import com.simibubi.create.AllTags;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.content.fluids.FluidFX;
import com.simibubi.create.content.fluids.particle.FluidParticleData;
import com.simibubi.create.content.kinetics.belt.behaviour.DirectBeltInputBehaviour;
@ -31,14 +31,14 @@ import com.simibubi.create.foundation.utility.BlockHelper;
import com.simibubi.create.foundation.utility.CreateLang;
import net.createmod.catnip.animation.AnimationTickHolder;
import net.createmod.catnip.animation.LerpedFloat;
import net.createmod.catnip.animation.LerpedFloat.Chaser;
import net.createmod.catnip.data.Couple;
import net.createmod.catnip.data.IntAttached;
import net.createmod.catnip.data.Iterate;
import net.createmod.catnip.nbt.NBTHelper;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.animation.LerpedFloat;
import net.createmod.catnip.animation.LerpedFloat.Chaser;
import net.createmod.catnip.lang.LangBuilder;
import net.createmod.catnip.math.VecHelper;
import net.createmod.catnip.nbt.NBTHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -58,6 +58,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.capabilities.Capabilities;
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
import net.neoforged.neoforge.fluids.FluidStack;
@ -376,14 +377,14 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
IItemHandler targetInv = be == null ? null
: Optional.ofNullable(level.getCapability(Capabilities.ItemHandler.BLOCK, be.getBlockPos(), direction.getOpposite()))
.orElse(inserter == null ? null : inserter.getInventory());
.orElse(inserter == null ? null : inserter.getInventory());
IFluidHandler targetTank = be == null ? null
: level.getCapability(Capabilities.FluidHandler.BLOCK, be.getBlockPos(), direction.getOpposite());
boolean update = false;
for (Iterator<ItemStack> iterator = spoutputBuffer.iterator(); iterator.hasNext();) {
for (Iterator<ItemStack> iterator = spoutputBuffer.iterator(); iterator.hasNext(); ) {
ItemStack itemStack = iterator.next();
if (direction == Direction.DOWN) {
@ -413,7 +414,7 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
itemStack.setCount(remainder.getCount());
}
for (Iterator<FluidStack> iterator = spoutputFluidBuffer.iterator(); iterator.hasNext();) {
for (Iterator<FluidStack> iterator = spoutputFluidBuffer.iterator(); iterator.hasNext(); ) {
FluidStack fluidStack = iterator.next();
if (direction == Direction.DOWN) {
@ -527,7 +528,7 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
be == null ? null : BlockEntityBehaviour.get(level, be.getBlockPos(), InvManipulationBehaviour.TYPE);
IItemHandler targetInv = be == null ? null
: Optional.ofNullable(level.getCapability(Capabilities.ItemHandler.BLOCK, be.getBlockPos(), direction.getOpposite()))
.orElse(inserter == null ? null : inserter.getInventory());
.orElse(inserter == null ? null : inserter.getInventory());
IFluidHandler targetTank = be == null ? null
: level.getCapability(Capabilities.FluidHandler.BLOCK, be.getBlockPos(), direction.getOpposite());
boolean externalTankNotPresent = targetTank == null;
@ -572,7 +573,7 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
}
private boolean acceptFluidOutputsIntoBasin(List<FluidStack> outputFluids, boolean simulate,
IFluidHandler targetTank) {
IFluidHandler targetTank) {
for (FluidStack fluidStack : outputFluids) {
FluidAction action = simulate ? FluidAction.SIMULATE : FluidAction.EXECUTE;
int fill = targetTank instanceof SmartFluidTankBehaviour.InternalFluidHandler
@ -744,7 +745,7 @@ public class BasinBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
ItemStack stackInSlot = itemCapability.getStackInSlot(i);
if (stackInSlot.isEmpty())
continue;
CreateLang.text("")
CreateLang.text("")
.add(Component.translatable(stackInSlot.getDescriptionId())
.withStyle(ChatFormatting.GRAY))
.add(CreateLang.text(" x" + stackInSlot.getCount())

View file

@ -2,10 +2,10 @@ package com.simibubi.create.content.processing.burner;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.api.contraption.train.TrainConductorHandler;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.Contraption;
import com.simibubi.create.content.contraptions.behaviour.MovingInteractionBehaviour;
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock.HeatLevel;
import com.simibubi.create.content.trains.entity.CarriageContraption;
import com.simibubi.create.content.trains.entity.CarriageContraptionEntity;
import com.simibubi.create.content.trains.entity.Train;
@ -21,9 +21,21 @@ import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo;
public class BlazeBurnerInteractionBehaviour extends MovingInteractionBehaviour {
import java.util.function.Predicate;
public class BlockBasedTrainConductorInteractionBehaviour extends MovingInteractionBehaviour {
private final Predicate<BlockState> isValidConductor;
private final TrainConductorHandler.UpdateScheduleCallback callback;
public BlockBasedTrainConductorInteractionBehaviour(Predicate<BlockState> isValidConductor, TrainConductorHandler.UpdateScheduleCallback callback) {
this.isValidConductor = isValidConductor;
this.callback = callback;
}
@Override
public boolean handlePlayerInteraction(Player player, InteractionHand activeHand, BlockPos localPos,
@ -40,8 +52,7 @@ public class BlazeBurnerInteractionBehaviour extends MovingInteractionBehaviour
StructureBlockInfo info = carriageContraption.getBlocks()
.get(localPos);
if (info == null || !info.state().hasProperty(BlazeBurnerBlock.HEAT_LEVEL)
|| info.state().getValue(BlazeBurnerBlock.HEAT_LEVEL) == HeatLevel.NONE)
if (info == null || !isValidConductor.test(info.state()))
return false;
Direction assemblyDirection = carriageContraption.getAssemblyDirection();
@ -74,6 +85,7 @@ public class BlazeBurnerInteractionBehaviour extends MovingInteractionBehaviour
train.runtime.isAutoSchedule ? "schedule.auto_removed_from_train" : "schedule.removed_from_train"),
true);
player.setItemInHand(activeHand, train.runtime.returnSchedule(player.registryAccess()));
callback.update(false, info.state(), newBlockState -> setBlockState(localPos, contraptionEntity, newBlockState));
return true;
}
@ -89,7 +101,7 @@ public class BlazeBurnerInteractionBehaviour extends MovingInteractionBehaviour
player.displayClientMessage(CreateLang.translateDirect("schedule.no_stops"), true);
return true;
}
callback.update(true, info.state(), newBlockState -> setBlockState(localPos, contraptionEntity, newBlockState));
train.runtime.setSchedule(schedule, false);
AllAdvancements.CONDUCTOR.awardTo(player);
AllSoundEvents.CONFIRM.playOnServer(player.level(), player.blockPosition(), 1, 1);
@ -105,4 +117,10 @@ public class BlazeBurnerInteractionBehaviour extends MovingInteractionBehaviour
return true;
}
private void setBlockState(BlockPos localPos, AbstractContraptionEntity contraption, BlockState newState) {
StructureTemplate.StructureBlockInfo info = contraption.getContraption().getBlocks().get(localPos);
if (info != null) {
setContraptionBlockData(contraption, localPos, new StructureTemplate.StructureBlockInfo(info.pos(), newState, info.nbt()));
}
}
}

View file

@ -5,11 +5,11 @@ import org.joml.Quaternionfc;
import dev.engine_room.flywheel.api.instance.InstanceHandle;
import dev.engine_room.flywheel.api.instance.InstanceType;
import dev.engine_room.flywheel.lib.instance.ColoredLitInstance;
import dev.engine_room.flywheel.lib.instance.ColoredLitOverlayInstance;
import net.createmod.catnip.render.SpriteShiftEntry;
import net.minecraft.core.Vec3i;
public class ScrollInstance extends ColoredLitInstance {
public class ScrollInstance extends ColoredLitOverlayInstance {
public float x;
public float y;
public float z;
@ -27,7 +27,7 @@ public class ScrollInstance extends ColoredLitInstance {
public float scaleU;
public float scaleV;
public ScrollInstance(InstanceType<? extends ColoredLitInstance> type, InstanceHandle handle) {
public ScrollInstance(InstanceType<? extends ColoredLitOverlayInstance> type, InstanceHandle handle) {
super(type, handle);
}

View file

@ -2,7 +2,7 @@ package com.simibubi.create.content.redstone.analogLever;
import java.util.List;
import com.simibubi.create.content.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.api.equipment.goggles.IHaveGoggleInformation;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import com.simibubi.create.foundation.utility.CreateLang;

View file

@ -3,10 +3,13 @@ package com.simibubi.create.content.redstone.link.controller;
import java.util.List;
import java.util.UUID;
import com.simibubi.create.AllDataComponents;
import com.simibubi.create.AllItems;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.foundation.blockEntity.SmartBlockEntity;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import net.createmod.catnip.codecs.CatnipCodecUtils;
import net.createmod.catnip.platform.CatnipServices;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
@ -20,16 +23,17 @@ import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.ItemContainerContents;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
public class LecternControllerBlockEntity extends SmartBlockEntity {
private ItemStack controller = ItemStack.EMPTY;
private ItemContainerContents controllerData = ItemContainerContents.EMPTY;
private UUID user;
private UUID prevUser; // used only on client
private boolean deactivatedThisTick; // used only on server
@ -44,7 +48,7 @@ public class LecternControllerBlockEntity extends SmartBlockEntity {
@Override
protected void write(CompoundTag compound, HolderLookup.Provider registries, boolean clientPacket) {
super.write(compound, registries, clientPacket);
compound.put("Controller", controller.saveOptional(registries));
compound.put("ControllerData", CatnipCodecUtils.encode(ItemContainerContents.CODEC, controllerData).orElseThrow());
if (user != null)
compound.putUUID("User", user);
}
@ -52,18 +56,20 @@ public class LecternControllerBlockEntity extends SmartBlockEntity {
@Override
public void writeSafe(CompoundTag compound, HolderLookup.Provider registries) {
super.writeSafe(compound, registries);
compound.put("Controller", controller.saveOptional(registries));
compound.put("ControllerData", CatnipCodecUtils.encode(ItemContainerContents.CODEC, controllerData).orElseThrow());
}
@Override
protected void read(CompoundTag compound, HolderLookup.Provider registries, boolean clientPacket) {
super.read(compound, registries, clientPacket);
controller = ItemStack.parseOptional(registries, compound.getCompound("Controller"));
controllerData = CatnipCodecUtils.decode(ItemContainerContents.CODEC, compound.getCompound("ControllerData"))
.orElse(ItemContainerContents.EMPTY);
user = compound.hasUUID("User") ? compound.getUUID("User") : null;
}
public ItemStack getController() {
return controller;
return getController();
}
public boolean hasUser() { return user != null; }
@ -139,8 +145,8 @@ public class LecternControllerBlockEntity extends SmartBlockEntity {
}
public void setController(ItemStack newController) {
controller = newController;
if (newController != null) {
controllerData = newController.getOrDefault(AllDataComponents.LINKED_CONTROLLER_ITEMS, ItemContainerContents.EMPTY);
AllSoundEvents.CONTROLLER_PUT.playOnServer(level, worldPosition);
}
}
@ -149,7 +155,7 @@ public class LecternControllerBlockEntity extends SmartBlockEntity {
ItemStack newController = stack.copy();
stack.setCount(0);
if (player.getItemInHand(hand).isEmpty()) {
player.setItemInHand(hand, controller);
player.setItemInHand(hand, createLinkedController());
} else {
dropController(state);
}
@ -165,10 +171,10 @@ public class LecternControllerBlockEntity extends SmartBlockEntity {
double x = worldPosition.getX() + 0.5 + 0.25 * dir.getStepX();
double y = worldPosition.getY() + 1;
double z = worldPosition.getZ() + 0.5 + 0.25 * dir.getStepZ();
ItemEntity itementity = new ItemEntity(level, x, y, z, controller.copy());
ItemEntity itementity = new ItemEntity(level, x, y, z, createLinkedController());
itementity.setDefaultPickUpDelay();
level.addFreshEntity(itementity);
controller = null;
controllerData = ItemContainerContents.EMPTY;
}
public static boolean playerInRange(Player player, Level world, BlockPos pos) {
@ -177,4 +183,9 @@ public class LecternControllerBlockEntity extends SmartBlockEntity {
return player.distanceToSqr(Vec3.atCenterOf(pos)) < reach * reach;
}
private ItemStack createLinkedController() {
ItemStack stack = AllItems.LINKED_CONTROLLER.asStack();
stack.set(AllDataComponents.LINKED_CONTROLLER_ITEMS, controllerData);
return stack;
}
}

View file

@ -86,7 +86,7 @@ public class NixieTubeRenderer extends SafeBlockEntityRenderer<NixieTubeBlockEnt
float charWidth = fontRenderer.width(c);
float shadowOffset = .5f;
float flicker = r.nextFloat();
Couple<Integer> couple = DyeHelper.DYE_TABLE.get(color);
Couple<Integer> couple = DyeHelper.getDyeColors(color);
int brightColor = couple.getFirst();
int darkColor = couple.getSecond();
int flickeringBrightColor = Color.mixColors(brightColor, darkColor, flicker / 4);

View file

@ -5,9 +5,7 @@ import java.util.function.Consumer;
import org.jetbrains.annotations.Nullable;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllPartialModels;
import com.simibubi.create.content.kinetics.simpleRelays.ShaftBlock;
import dev.engine_room.flywheel.api.instance.Instance;
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
@ -15,7 +13,6 @@ import dev.engine_room.flywheel.lib.instance.InstanceTypes;
import dev.engine_room.flywheel.lib.instance.TransformedInstance;
import dev.engine_room.flywheel.lib.model.Models;
import net.createmod.catnip.math.AngleHelper;
import net.createmod.ponder.render.VirtualRenderHelper;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
@ -25,10 +22,10 @@ public class StandardBogeyVisual implements BogeyVisual {
public StandardBogeyVisual(VisualizationContext ctx, float partialTick, boolean inContraption) {
var shaftInstancer = ctx.instancerProvider()
.instancer(InstanceTypes.TRANSFORMED, VirtualRenderHelper.blockModel(AllBlocks.SHAFT.getDefaultState()
.setValue(ShaftBlock.AXIS, Direction.Axis.Z)));
shaft1 = shaftInstancer.createInstance();
shaft2 = shaftInstancer.createInstance();
.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.SHAFT));
shaft1 = shaftInstancer.createInstance().rotateToFace(Direction.SOUTH);
shaft2 = shaftInstancer.createInstance().rotateToFace(Direction.SOUTH);
}
@Override
@ -147,10 +144,9 @@ public class StandardBogeyVisual implements BogeyVisual {
public Large(VisualizationContext ctx, float partialTick, boolean inContraption) {
super(ctx, partialTick, inContraption);
var secondaryShaftInstancer = ctx.instancerProvider()
.instancer(InstanceTypes.TRANSFORMED, VirtualRenderHelper.blockModel(AllBlocks.SHAFT.getDefaultState()
.setValue(ShaftBlock.AXIS, Direction.Axis.X)));
secondaryShaft1 = secondaryShaftInstancer.createInstance();
secondaryShaft2 = secondaryShaftInstancer.createInstance();
.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.SHAFT));
secondaryShaft1 = secondaryShaftInstancer.createInstance().rotateToFace(Direction.EAST);
secondaryShaft2 = secondaryShaftInstancer.createInstance().rotateToFace(Direction.EAST);
drive = ctx.instancerProvider()
.instancer(InstanceTypes.TRANSFORMED, Models.partial(AllPartialModels.BOGEY_DRIVE))
.createInstance();

View file

@ -319,7 +319,7 @@ public class FlapDisplayBlockEntity extends KineticBlockEntity {
public int getLineColor(int line) {
DyeColor color = colour[line];
return color == null ? 0xFF_D3C6BA
: DyeHelper.DYE_TABLE.get(color)
: DyeHelper.getDyeColors(color)
.getFirst() | 0xFF_000000;
}

View file

@ -7,6 +7,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import com.simibubi.create.api.contraption.train.TrainConductorHandler;
import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.AllBlocks;
@ -16,8 +18,6 @@ import com.simibubi.create.content.contraptions.ContraptionType;
import com.simibubi.create.content.contraptions.MountedStorageManager;
import com.simibubi.create.content.contraptions.actors.trainControls.ControlsBlock;
import com.simibubi.create.content.contraptions.minecart.TrainCargoManager;
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock.HeatLevel;
import com.simibubi.create.content.trains.bogey.AbstractBogeyBlock;
import com.simibubi.create.foundation.utility.CreateLang;
@ -46,7 +46,7 @@ public class CarriageContraption extends Contraption {
private boolean forwardControls;
private boolean backwardControls;
public Couple<Boolean> blazeBurnerConductors;
public Couple<Boolean> blockConductors;
public Map<BlockPos, Couple<Boolean>> conductorSeats;
public ArrivalSoundQueue soundQueue;
@ -56,7 +56,7 @@ public class CarriageContraption extends Contraption {
private int bogeys;
private boolean sidewaysControls;
private BlockPos secondBogeyPos;
private List<BlockPos> assembledBlazeBurners;
private List<BlockPos> assembledBlockConductors;
// render
public int portalCutoffMin;
@ -71,8 +71,8 @@ public class CarriageContraption extends Contraption {
public CarriageContraption() {
conductorSeats = new HashMap<>();
assembledBlazeBurners = new ArrayList<>();
blazeBurnerConductors = Couple.create(false, false);
assembledBlockConductors = new ArrayList<>();
blockConductors = Couple.create(false, false);
soundQueue = new ArrivalSoundQueue();
portalCutoffMin = Integer.MIN_VALUE;
portalCutoffMax = Integer.MAX_VALUE;
@ -102,10 +102,10 @@ public class CarriageContraption extends Contraption {
if (sidewaysControls)
throw new AssemblyException(CreateLang.translateDirect("train_assembly.sideways_controls"));
for (BlockPos blazePos : assembledBlazeBurners)
for (BlockPos blazePos : assembledBlockConductors)
for (Direction direction : Iterate.directionsInAxis(assemblyDirection.getAxis()))
if (inControl(blazePos, direction))
blazeBurnerConductors.set(direction != assemblyDirection, true);
blockConductors.set(direction != assemblyDirection, true);
for (BlockPos seatPos : getSeats())
for (Direction direction : Iterate.directionsInAxis(assemblyDirection.getAxis()))
if (inControl(seatPos, direction))
@ -166,9 +166,8 @@ public class CarriageContraption extends Contraption {
captureBE ? world.getBlockEntity(pos) : null);
}
if (AllBlocks.BLAZE_BURNER.has(blockState)
&& blockState.getValue(BlazeBurnerBlock.HEAT_LEVEL) != HeatLevel.NONE)
assembledBlazeBurners.add(toLocalPos(pos));
if (TrainConductorHandler.CONDUCTOR_HANDLERS.stream().anyMatch(handler -> handler.isValidConductor(blockState)))
assembledBlockConductors.add(toLocalPos(pos));
if (AllBlocks.TRAIN_CONTROLS.has(blockState)) {
Direction facing = blockState.getValue(ControlsBlock.FACING);
@ -192,8 +191,8 @@ public class CarriageContraption extends Contraption {
NBTHelper.writeEnum(tag, "AssemblyDirection", getAssemblyDirection());
tag.putBoolean("FrontControls", forwardControls);
tag.putBoolean("BackControls", backwardControls);
tag.putBoolean("FrontBlazeConductor", blazeBurnerConductors.getFirst());
tag.putBoolean("BackBlazeConductor", blazeBurnerConductors.getSecond());
tag.putBoolean("FrontBlazeConductor", blockConductors.getFirst());
tag.putBoolean("BackBlazeConductor", blockConductors.getSecond());
ListTag list = NBTHelper.writeCompoundList(conductorSeats.entrySet(), e -> {
CompoundTag compoundTag = new CompoundTag();
compoundTag.put("Pos", NbtUtils.writeBlockPos(e.getKey()));
@ -213,7 +212,7 @@ public class CarriageContraption extends Contraption {
assemblyDirection = NBTHelper.readEnum(nbt, "AssemblyDirection", Direction.class);
forwardControls = nbt.getBoolean("FrontControls");
backwardControls = nbt.getBoolean("BackControls");
blazeBurnerConductors =
blockConductors =
Couple.create(nbt.getBoolean("FrontBlazeConductor"), nbt.getBoolean("BackBlazeConductor"));
conductorSeats.clear();
NBTHelper.iterateCompoundList(nbt.getList("ConductorSeats", Tag.TAG_COMPOUND),

View file

@ -492,8 +492,8 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
if (!(contraption instanceof CarriageContraption cc))
return sides;
sides.setFirst(cc.blazeBurnerConductors.getFirst());
sides.setSecond(cc.blazeBurnerConductors.getSecond());
sides.setFirst(cc.blockConductors.getFirst());
sides.setSecond(cc.blockConductors.getSecond());
for (Entity entity : getPassengers()) {
if (entity instanceof Player)

View file

@ -6,8 +6,8 @@ import com.simibubi.create.compat.Mods;
import com.simibubi.create.content.contraptions.glue.SuperGlueEntity;
import com.simibubi.create.foundation.utility.AttachedRegistry;
import net.createmod.catnip.math.BlockFace;
import net.createmod.catnip.data.Pair;
import net.createmod.catnip.math.BlockFace;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
@ -19,44 +19,95 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.NetherPortalBlock;
import net.minecraft.world.level.block.Portal;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.portal.DimensionTransition;
import net.minecraft.world.phys.AABB;
/**
* Manages portal track integrations for various dimensions and mods within the Create mod.
* <p>
* Portals must be entered from the side and must lead to a different dimension than the one entered from.
* This class handles the registration and functionality of portal tracks for standard and modded portals.
* </p>
*/
public class AllPortalTracks {
/**
* Functional interface representing a provider for portal track connections.
* It takes a pair of {@link ServerLevel} and {@link BlockFace} representing the inbound track
* and returns a similar pair for the outbound track.
*/
@FunctionalInterface
public interface PortalTrackProvider extends UnaryOperator<Pair<ServerLevel, BlockFace>> {}
// Portals must be entered from the side and must lead to a different dimension
// than the one entered from
@FunctionalInterface public interface PortalTrackProvider extends UnaryOperator<Pair<ServerLevel, BlockFace>> {}
/**
* Registry mapping portal blocks to their respective {@link PortalTrackProvider}s.
*/
private static final AttachedRegistry<Block, PortalTrackProvider> PORTAL_BEHAVIOURS =
new AttachedRegistry<>(BuiltInRegistries.BLOCK);
new AttachedRegistry<>(BuiltInRegistries.BLOCK);
/**
* Registers a portal track integration for a given block identified by its {@link ResourceLocation}.
*
* @param block The resource location of the portal block.
* @param provider The portal track provider for the block.
*/
public static void registerIntegration(ResourceLocation block, PortalTrackProvider provider) {
PORTAL_BEHAVIOURS.register(block, provider);
}
/**
* Registers a portal track integration for a given {@link Block}.
*
* @param block The portal block.
* @param provider The portal track provider for the block.
*/
public static void registerIntegration(Block block, PortalTrackProvider provider) {
PORTAL_BEHAVIOURS.register(block, provider);
}
private static void registerIntegration(Mods mod, String blockId, PortalTrackProvider provider) {
if (mod.isLoaded())
PORTAL_BEHAVIOURS.register(mod.rl(blockId), provider);
private static void registerSimpleInteraction(Mods mod, String dimensionId, String portalBlockId) {
ResourceKey<Level> levelKey = ResourceKey.create(Registries.DIMENSION, mod.rl(dimensionId));
registerSimpleInteraction(mod, levelKey, portalBlockId);
}
private static void registerSimpleInteraction(Mods mod, ResourceKey<Level> levelKey, String portalBlockId) {
if (mod.isLoaded())
registerSimpleInteraction(levelKey, asPortal(mod.rl(portalBlockId)));
}
private static void registerSimpleInteraction(ResourceKey<Level> levelKey, Portal portalBlock) {
PortalTrackProvider p = i ->
standardPortalProvider(i, Level.OVERWORLD, levelKey, portalBlock);
PORTAL_BEHAVIOURS.register((Block) portalBlock, p);
}
/**
* Checks if a given {@link BlockState} represents a supported portal block.
*
* @param state The block state to check.
* @return {@code true} if the block state represents a supported portal; {@code false} otherwise.
*/
public static boolean isSupportedPortal(BlockState state) {
return PORTAL_BEHAVIOURS.get(state.getBlock()) != null;
}
/**
* Grabs a block from the registry as a {@link Portal} block
*/
public static Portal asPortal(ResourceLocation block) {
return (Portal) BuiltInRegistries.BLOCK.get(block);
}
/**
* Retrieves the corresponding outbound track on the other side of a portal.
*
* @param level The current {@link ServerLevel}.
* @param inboundTrack The inbound track {@link BlockFace}.
* @return A pair containing the target {@link ServerLevel} and outbound {@link BlockFace},
* or {@code null} if no corresponding portal is found.
*/
public static Pair<ServerLevel, BlockFace> getOtherSide(ServerLevel level, BlockFace inboundTrack) {
BlockPos portalPos = inboundTrack.getConnectedPos();
BlockState portalState = level.getBlockState(portalPos);
@ -64,37 +115,41 @@ public class AllPortalTracks {
return provider == null ? null : provider.apply(Pair.of(level, inboundTrack));
}
// Builtin handlers
// Built-in handlers
/**
* Registers default portal track integrations for built-in dimensions and mods.
* This includes the Nether, the Aether (if loaded) and the end (if betterend is loaded).
*/
public static void registerDefaults() {
registerIntegration(Blocks.NETHER_PORTAL, AllPortalTracks::nether);
registerIntegration(Mods.AETHER, "aether_portal", AllPortalTracks::aether);
registerIntegration(Mods.AETHER_II, "aether_portal", AllPortalTracks::aetherII);
registerSimpleInteraction(Level.NETHER, (Portal) Blocks.NETHER_PORTAL);
registerSimpleInteraction(Mods.AETHER, "the_aether", "aether_portal");
registerSimpleInteraction(Mods.AETHER_II, "aether_highlands", "aether_portal");
registerSimpleInteraction(Mods.BETTEREND, Level.END, "end_portal_block");
}
private static Pair<ServerLevel, BlockFace> nether(Pair<ServerLevel, BlockFace> inbound) {
return standardPortalProvider(inbound, Level.OVERWORLD, Level.NETHER, (NetherPortalBlock) Blocks.NETHER_PORTAL);
}
private static Pair<ServerLevel, BlockFace> aether(Pair<ServerLevel, BlockFace> inbound) {
ResourceKey<Level> aetherLevelKey = ResourceKey.create(Registries.DIMENSION, Mods.AETHER.rl("the_aether"));
return standardPortalProvider(inbound, Level.OVERWORLD, aetherLevelKey, asPortal(Mods.AETHER.rl("aether_portal")));
}
private static Pair<ServerLevel, BlockFace> aetherII(Pair<ServerLevel, BlockFace> inbound) {
ResourceKey<Level> aetherLevelKey = ResourceKey.create(Registries.DIMENSION, Mods.AETHER_II.rl("aether_highlands"));
return standardPortalProvider(inbound, Level.OVERWORLD, aetherLevelKey, asPortal(Mods.AETHER_II.rl("aether_portal")));
}
public static Pair<ServerLevel, BlockFace> standardPortalProvider(Pair<ServerLevel, BlockFace> inbound,
ResourceKey<Level> firstDimension, ResourceKey<Level> secondDimension,
Portal portal) {
/**
* Generalized portal provider method that calculates the corresponding outbound track across a portal.
*
* @param inbound A pair containing the current {@link ServerLevel} and inbound {@link BlockFace}.
* @param firstDimension The first dimension.
* @param secondDimension The second dimension.
* @param portal The portal block
* @return A pair with the target {@link ServerLevel} and outbound {@link BlockFace}, or {@code null} if not applicable.
*/
public static Pair<ServerLevel, BlockFace> standardPortalProvider(
Pair<ServerLevel, BlockFace> inbound,
ResourceKey<Level> firstDimension,
ResourceKey<Level> secondDimension,
Portal portal
) {
ServerLevel level = inbound.getFirst();
ResourceKey<Level> resourcekey = level.dimension() == secondDimension ? firstDimension : secondDimension;
MinecraftServer minecraftserver = level.getServer();
ServerLevel otherLevel = minecraftserver.getLevel(resourcekey);
ResourceKey<Level> resourceKey = level.dimension() == secondDimension ? firstDimension : secondDimension;
if (otherLevel == null || !minecraftserver.isLevelEnabled(otherLevel))
MinecraftServer minecraftServer = level.getServer();
ServerLevel otherLevel = minecraftServer.getLevel(resourceKey);
if (otherLevel == null)
return null;
BlockFace inboundTrack = inbound.getSecond();
@ -102,16 +157,18 @@ public class AllPortalTracks {
BlockState portalState = level.getBlockState(portalPos);
SuperGlueEntity probe = new SuperGlueEntity(level, new AABB(portalPos));
probe.setYRot(inboundTrack.getFace()
.toYRot());
probe.setYRot(inboundTrack.getFace().toYRot());
DimensionTransition dimensiontransition = portal.getPortalDestination(level, probe, probe.blockPosition());
if (dimensiontransition == null)
return null;
if (!minecraftServer.isLevelEnabled(dimensiontransition.newLevel()))
return null;
BlockPos otherPortalPos = BlockPos.containing(dimensiontransition.pos());
BlockState otherPortalState = otherLevel.getBlockState(otherPortalPos);
if (otherPortalState.getBlock() != portalState.getBlock())
if (!otherPortalState.is(portalState.getBlock()))
return null;
Direction targetDirection = inboundTrack.getFace();
@ -120,5 +177,4 @@ public class AllPortalTracks {
BlockPos otherPos = otherPortalPos.relative(targetDirection);
return Pair.of(otherLevel, new BlockFace(otherPos, targetDirection.getOpposite()));
}
}

View file

@ -7,6 +7,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;
import net.minecraft.tags.ItemTags;
import org.apache.commons.lang3.ArrayUtils;
import com.simibubi.create.foundation.data.TagGen;
@ -138,7 +140,13 @@ public class CopperBlockSet {
.simpleItem();
if (variant == BlockVariant.INSTANCE && state == WeatherState.UNAFFECTED)
builder.recipe((c, p) -> mainBlockRecipe.accept(c, p));
builder.recipe(mainBlockRecipe::accept);
if (variant == StairVariant.INSTANCE)
builder.tag(BlockTags.STAIRS);
if (variant == SlabVariant.INSTANCE)
builder.tag(BlockTags.SLABS);
if (waxed) {
builder.recipe((ctx, prov) -> {

View file

@ -69,6 +69,7 @@ import net.minecraft.data.recipes.ShapelessRecipeBuilder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.level.ItemLike;
@ -498,13 +499,15 @@ public class BuilderTransformers {
public static <B extends Block, P> NonNullUnaryOperator<BlockBuilder<B, P>> tableCloth(String name,
NonNullSupplier<? extends Block> initialProps, boolean dyed) {
return b -> {
TagKey<Block> soundTag = dyed ? BlockTags.COMBINATION_STEP_SOUND_BLOCKS : BlockTags.INSIDE_STEP_SOUND_BLOCKS;
ItemBuilder<TableClothBlockItem, BlockBuilder<B, P>> item = b.initialProperties(initialProps)
.addLayer(() -> RenderType::cutoutMipped)
.blockstate((c, p) -> p.simpleBlock(c.get(), p.models()
.withExistingParent(name + "_table_cloth", p.modLoc("block/table_cloth/block"))
.texture("0", p.modLoc("block/table_cloth/" + name))))
.onRegister(CreateRegistrate.blockModel(() -> TableClothModel::new))
.tag(AllBlockTags.TABLE_CLOTHS.tag)
.tag(AllBlockTags.TABLE_CLOTHS.tag, soundTag)
.onRegisterAfter(Registries.ITEM, v -> ItemDescription.useKey(v, "block.create.table_cloth"))
.item(TableClothBlockItem::new);

View file

@ -186,29 +186,30 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
/* Fluids */
public <T extends BaseFlowingFluid> FluidBuilder<T, CreateRegistrate> virtualFluid(String name,
FluidBuilder.FluidTypeFactory typeFactory, NonNullFunction<BaseFlowingFluid.Properties, T> factory) {
FluidBuilder.FluidTypeFactory typeFactory, NonNullFunction<BaseFlowingFluid.Properties, T> sourceFactory,
NonNullFunction<BaseFlowingFluid.Properties, T> flowingFactory) {
return entry(name,
c -> new VirtualFluidBuilder<>(self(), self(), name, c, ResourceLocation.fromNamespaceAndPath(getModid(), "fluid/" + name + "_still"),
ResourceLocation.fromNamespaceAndPath(getModid(), "fluid/" + name + "_flow"), typeFactory, factory));
ResourceLocation.fromNamespaceAndPath(getModid(), "fluid/" + name + "_flow"), typeFactory, sourceFactory, flowingFactory));
}
public <T extends BaseFlowingFluid> FluidBuilder<T, CreateRegistrate> virtualFluid(String name,
ResourceLocation still, ResourceLocation flow, FluidBuilder.FluidTypeFactory typeFactory,
NonNullFunction<BaseFlowingFluid.Properties, T> factory) {
return entry(name, c -> new VirtualFluidBuilder<>(self(), self(), name, c, still, flow, typeFactory, factory));
NonNullFunction<BaseFlowingFluid.Properties, T> sourceFactory, NonNullFunction<BaseFlowingFluid.Properties, T> flowingFactory) {
return entry(name, c -> new VirtualFluidBuilder<>(self(), self(), name, c, still, flow, typeFactory, sourceFactory, flowingFactory));
}
public FluidBuilder<VirtualFluid, CreateRegistrate> virtualFluid(String name) {
return entry(name,
c -> new VirtualFluidBuilder<VirtualFluid, CreateRegistrate>(self(), self(), name, c,
ResourceLocation.fromNamespaceAndPath(getModid(), "fluid/" + name + "_still"), ResourceLocation.fromNamespaceAndPath(getModid(), "fluid/" + name + "_flow"),
CreateRegistrate::defaultFluidType, VirtualFluid::new));
CreateRegistrate::defaultFluidType, VirtualFluid::createSource, VirtualFluid::createFlowing));
}
public FluidBuilder<VirtualFluid, CreateRegistrate> virtualFluid(String name, ResourceLocation still,
ResourceLocation flow) {
return entry(name, c -> new VirtualFluidBuilder<>(self(), self(), name, c, still, flow,
CreateRegistrate::defaultFluidType, VirtualFluid::new));
CreateRegistrate::defaultFluidType, VirtualFluid::createSource, VirtualFluid::createFlowing));
}
public FluidBuilder<BaseFlowingFluid.Flowing, CreateRegistrate> standardFluid(String name) {

View file

@ -17,9 +17,11 @@ public class VirtualFluidBuilder<T extends BaseFlowingFluid, P> extends FluidBui
public VirtualFluidBuilder(AbstractRegistrate<?> owner, P parent, String name, BuilderCallback callback,
ResourceLocation stillTexture, ResourceLocation flowingTexture, FluidBuilder.FluidTypeFactory typeFactory,
NonNullFunction<Properties, T> factory) {
super(owner, parent, name, callback, stillTexture, flowingTexture, typeFactory, factory);
source(factory);
NonNullFunction<Properties, T> sourceFactory,
NonNullFunction<Properties, T> flowingFactory
) {
super(owner, parent, name, callback, stillTexture, flowingTexture, typeFactory, flowingFactory);
source(sourceFactory);
}
@Override

View file

@ -63,8 +63,7 @@ public class MillingRecipeGen extends ProcessingRecipeGen {
CACTUS = create(() -> Blocks.CACTUS, b -> b.duration(50)
.output(Items.GREEN_DYE, 2)
.output(.1f, Items.GREEN_DYE, 1)
.whenModMissing("quark")),
.output(.1f, Items.GREEN_DYE, 1)),
SEA_PICKLE = create(() -> Blocks.SEA_PICKLE, b -> b.duration(50)
.output(Items.LIME_DYE, 2)

View file

@ -17,7 +17,7 @@ public class PressingRecipeGen extends ProcessingRecipeGen {
SUGAR_CANE = create(() -> Items.SUGAR_CANE, b -> b.output(Items.PAPER)),
PATH = create("path", b -> b.require(Ingredient.of(Items.GRASS_BLOCK, Items.DIRT))
PATH = create("path", b -> b.require(Ingredient.of(Items.GRASS_BLOCK, Items.DIRT, Items.COARSE_DIRT, Items.ROOTED_DIRT))
.output(Items.DIRT_PATH)),
IRON = create("iron_ingot", b -> b.require(I.iron())

View file

@ -10,6 +10,7 @@ import javax.annotation.Nullable;
import org.apache.commons.lang3.mutable.MutableInt;
import com.simibubi.create.content.logistics.box.PackageEntity;
import com.simibubi.create.foundation.block.IBE;
import com.simibubi.create.foundation.mixin.accessor.ItemStackHandlerAccessor;
import net.createmod.catnip.data.Pair;
@ -24,7 +25,9 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.ItemContainerContents;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.neoforged.neoforge.capabilities.Capabilities.ItemHandler;
import net.neoforged.neoforge.items.IItemHandler;
import net.neoforged.neoforge.items.IItemHandlerModifiable;
import net.neoforged.neoforge.items.ItemStackHandler;
@ -81,6 +84,13 @@ public class ItemHelper {
return true;
}
public static <T extends IBE<? extends BlockEntity>> int calcRedstoneFromBlockEntity(T ibe, Level level, BlockPos pos) {
return ibe.getBlockEntityOptional(level, pos)
.map(be -> level.getCapability(ItemHandler.BLOCK, pos, null))
.map(ItemHelper::calcRedstoneFromInventory)
.orElse(0);
}
public static int calcRedstoneFromInventory(@Nullable IItemHandler inv) {
if (inv == null)
return 0;

View file

@ -5,12 +5,15 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.advancement.AllAdvancements;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.SmithingMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.ItemEnchantments;
@Mixin(SmithingMenu.class)
public class SmithingMenuMixin {
@ -23,4 +26,23 @@ public class SmithingMenuMixin {
AllAdvancements.CARDBOARD_ARMOR_TRIM.awardTo(player);
}
}
// Only add enchantments to the backtank if it supports them
@ModifyExpressionValue(
method = "createResult",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/item/crafting/SmithingRecipe;assemble(Lnet/minecraft/world/item/crafting/RecipeInput;Lnet/minecraft/core/HolderLookup$Provider;)Lnet/minecraft/world/item/ItemStack;"
)
)
private ItemStack create$preventUnbreakingOnBacktanks(ItemStack original) {
if (AllItems.COPPER_BACKTANK.is(original) || AllItems.NETHERITE_BACKTANK.is(original)) {
ItemEnchantments.Mutable mutableEnchantments =
new ItemEnchantments.Mutable(original.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY));
mutableEnchantments.removeIf(enchant -> !original.supportsEnchantment(enchant));
original.set(DataComponents.ENCHANTMENTS, mutableEnchantments.toImmutable());
}
return original;
}
}

View file

@ -56,6 +56,8 @@ import net.minecraft.world.level.block.SlimeBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.state.properties.SlabType;
import net.minecraft.world.level.chunk.LevelChunk;
@ -68,6 +70,24 @@ import net.neoforged.neoforge.event.level.BlockDropsEvent;
import net.neoforged.neoforge.event.level.BlockEvent;
public class BlockHelper {
private static final List<IntegerProperty> COUNT_STATES = List.of(
BlockStateProperties.EGGS,
BlockStateProperties.PICKLES,
BlockStateProperties.CANDLES
);
private static final List<Block> VINELIKE_BLOCKS = List.of(
Blocks.VINE, Blocks.GLOW_LICHEN
);
private static final List<BooleanProperty> VINELIKE_STATES = List.of(
BlockStateProperties.UP,
BlockStateProperties.NORTH,
BlockStateProperties.EAST,
BlockStateProperties.SOUTH,
BlockStateProperties.WEST,
BlockStateProperties.DOWN
);
public static BlockState setZeroAge(BlockState blockState) {
if (blockState.hasProperty(BlockStateProperties.AGE_1))
@ -109,11 +129,21 @@ public class BlockHelper {
if (needsTwo)
amount *= 2;
if (block.hasProperty(BlockStateProperties.EGGS))
amount *= block.getValue(BlockStateProperties.EGGS);
for (IntegerProperty property : COUNT_STATES)
if (block.hasProperty(property))
amount *= block.getValue(property);
if (block.hasProperty(BlockStateProperties.PICKLES))
amount *= block.getValue(BlockStateProperties.PICKLES);
if (VINELIKE_BLOCKS.contains(block.getBlock())) {
int vineCount = 0;
for (BooleanProperty vineState : VINELIKE_STATES) {
if (block.hasProperty(vineState) && block.getValue(vineState)) {
vineCount++;
}
}
amount += vineCount - 1;
}
{
// Try held Item first

View file

@ -1,8 +1,8 @@
package com.simibubi.create.foundation.utility;
import java.util.HashMap;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import java.util.function.Supplier;
import net.createmod.catnip.data.Couple;
import net.minecraft.world.item.DyeColor;
@ -12,49 +12,53 @@ import net.minecraft.world.level.block.Blocks;
public class DyeHelper {
public static ItemLike getWoolOfDye(DyeColor color) {
return switch (color) {
case BLACK -> Blocks.BLACK_WOOL;
case BLUE -> Blocks.BLUE_WOOL;
case BROWN -> Blocks.BROWN_WOOL;
case CYAN -> Blocks.CYAN_WOOL;
case GRAY -> Blocks.GRAY_WOOL;
case GREEN -> Blocks.GREEN_WOOL;
case LIGHT_BLUE -> Blocks.LIGHT_BLUE_WOOL;
case LIGHT_GRAY -> Blocks.LIGHT_GRAY_WOOL;
case LIME -> Blocks.LIME_WOOL;
case MAGENTA -> Blocks.MAGENTA_WOOL;
case ORANGE -> Blocks.ORANGE_WOOL;
case PINK -> Blocks.PINK_WOOL;
case PURPLE -> Blocks.PURPLE_WOOL;
case RED -> Blocks.RED_WOOL;
case YELLOW -> Blocks.YELLOW_WOOL;
default -> Blocks.WHITE_WOOL;
};
return WOOL_TABLE.getOrDefault(color, () -> Blocks.WHITE_WOOL).get();
}
public static final Map<DyeColor, Couple<Integer>> DYE_TABLE = new ImmutableMap.Builder<DyeColor, Couple<Integer>>()
public static Couple<Integer> getDyeColors(DyeColor color){
return DYE_TABLE.getOrDefault(color, DYE_TABLE.get(DyeColor.WHITE));
}
// DyeColor, ( Front RGB, Back RGB )
.put(DyeColor.BLACK, Couple.create(0x45403B, 0x21201F))
.put(DyeColor.RED, Couple.create(0xB13937, 0x632737))
.put(DyeColor.GREEN, Couple.create(0x208A46, 0x1D6045))
.put(DyeColor.BROWN, Couple.create(0xAC855C, 0x68533E))
/**
* Adds a dye color s.t. Create's blocks can use it instead of defaulting to white.
* @param color Dye color to add
* @param brightColor Front (bright) RGB color
* @param darkColor Back (dark) RGB color
* @param wool Supplier of wool item/block corresponding to the color
*/
public static void addDye(DyeColor color, Integer brightColor, Integer darkColor, Supplier<ItemLike> wool){
DYE_TABLE.put(color, Couple.create(brightColor, darkColor));
WOOL_TABLE.put(color, wool);
}
.put(DyeColor.BLUE, Couple.create(0x5391E1, 0x504B90))
.put(DyeColor.GRAY, Couple.create(0x5D666F, 0x313538))
.put(DyeColor.LIGHT_GRAY, Couple.create(0x95969B, 0x707070))
.put(DyeColor.PURPLE, Couple.create(0x9F54AE, 0x63366C))
private static void addDye(DyeColor color, Integer brightColor, Integer darkColor, ItemLike wool){
addDye(color, brightColor, darkColor, () -> wool);
}
.put(DyeColor.CYAN, Couple.create(0x3EABB4, 0x3C7872))
.put(DyeColor.PINK, Couple.create(0xD5A8CB, 0xB86B95))
.put(DyeColor.LIME, Couple.create(0xA3DF55, 0x4FB16F))
.put(DyeColor.YELLOW, Couple.create(0xE6D756, 0xE9AC29))
private static final Map<DyeColor, Supplier<ItemLike>> WOOL_TABLE = new HashMap<>();
.put(DyeColor.LIGHT_BLUE, Couple.create(0x69CED2, 0x508AA5))
.put(DyeColor.ORANGE, Couple.create(0xEE9246, 0xD94927))
.put(DyeColor.MAGENTA, Couple.create(0xF062B0, 0xC04488))
.put(DyeColor.WHITE, Couple.create(0xEDEAE5, 0xBBB6B0))
private static final Map<DyeColor, Couple<Integer>> DYE_TABLE = new HashMap<>();
.build();
static {
// DyeColor, ( Front RGB, Back RGB )
addDye(DyeColor.BLACK, 0x45403B, 0x21201F, Blocks.BLACK_WOOL);
addDye(DyeColor.RED, 0xB13937, 0x632737, Blocks.RED_WOOL);
addDye(DyeColor.GREEN, 0x208A46, 0x1D6045, Blocks.GREEN_WOOL);
addDye(DyeColor.BROWN, 0xAC855C, 0x68533E, Blocks.BROWN_WOOL);
addDye(DyeColor.BLUE, 0x5391E1, 0x504B90, Blocks.BLUE_WOOL);
addDye(DyeColor.GRAY, 0x5D666F, 0x313538, Blocks.GRAY_WOOL);
addDye(DyeColor.LIGHT_GRAY, 0x95969B, 0x707070, Blocks.LIGHT_GRAY_WOOL);
addDye(DyeColor.PURPLE, 0x9F54AE, 0x63366C, Blocks.PURPLE_WOOL);
addDye(DyeColor.CYAN, 0x3EABB4, 0x3C7872, Blocks.CYAN_WOOL);
addDye(DyeColor.PINK, 0xD5A8CB, 0xB86B95, Blocks.PINK_WOOL);
addDye(DyeColor.LIME, 0xA3DF55, 0x4FB16F, Blocks.LIME_WOOL);
addDye(DyeColor.YELLOW, 0xE6D756, 0xE9AC29, Blocks.YELLOW_WOOL);
addDye(DyeColor.LIGHT_BLUE, 0x69CED2, 0x508AA5, Blocks.LIGHT_BLUE_WOOL);
addDye(DyeColor.ORANGE, 0xEE9246, 0xD94927, Blocks.ORANGE_WOOL);
addDye(DyeColor.MAGENTA, 0xF062B0, 0xC04488, Blocks.MAGENTA_WOOL);
addDye(DyeColor.WHITE, 0xEDEAE5, 0xBBB6B0, Blocks.WHITE_WOOL);
}
}

View file

@ -126,6 +126,9 @@ public class CreateRegistrateTags {
prov.tag(AllBlockTags.ROOTS.tag)
.add(Blocks.MANGROVE_ROOTS);
prov.tag(AllBlockTags.SUGAR_CANE_VARIANTS.tag)
.add(Blocks.SUGAR_CANE);
prov.tag(AllBlockTags.CORALS.tag)
.add(Blocks.DEAD_TUBE_CORAL, Blocks.DEAD_BRAIN_CORAL, Blocks.DEAD_BUBBLE_CORAL, Blocks.DEAD_FIRE_CORAL,
Blocks.DEAD_HORN_CORAL, Blocks.TUBE_CORAL, Blocks.BRAIN_CORAL, Blocks.BUBBLE_CORAL,

View file

@ -40,7 +40,7 @@ public record ServerDebugInfoPacket(String serverInfo) implements ClientboundPac
String text = output.toString();
Minecraft.getInstance().keyboardHandler.setClipboard(text);
CreateLang.translate("command.debuginfo.saved_to_clipboard")
.color(DyeHelper.DYE_TABLE.get(DyeColor.LIME)
.color(DyeHelper.getDyeColors(DyeColor.LIME)
.getFirst())
.sendChat(player);
}