Holder Holdups

- Finished work on compilation errors
This commit is contained in:
simibubi 2022-03-22 00:29:46 +01:00
parent 727b0a463e
commit 2fa65727d5
22 changed files with 188 additions and 143 deletions

View file

@ -60,7 +60,6 @@ import com.simibubi.create.foundation.item.TagDependentIngredientItem;
import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.item.TooltipHelper;
import com.tterrag.registrate.util.entry.ItemEntry; import com.tterrag.registrate.util.entry.ItemEntry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.food.FoodProperties; import net.minecraft.world.food.FoodProperties;
@ -308,7 +307,8 @@ public class AllItems {
public static final ItemEntry<SymmetryWandItem> WAND_OF_SYMMETRY = public static final ItemEntry<SymmetryWandItem> WAND_OF_SYMMETRY =
REGISTRATE.item("wand_of_symmetry", SymmetryWandItem::new) REGISTRATE.item("wand_of_symmetry", SymmetryWandItem::new)
.properties(p -> p.stacksTo(1).rarity(Rarity.UNCOMMON)) .properties(p -> p.stacksTo(1)
.rarity(Rarity.UNCOMMON))
.model(AssetLookup.itemModelWithPartials()) .model(AssetLookup.itemModelWithPartials())
.register(); .register();
@ -380,7 +380,7 @@ public class AllItems {
String metalName = metal.getName(); String metalName = metal.getName();
return REGISTRATE return REGISTRATE
.item("crushed_" + metalName + "_ore", .item("crushed_" + metalName + "_ore",
props -> new TagDependentIngredientItem(props, new ResourceLocation("forge", "ores/" + metalName))) props -> new TagDependentIngredientItem(props, AllTags.forgeItemTag("ores/" + metalName)))
.tag(CRUSHED_ORES.tag) .tag(CRUSHED_ORES.tag)
.register(); .register();
} }

View file

@ -57,7 +57,7 @@ public class AllMovementBehaviours {
addMovementBehaviour(Blocks.BELL, new BellMovementBehaviour()); addMovementBehaviour(Blocks.BELL, new BellMovementBehaviour());
addMovementBehaviour(Blocks.CAMPFIRE, new CampfireMovementBehaviour()); addMovementBehaviour(Blocks.CAMPFIRE, new CampfireMovementBehaviour());
DispenserMovementBehaviour.gatherMovedDispenseItemBehaviours(); DispenserMovementBehaviour.gatherMovedDispenseItemBehaviours();
addMovementBehaviour(Blocks.DISPENSER, new DispenserMovementBehaviour()); addMovementBehaviour(Blocks.DISPENSER, new DispenserMovementBehaviour());
addMovementBehaviour(Blocks.DROPPER, new DropperMovementBehaviour()); addMovementBehaviour(Blocks.DROPPER, new DropperMovementBehaviour());
} }

View file

@ -4,6 +4,7 @@ import static com.simibubi.create.AllTags.NameSpace.FORGE;
import static com.simibubi.create.AllTags.NameSpace.MOD; import static com.simibubi.create.AllTags.NameSpace.MOD;
import static com.simibubi.create.AllTags.NameSpace.TIC; import static com.simibubi.create.AllTags.NameSpace.TIC;
import java.util.Collections;
import java.util.function.Function; import java.util.function.Function;
import com.simibubi.create.foundation.data.CreateRegistrate; import com.simibubi.create.foundation.data.CreateRegistrate;
@ -15,8 +16,6 @@ import com.tterrag.registrate.util.nullness.NonNullFunction;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
@ -28,6 +27,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Fluids; import net.minecraft.world.level.material.Fluids;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import net.minecraftforge.registries.ForgeRegistries;
public class AllTags { public class AllTags {
@ -44,15 +44,18 @@ public class AllTags {
} }
public static TagKey<Block> forgeBlockTag(String path) { public static TagKey<Block> forgeBlockTag(String path) {
return forgeTag(BlockTags::createOptional, path); return forgeTag(r -> ForgeRegistries.BLOCKS.tags()
.createOptionalTagKey(r, Collections.emptySet()), path);
} }
public static TagKey<Item> forgeItemTag(String path) { public static TagKey<Item> forgeItemTag(String path) {
return forgeTag(ItemTags::createOptional, path); return forgeTag(r -> ForgeRegistries.ITEMS.tags()
.createOptionalTagKey(r, Collections.emptySet()), path);
} }
public static TagKey<Fluid> forgeFluidTag(String path) { public static TagKey<Fluid> forgeFluidTag(String path) {
return forgeTag(FluidTags::createOptional, path); return forgeTag(r -> ForgeRegistries.FLUIDS.tags()
.createOptionalTagKey(r, Collections.emptySet()), path);
} }
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuilder<T, P>> axeOrPickaxe() { public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, BlockBuilder<T, P>> axeOrPickaxe() {
@ -71,10 +74,10 @@ public class AllTags {
public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, ItemBuilder<BlockItem, BlockBuilder<T, P>>> tagBlockAndItem( public static <T extends Block, P> NonNullFunction<BlockBuilder<T, P>, ItemBuilder<BlockItem, BlockBuilder<T, P>>> tagBlockAndItem(
String... path) { String... path) {
return b -> { return b -> {
for (String p : path) for (String p : path)
b.tag(forgeBlockTag(p)); b.tag(forgeBlockTag(p));
ItemBuilder<BlockItem,BlockBuilder<T,P>> item = b.item(); ItemBuilder<BlockItem, BlockBuilder<T, P>> item = b.item();
for (String p : path) for (String p : path)
item.tag(forgeItemTag(p)); item.tag(forgeItemTag(p));
return item; return item;
}; };
@ -82,9 +85,7 @@ public class AllTags {
public enum NameSpace { public enum NameSpace {
MOD(Create.ID, false, true), MOD(Create.ID, false, true), FORGE("forge"), TIC("tconstruct")
FORGE("forge"),
TIC("tconstruct")
; ;
@ -119,6 +120,7 @@ public class AllTags {
WRENCH_PICKUP, WRENCH_PICKUP,
WG_STONE(FORGE), WG_STONE(FORGE),
RELOCATION_NOT_SUPPORTED(FORGE),
SLIMY_LOGS(TIC), SLIMY_LOGS(TIC),
@ -145,9 +147,10 @@ public class AllTags {
AllBlockTags(NameSpace namespace, String path, boolean optional, boolean alwaysDatagen) { AllBlockTags(NameSpace namespace, String path, boolean optional, boolean alwaysDatagen) {
ResourceLocation id = new ResourceLocation(namespace.id, path == null ? Lang.asId(name()) : path); ResourceLocation id = new ResourceLocation(namespace.id, path == null ? Lang.asId(name()) : path);
if (optional) { if (optional) {
tag = BlockTags.createOptional(id); tag = ForgeRegistries.BLOCKS.tags()
.createOptionalTagKey(id, Collections.emptySet());
} else { } else {
tag = BlockTags.bind(id.toString()); tag = TagKey.create(ForgeRegistries.BLOCKS.getRegistryKey(), id);
} }
if (alwaysDatagen) { if (alwaysDatagen) {
REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.tag(tag)); REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.tag(tag));
@ -155,7 +158,9 @@ public class AllTags {
} }
public boolean matches(Block block) { public boolean matches(Block block) {
return tag.contains(block); return ForgeRegistries.BLOCKS.getHolder(block)
.map(h -> h.containsTag(tag))
.orElse(false);
} }
public boolean matches(BlockState state) { public boolean matches(BlockState state) {
@ -221,9 +226,10 @@ public class AllTags {
AllItemTags(NameSpace namespace, String path, boolean optional, boolean alwaysDatagen) { AllItemTags(NameSpace namespace, String path, boolean optional, boolean alwaysDatagen) {
ResourceLocation id = new ResourceLocation(namespace.id, path == null ? Lang.asId(name()) : path); ResourceLocation id = new ResourceLocation(namespace.id, path == null ? Lang.asId(name()) : path);
if (optional) { if (optional) {
tag = ItemTags.createOptional(id); tag = ForgeRegistries.ITEMS.tags()
.createOptionalTagKey(id, Collections.emptySet());
} else { } else {
tag = ItemTags.bind(id.toString()); tag = TagKey.create(ForgeRegistries.ITEMS.getRegistryKey(), id);
} }
if (alwaysDatagen) { if (alwaysDatagen) {
REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.tag(tag)); REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.tag(tag));
@ -231,7 +237,9 @@ public class AllTags {
} }
public boolean matches(ItemStack stack) { public boolean matches(ItemStack stack) {
return tag.contains(stack.getItem()); return ForgeRegistries.ITEMS.getHolder(stack.getItem())
.map(h -> h.containsTag(tag))
.orElse(false);
} }
public void add(Item... values) { public void add(Item... values) {
@ -285,17 +293,19 @@ public class AllTags {
AllFluidTags(NameSpace namespace, String path, boolean optional, boolean alwaysDatagen) { AllFluidTags(NameSpace namespace, String path, boolean optional, boolean alwaysDatagen) {
ResourceLocation id = new ResourceLocation(namespace.id, path == null ? Lang.asId(name()) : path); ResourceLocation id = new ResourceLocation(namespace.id, path == null ? Lang.asId(name()) : path);
if (optional) { if (optional) {
tag = FluidTags.createOptional(id); tag = ForgeRegistries.FLUIDS.tags()
.createOptionalTagKey(id, Collections.emptySet());
} else { } else {
tag = FluidTags.bind(id.toString()); tag = TagKey.create(ForgeRegistries.FLUIDS.getRegistryKey(), id);
} }
if (alwaysDatagen) { if (alwaysDatagen)
REGISTRATE.addDataGenerator(ProviderType.FLUID_TAGS, prov -> prov.tag(tag)); REGISTRATE.addDataGenerator(ProviderType.FLUID_TAGS, prov -> prov.tag(tag));
}
} }
public boolean matches(Fluid fluid) { public boolean matches(Fluid fluid) {
return fluid != null && fluid.is(tag); return fluid != null && ForgeRegistries.FLUIDS.getHolder(fluid)
.map(h -> h.containsTag(tag))
.orElse(false);
} }
public void add(Fluid... values) { public void add(Fluid... values) {
@ -347,7 +357,7 @@ public class AllTags {
AllBlockTags.WRENCH_PICKUP.add(Blocks.REDSTONE_WIRE, Blocks.REDSTONE_TORCH, Blocks.REPEATER, Blocks.LEVER, AllBlockTags.WRENCH_PICKUP.add(Blocks.REDSTONE_WIRE, Blocks.REDSTONE_TORCH, Blocks.REPEATER, Blocks.LEVER,
Blocks.COMPARATOR, Blocks.OBSERVER, Blocks.REDSTONE_WALL_TORCH, Blocks.PISTON, Blocks.STICKY_PISTON, Blocks.COMPARATOR, Blocks.OBSERVER, Blocks.REDSTONE_WALL_TORCH, Blocks.PISTON, Blocks.STICKY_PISTON,
Blocks.TRIPWIRE, Blocks.TRIPWIRE_HOOK, Blocks.DAYLIGHT_DETECTOR, Blocks.TARGET); Blocks.TRIPWIRE, Blocks.TRIPWIRE_HOOK, Blocks.DAYLIGHT_DETECTOR, Blocks.TARGET);
AllBlockTags.ORE_OVERRIDE_STONE.includeAll(BlockTags.STONE_ORE_REPLACEABLES); AllBlockTags.ORE_OVERRIDE_STONE.includeAll(BlockTags.STONE_ORE_REPLACEABLES);
} }

View file

@ -57,7 +57,7 @@ public class Create {
public static final String ID = "create"; public static final String ID = "create";
public static final String NAME = "Create"; public static final String NAME = "Create";
public static final String VERSION = "0.4f"; public static final String VERSION = "0.4.1";
public static final Logger LOGGER = LogManager.getLogger(); public static final Logger LOGGER = LogManager.getLogger();

View file

@ -2,11 +2,9 @@ package com.simibubi.create.content.contraptions.components.actors.dispenser;
import java.util.HashMap; import java.util.HashMap;
import javax.annotation.ParametersAreNonnullByDefault;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
import com.simibubi.create.foundation.mixin.accessor.DispenserBlockAccessor;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior; import net.minecraft.core.dispenser.AbstractProjectileDispenseBehavior;
@ -16,23 +14,26 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
public class DispenserMovementBehaviour extends DropperMovementBehaviour { public class DispenserMovementBehaviour extends DropperMovementBehaviour {
private static final HashMap<Item, IMovedDispenseItemBehaviour> MOVED_DISPENSE_ITEM_BEHAVIOURS = new HashMap<>(); private static final HashMap<Item, IMovedDispenseItemBehaviour> MOVED_DISPENSE_ITEM_BEHAVIOURS = new HashMap<>();
private static final HashMap<Item, IMovedDispenseItemBehaviour> MOVED_PROJECTILE_DISPENSE_BEHAVIOURS = new HashMap<>(); private static final HashMap<Item, IMovedDispenseItemBehaviour> MOVED_PROJECTILE_DISPENSE_BEHAVIOURS = new HashMap<>();
private static final DispenserLookup BEHAVIOUR_LOOKUP = new DispenserLookup();
private static boolean spawneggsRegistered = false; private static boolean spawneggsRegistered = false;
public static void gatherMovedDispenseItemBehaviours() { public static void gatherMovedDispenseItemBehaviours() {
IMovedDispenseItemBehaviour.init(); IMovedDispenseItemBehaviour.init();
} }
public static void registerMovedDispenseItemBehaviour(Item item, IMovedDispenseItemBehaviour movedDispenseItemBehaviour) { public static void registerMovedDispenseItemBehaviour(Item item,
IMovedDispenseItemBehaviour movedDispenseItemBehaviour) {
MOVED_DISPENSE_ITEM_BEHAVIOURS.put(item, movedDispenseItemBehaviour); MOVED_DISPENSE_ITEM_BEHAVIOURS.put(item, movedDispenseItemBehaviour);
} }
public static DispenseItemBehavior getDispenseMethod(ItemStack itemstack) {
return ((DispenserBlockAccessor) Blocks.DISPENSER).create$callGetDispenseMethod(itemstack);
}
@Override @Override
protected void activate(MovementContext context, BlockPos pos) { protected void activate(MovementContext context, BlockPos pos) {
if (!spawneggsRegistered) { if (!spawneggsRegistered) {
@ -59,7 +60,7 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour {
return; return;
} }
DispenseItemBehavior idispenseitembehavior = BEHAVIOUR_LOOKUP.getDispenseMethod(itemstack); DispenseItemBehavior idispenseitembehavior = getDispenseMethod(itemstack);
if (idispenseitembehavior instanceof AbstractProjectileDispenseBehavior) { // Projectile behaviours can be converted most of the time if (idispenseitembehavior instanceof AbstractProjectileDispenseBehavior) { // Projectile behaviours can be converted most of the time
IMovedDispenseItemBehaviour iMovedDispenseItemBehaviour = MovedProjectileDispenserBehaviour.of((AbstractProjectileDispenseBehavior) idispenseitembehavior); IMovedDispenseItemBehaviour iMovedDispenseItemBehaviour = MovedProjectileDispenserBehaviour.of((AbstractProjectileDispenseBehavior) idispenseitembehavior);
setItemStackAt(location, iMovedDispenseItemBehaviour.dispense(itemstack, context, pos), context); setItemStackAt(location, iMovedDispenseItemBehaviour.dispense(itemstack, context, pos), context);
@ -85,15 +86,4 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour {
} }
} }
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
private static class DispenserLookup extends DispenserBlock {
protected DispenserLookup() {
super(BlockBehaviour.Properties.copy(Blocks.DISPENSER));
}
public DispenseItemBehavior getDispenseMethod(ItemStack itemStack) {
return super.getDispenseMethod(itemStack);
}
}
} }

View file

@ -5,7 +5,6 @@ import java.util.List;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllTags.AllBlockTags; import com.simibubi.create.AllTags.AllBlockTags;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.components.actors.AttachedActorBlock; import com.simibubi.create.content.contraptions.components.actors.AttachedActorBlock;
import com.simibubi.create.content.contraptions.components.actors.HarvesterBlock; import com.simibubi.create.content.contraptions.components.actors.HarvesterBlock;
import com.simibubi.create.content.contraptions.components.actors.PloughBlock; import com.simibubi.create.content.contraptions.components.actors.PloughBlock;
@ -36,7 +35,6 @@ import com.simibubi.create.foundation.config.ContraptionMovementSetting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BasePressurePlateBlock; import net.minecraft.world.level.block.BasePressurePlateBlock;
import net.minecraft.world.level.block.BaseRailBlock; import net.minecraft.world.level.block.BaseRailBlock;
@ -75,7 +73,6 @@ public class BlockMovementChecks {
private static final List<BrittleCheck> BRITTLE_CHECKS = new ArrayList<>(); private static final List<BrittleCheck> BRITTLE_CHECKS = new ArrayList<>();
private static final List<AttachedCheck> ATTACHED_CHECKS = new ArrayList<>(); private static final List<AttachedCheck> ATTACHED_CHECKS = new ArrayList<>();
private static final List<NotSupportiveCheck> NOT_SUPPORTIVE_CHECKS = new ArrayList<>(); private static final List<NotSupportiveCheck> NOT_SUPPORTIVE_CHECKS = new ArrayList<>();
public static final ResourceLocation NON_MOVABLE = Create.asResource("non_movable");
// Registration // Registration
// Add new checks to the front instead of the end // Add new checks to the front instead of the end
@ -194,7 +191,7 @@ public class BlockMovementChecks {
return true; return true;
if (state.getDestroySpeed(world, pos) == -1) if (state.getDestroySpeed(world, pos) == -1)
return false; return false;
if (state.getBlock().getTags().contains(NON_MOVABLE)) if (AllBlockTags.RELOCATION_NOT_SUPPORTED.matches(state))
return false; return false;
if (ContraptionMovementSetting.get(state.getBlock()) == ContraptionMovementSetting.UNMOVABLE) if (ContraptionMovementSetting.get(state.getBlock()) == ContraptionMovementSetting.UNMOVABLE)
return false; return false;
@ -255,7 +252,7 @@ public class BlockMovementChecks {
return true; return true;
if (block instanceof WoolCarpetBlock) if (block instanceof WoolCarpetBlock)
return true; return true;
return AllBlockTags.BRITTLE.tag.contains(block); return AllBlockTags.BRITTLE.matches(block);
} }
private static boolean isBlockAttachedTowardsFallback(BlockState state, Level world, BlockPos pos, private static boolean isBlockAttachedTowardsFallback(BlockState state, Level world, BlockPos pos,

View file

@ -56,6 +56,7 @@ import net.minecraft.world.phys.Vec3;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.items.wrapper.RecipeWrapper; import net.minecraftforge.items.wrapper.RecipeWrapper;
import net.minecraftforge.registries.ForgeRegistries;
public class InWorldProcessing { public class InWorldProcessing {
@ -292,8 +293,8 @@ public class InWorldProcessing {
} }
if (entity.isOnFire()) { if (entity.isOnFire()) {
entity.clearFire(); entity.clearFire();
level.playSound(null, entity.blockPosition(), SoundEvents.GENERIC_EXTINGUISH_FIRE, SoundSource.NEUTRAL, level.playSound(null, entity.blockPosition(), SoundEvents.GENERIC_EXTINGUISH_FIRE,
0.7F, 1.6F + (level.random.nextFloat() - level.random.nextFloat()) * 0.4F); SoundSource.NEUTRAL, 0.7F, 1.6F + (level.random.nextFloat() - level.random.nextFloat()) * 0.4F);
} }
} }
@ -467,14 +468,20 @@ public class InWorldProcessing {
if (block == Blocks.SOUL_FIRE if (block == Blocks.SOUL_FIRE
|| block == Blocks.SOUL_CAMPFIRE && blockState.getOptionalValue(CampfireBlock.LIT) || block == Blocks.SOUL_CAMPFIRE && blockState.getOptionalValue(CampfireBlock.LIT)
.orElse(false) .orElse(false)
|| AllBlocks.LIT_BLAZE_BURNER.has(blockState) && blockState.getOptionalValue(LitBlazeBurnerBlock.FLAME_TYPE) || AllBlocks.LIT_BLAZE_BURNER.has(blockState)
.map(flame -> flame == LitBlazeBurnerBlock.FlameType.SOUL).orElse(false)) && blockState.getOptionalValue(LitBlazeBurnerBlock.FLAME_TYPE)
.map(flame -> flame == LitBlazeBurnerBlock.FlameType.SOUL)
.orElse(false))
return Type.HAUNTING; return Type.HAUNTING;
if (block == Blocks.FIRE if (block == Blocks.FIRE || ForgeRegistries.BLOCKS.getHolder(block)
|| BlockTags.CAMPFIRES.contains(block) && blockState.getOptionalValue(CampfireBlock.LIT) .map(h -> h.containsTag(BlockTags.CAMPFIRES))
.orElse(false)
&& blockState.getOptionalValue(CampfireBlock.LIT)
.orElse(false) .orElse(false)
|| AllBlocks.LIT_BLAZE_BURNER.has(blockState) && blockState.getOptionalValue(LitBlazeBurnerBlock.FLAME_TYPE) || AllBlocks.LIT_BLAZE_BURNER.has(blockState)
.map(flame -> flame == LitBlazeBurnerBlock.FlameType.REGULAR).orElse(false) && blockState.getOptionalValue(LitBlazeBurnerBlock.FLAME_TYPE)
.map(flame -> flame == LitBlazeBurnerBlock.FlameType.REGULAR)
.orElse(false)
|| getHeatLevelOf(blockState) == BlazeBurnerBlock.HeatLevel.SMOULDERING) || getHeatLevelOf(blockState) == BlazeBurnerBlock.HeatLevel.SMOULDERING)
return Type.SMOKING; return Type.SMOKING;
if (block == Blocks.LAVA || getHeatLevelOf(blockState).isAtLeast(BlazeBurnerBlock.HeatLevel.FADING)) if (block == Blocks.LAVA || getHeatLevelOf(blockState).isAtLeast(BlazeBurnerBlock.HeatLevel.FADING))

View file

@ -82,6 +82,7 @@ import net.minecraftforge.client.IBlockRenderProperties;
import net.minecraftforge.common.Tags; import net.minecraftforge.common.Tags;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.registries.ForgeRegistries;
public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEntity>, ISpecialBlockItemRequirement { public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEntity>, ISpecialBlockItemRequirement {
@ -130,7 +131,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
} }
@Override @Override
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos, Player player) { public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter world, BlockPos pos,
Player player) {
return AllItems.BELT_CONNECTOR.asStack(); return AllItems.BELT_CONNECTOR.asStack();
} }
@ -249,7 +251,9 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
boolean isWrench = AllItems.WRENCH.isIn(heldItem); boolean isWrench = AllItems.WRENCH.isIn(heldItem);
boolean isConnector = AllItems.BELT_CONNECTOR.isIn(heldItem); boolean isConnector = AllItems.BELT_CONNECTOR.isIn(heldItem);
boolean isShaft = AllBlocks.SHAFT.isIn(heldItem); boolean isShaft = AllBlocks.SHAFT.isIn(heldItem);
boolean isDye = Tags.Items.DYES.contains(heldItem.getItem()); boolean isDye = ForgeRegistries.ITEMS.getHolder(heldItem.getItem())
.map(h -> h.containsTag(Tags.Items.DYES))
.orElse(false);
boolean hasWater = EmptyingByBasin.emptyItem(world, heldItem, true) boolean hasWater = EmptyingByBasin.emptyItem(world, heldItem, true)
.getFirst() .getFirst()
.getFluid() .getFluid()
@ -603,7 +607,8 @@ public class BeltBlock extends HorizontalKineticBlock implements ITE<BeltTileEnt
public static class RenderProperties extends ReducedDestroyEffects implements DestroyProgressRenderingHandler { public static class RenderProperties extends ReducedDestroyEffects implements DestroyProgressRenderingHandler {
@Override @Override
public boolean renderDestroyProgress(ClientLevel level, LevelRenderer renderer, int breakerId, BlockPos pos, int progress, BlockState blockState) { public boolean renderDestroyProgress(ClientLevel level, LevelRenderer renderer, int breakerId, BlockPos pos,
int progress, BlockState blockState) {
BlockEntity blockEntity = level.getBlockEntity(pos); BlockEntity blockEntity = level.getBlockEntity(pos);
if (blockEntity instanceof BeltTileEntity belt) { if (blockEntity instanceof BeltTileEntity belt) {
for (BlockPos beltPos : BeltBlock.getBeltChain(level, belt.getController())) { for (BlockPos beltPos : BeltBlock.getBeltChain(level, belt.getController())) {

View file

@ -24,7 +24,6 @@ import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.inventory.CraftingContainer; import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
@ -40,6 +39,7 @@ import net.minecraftforge.client.gui.ForgeIngameGui;
import net.minecraftforge.client.gui.IIngameOverlay; import net.minecraftforge.client.gui.IIngameOverlay;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.ItemStackHandler;
import net.minecraftforge.registries.ForgeRegistries;
public class BlueprintOverlayRenderer { public class BlueprintOverlayRenderer {
@ -280,8 +280,12 @@ public class BlueprintOverlayRenderer {
ItemAttribute fromNBT = ItemAttribute.fromNBT((CompoundTag) attributes.get(0)); ItemAttribute fromNBT = ItemAttribute.fromNBT((CompoundTag) attributes.get(0));
if (fromNBT instanceof ItemAttribute.InTag) { if (fromNBT instanceof ItemAttribute.InTag) {
ItemAttribute.InTag inTag = (ItemAttribute.InTag) fromNBT; ItemAttribute.InTag inTag = (ItemAttribute.InTag) fromNBT;
TagKey<Item> itag = ItemTags.getAllTags() TagKey<Item> itag = ForgeRegistries.ITEMS.tags()
.getTag(inTag.tagName); .getTagNames()
.filter(tk -> tk.location()
.equals(inTag.tagName))
.findAny()
.orElse(null);
if (itag != null) if (itag != null)
return Ingredient.of(itag) return Ingredient.of(itag)
.getItems(); .getItems();

View file

@ -22,6 +22,7 @@ import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects; import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.animal.Fox; import net.minecraft.world.entity.animal.Fox;
import net.minecraft.world.entity.item.FallingBlockEntity; import net.minecraft.world.entity.item.FallingBlockEntity;
@ -147,7 +148,7 @@ public class BuiltinPotatoProjectileTypes {
.knockback(0.1f) .knockback(0.1f)
.renderTumbling() .renderTumbling()
.soundPitch(1.1f) .soundPitch(1.1f)
.onEntityHit(potion(MobEffects.MOVEMENT_SLOWDOWN, 2,160, true)) .onEntityHit(potion(MobEffects.MOVEMENT_SLOWDOWN, 2, 160, true))
.registerAndAssign(AllItems.HONEYED_APPLE.get()), .registerAndAssign(AllItems.HONEYED_APPLE.get()),
GOLDEN_APPLE = create("golden_apple").damage(1) GOLDEN_APPLE = create("golden_apple").damage(1)
@ -160,8 +161,7 @@ public class BuiltinPotatoProjectileTypes {
Entity entity = ray.getEntity(); Entity entity = ray.getEntity();
Level world = entity.level; Level world = entity.level;
if (!(entity instanceof ZombieVillager) if (!(entity instanceof ZombieVillager) || !((ZombieVillager) entity).hasEffect(MobEffects.WEAKNESS))
|| !((ZombieVillager) entity).hasEffect(MobEffects.WEAKNESS))
return foodEffects(Foods.GOLDEN_APPLE, false).test(ray); return foodEffects(Foods.GOLDEN_APPLE, false).test(ray);
if (world.isClientSide) if (world.isClientSide)
return false; return false;
@ -261,7 +261,8 @@ public class BuiltinPotatoProjectileTypes {
private static Predicate<EntityHitResult> setFire(int seconds) { private static Predicate<EntityHitResult> setFire(int seconds) {
return ray -> { return ray -> {
ray.getEntity().setSecondsOnFire(seconds); ray.getEntity()
.setSecondsOnFire(seconds);
return false; return false;
}; };
} }
@ -294,8 +295,10 @@ public class BuiltinPotatoProjectileTypes {
} }
private static void applyEffect(LivingEntity entity, MobEffectInstance effect) { private static void applyEffect(LivingEntity entity, MobEffectInstance effect) {
if (effect.getEffect().isInstantenous()) if (effect.getEffect()
effect.getEffect().applyInstantenousEffect(null, null, entity, effect.getDuration(), 1.0); .isInstantenous())
effect.getEffect()
.applyInstantenousEffect(null, null, entity, effect.getDuration(), 1.0);
else else
entity.addEffect(effect); entity.addEffect(effect);
} }
@ -319,12 +322,14 @@ public class BuiltinPotatoProjectileTypes {
BlockState blockState = world.getBlockState(hitPos); BlockState blockState = world.getBlockState(hitPos);
if (!blockState.canSustainPlant(world, hitPos, face, (IPlantable) cropBlock.get())) if (!blockState.canSustainPlant(world, hitPos, face, (IPlantable) cropBlock.get()))
return false; return false;
world.setBlock(placePos, cropBlock.get().defaultBlockState(), 3); world.setBlock(placePos, cropBlock.get()
.defaultBlockState(), 3);
return true; return true;
}; };
} }
private static BiPredicate<LevelAccessor, BlockHitResult> placeBlockOnGround(IRegistryDelegate<? extends Block> block) { private static BiPredicate<LevelAccessor, BlockHitResult> placeBlockOnGround(
IRegistryDelegate<? extends Block> block) {
return (world, ray) -> { return (world, ray) -> {
if (world.isClientSide()) if (world.isClientSide())
return true; return true;
@ -340,18 +345,23 @@ public class BuiltinPotatoProjectileTypes {
return false; return false;
if (face == Direction.UP) { if (face == Direction.UP) {
world.setBlock(placePos, block.get().defaultBlockState(), 3); world.setBlock(placePos, block.get()
} else if (world instanceof Level) { .defaultBlockState(), 3);
} else if (world instanceof Level level) {
double y = ray.getLocation().y - 0.5; double y = ray.getLocation().y - 0.5;
if (!world.isEmptyBlock(placePos.above())) if (!world.isEmptyBlock(placePos.above()))
y = Math.min(y, placePos.getY()); y = Math.min(y, placePos.getY());
if (!world.isEmptyBlock(placePos.below())) if (!world.isEmptyBlock(placePos.below()))
y = Math.max(y, placePos.getY()); y = Math.max(y, placePos.getY());
FallingBlockEntity falling = new FallingBlockEntity((Level) world, placePos.getX() + 0.5, y, BlockState fallingState = block.get()
placePos.getZ() + 0.5, block.get().defaultBlockState()); .defaultBlockState();
falling.time = 1;
world.addFreshEntity(falling); FallingBlockEntity fallingBlockEntity = new FallingBlockEntity(EntityType.FALLING_BLOCK, level);
fallingBlockEntity.setPos(placePos.getX() + 0.5, y, placePos.getZ() + 0.5);
fallingBlockEntity.time = 1;
fallingBlockEntity.blockState = fallingState;
world.addFreshEntity(fallingBlockEntity);
} }
return true; return true;
@ -373,18 +383,23 @@ public class BuiltinPotatoProjectileTypes {
double entityZ = livingEntity.getZ(); double entityZ = livingEntity.getZ();
for (int teleportTry = 0; teleportTry < 16; ++teleportTry) { for (int teleportTry = 0; teleportTry < 16; ++teleportTry) {
double teleportX = entityX + (livingEntity.getRandom().nextDouble() - 0.5D) * teleportDiameter; double teleportX = entityX + (livingEntity.getRandom()
double teleportY = Mth.clamp(entityY + (livingEntity.getRandom().nextInt((int) teleportDiameter) - (int) (teleportDiameter / 2)), 0.0D, world.getHeight() - 1); .nextDouble() - 0.5D) * teleportDiameter;
double teleportZ = entityZ + (livingEntity.getRandom().nextDouble() - 0.5D) * teleportDiameter; double teleportY = Mth.clamp(entityY + (livingEntity.getRandom()
.nextInt((int) teleportDiameter) - (int) (teleportDiameter / 2)), 0.0D, world.getHeight() - 1);
double teleportZ = entityZ + (livingEntity.getRandom()
.nextDouble() - 0.5D) * teleportDiameter;
EntityTeleportEvent.ChorusFruit event = ForgeEventFactory.onChorusFruitTeleport(livingEntity, teleportX, teleportY, teleportZ); EntityTeleportEvent.ChorusFruit event =
ForgeEventFactory.onChorusFruitTeleport(livingEntity, teleportX, teleportY, teleportZ);
if (event.isCanceled()) if (event.isCanceled())
return false; return false;
if (livingEntity.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) { if (livingEntity.randomTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ(), true)) {
if (livingEntity.isPassenger()) if (livingEntity.isPassenger())
livingEntity.stopRiding(); livingEntity.stopRiding();
SoundEvent soundevent = livingEntity instanceof Fox ? SoundEvents.FOX_TELEPORT : SoundEvents.CHORUS_FRUIT_TELEPORT; SoundEvent soundevent =
livingEntity instanceof Fox ? SoundEvents.FOX_TELEPORT : SoundEvents.CHORUS_FRUIT_TELEPORT;
world.playSound(null, entityX, entityY, entityZ, soundevent, SoundSource.PLAYERS, 1.0F, 1.0F); world.playSound(null, entityX, entityY, entityZ, soundevent, SoundSource.PLAYERS, 1.0F, 1.0F);
livingEntity.playSound(soundevent, 1.0F, 1.0F); livingEntity.playSound(soundevent, 1.0F, 1.0F);
livingEntity.setDeltaMovement(Vec3.ZERO); livingEntity.setDeltaMovement(Vec3.ZERO);

View file

@ -3,6 +3,7 @@ package com.simibubi.create.content.palettes;
import static com.simibubi.create.content.palettes.PaletteBlockPattern.STANDARD_RANGE; import static com.simibubi.create.content.palettes.PaletteBlockPattern.STANDARD_RANGE;
import static com.simibubi.create.content.palettes.PaletteBlockPattern.VANILLA_RANGE; import static com.simibubi.create.content.palettes.PaletteBlockPattern.VANILLA_RANGE;
import java.util.Collections;
import java.util.function.Function; import java.util.function.Function;
import com.simibubi.create.AllTags; import com.simibubi.create.AllTags;
@ -11,11 +12,11 @@ import com.simibubi.create.foundation.data.CreateRegistrate;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.tterrag.registrate.util.nullness.NonNullSupplier; import com.tterrag.registrate.util.nullness.NonNullSupplier;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.registries.ForgeRegistries;
public enum AllPaletteStoneTypes { public enum AllPaletteStoneTypes {
@ -57,7 +58,7 @@ public enum AllPaletteStoneTypes {
private Function<CreateRegistrate, NonNullSupplier<Block>> factory; private Function<CreateRegistrate, NonNullSupplier<Block>> factory;
private PalettesVariantEntry variants; private PalettesVariantEntry variants;
public NonNullSupplier<Block> baseBlock; public NonNullSupplier<Block> baseBlock;
public PaletteBlockPattern[] variantTypes; public PaletteBlockPattern[] variantTypes;
public TagKey<Item> materialTag; public TagKey<Item> materialTag;
@ -81,7 +82,8 @@ public enum AllPaletteStoneTypes {
NonNullSupplier<Block> baseBlock = paletteStoneVariants.factory.apply(registrate); NonNullSupplier<Block> baseBlock = paletteStoneVariants.factory.apply(registrate);
paletteStoneVariants.baseBlock = baseBlock; paletteStoneVariants.baseBlock = baseBlock;
String id = Lang.asId(paletteStoneVariants.name()); String id = Lang.asId(paletteStoneVariants.name());
paletteStoneVariants.materialTag = AllTags.tag(ItemTags::createOptional, Create.ID, "stone_types/" + id); paletteStoneVariants.materialTag = AllTags.tag(r -> ForgeRegistries.ITEMS.tags()
.createOptionalTagKey(r, Collections.emptySet()), Create.ID, "stone_types/" + id);
paletteStoneVariants.variants = new PalettesVariantEntry(id, paletteStoneVariants); paletteStoneVariants.variants = new PalettesVariantEntry(id, paletteStoneVariants);
} }
} }

View file

@ -18,7 +18,7 @@ import com.simibubi.create.AllRecipeTypes;
import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.SetTag; import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeSerializer;
@ -62,7 +62,7 @@ public class MechanicalCraftingRecipeBuilder {
/** /**
* Adds a key to the recipe pattern. * Adds a key to the recipe pattern.
*/ */
public MechanicalCraftingRecipeBuilder key(Character p_200469_1_, SetTag<Item> p_200469_2_) { public MechanicalCraftingRecipeBuilder key(Character p_200469_1_, TagKey<Item> p_200469_2_) {
return this.key(p_200469_1_, Ingredient.of(p_200469_2_)); return this.key(p_200469_1_, Ingredient.of(p_200469_2_));
} }

View file

@ -18,12 +18,12 @@ import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.SerializationTags;
import net.minecraft.tags.TagKey; import net.minecraft.tags.TagKey;
import net.minecraft.util.GsonHelper; import net.minecraft.util.GsonHelper;
import net.minecraft.world.level.material.FlowingFluid; import net.minecraft.world.level.material.FlowingFluid;
import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.registries.ForgeRegistries;
public abstract class FluidIngredient implements Predicate<FluidStack> { public abstract class FluidIngredient implements Predicate<FluidStack> {
@ -207,8 +207,9 @@ public abstract class FluidIngredient implements Predicate<FluidStack> {
if (accepted.getFluid() if (accepted.getFluid()
.isSame(t.getFluid())) .isSame(t.getFluid()))
return true; return true;
return t.getFluid() return ForgeRegistries.FLUIDS.getHolder(t.getFluid())
.is(tag); .map(h -> h.containsTag(tag))
.orElse(false);
} }
@Override @Override
@ -230,22 +231,20 @@ public abstract class FluidIngredient implements Predicate<FluidStack> {
@Override @Override
protected void readInternal(JsonObject json) { protected void readInternal(JsonObject json) {
ResourceLocation id = new ResourceLocation(GsonHelper.getAsString(json, "fluidTag")); ResourceLocation resourcelocation = new ResourceLocation(GsonHelper.getAsString(json, "fluidTag"));
tag = SerializationTags.getInstance().getTagOrThrow(Registry.FLUID_REGISTRY, id, rl -> { tag = TagKey.create(Registry.FLUID_REGISTRY, resourcelocation);
return new JsonSyntaxException("Unknown fluid tag '" + rl + "'");
});
} }
@Override @Override
protected void writeInternal(JsonObject json) { protected void writeInternal(JsonObject json) {
json.addProperty("fluidTag", SerializationTags.getInstance().getIdOrThrow(Registry.FLUID_REGISTRY, tag, () -> { json.addProperty("fluidTag", tag.location()
return new IllegalStateException("Unknown fluid tag"); .toString());
}).toString());
} }
@Override @Override
protected List<FluidStack> determineMatchingFluidStacks() { protected List<FluidStack> determineMatchingFluidStacks() {
return tag.getValues() return ForgeRegistries.FLUIDS.tags()
.getTag(tag)
.stream() .stream()
.map(f -> { .map(f -> {
if (f instanceof FlowingFluid) if (f instanceof FlowingFluid)

View file

@ -1,18 +1,18 @@
package com.simibubi.create.foundation.item; package com.simibubi.create.foundation.item;
import net.minecraft.core.NonNullList; import net.minecraft.core.NonNullList;
import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.tags.ITagManager;
public class TagDependentIngredientItem extends Item { public class TagDependentIngredientItem extends Item {
private ResourceLocation tag; private TagKey<Item> tag;
public TagDependentIngredientItem(Properties properties, ResourceLocation tag) { public TagDependentIngredientItem(Properties properties, TagKey<Item> tag) {
super(properties); super(properties);
this.tag = tag; this.tag = tag;
} }
@ -24,9 +24,10 @@ public class TagDependentIngredientItem extends Item {
} }
public boolean shouldHide() { public boolean shouldHide() {
Tag<?> tag = ItemTags.getAllTags() ITagManager<Item> tags = ForgeRegistries.ITEMS.tags();
.getTag(this.tag); if (tags == null || !tags.isKnownTagName(tag))
return tag == null || tag.getValues() return false;
return tags.getTag(tag)
.isEmpty(); .isEmpty();
} }

View file

@ -0,0 +1,14 @@
package com.simibubi.create.foundation.mixin.accessor;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.core.dispenser.DispenseItemBehavior;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.DispenserBlock;
@Mixin(DispenserBlock.class)
public interface DispenserBlockAccessor {
@Invoker("getDispenseMethod")
DispenseItemBehavior create$callGetDispenseMethod(ItemStack stack);
}

View file

@ -17,11 +17,14 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FenceBlock; import net.minecraft.world.level.block.FenceBlock;
import net.minecraftforge.client.model.ItemMultiLayerBakedModel; import net.minecraftforge.client.model.ItemMultiLayerBakedModel;
import net.minecraftforge.registries.ForgeRegistries;
public class ValueBoxRenderer { public class ValueBoxRenderer {
public static void renderItemIntoValueBox(ItemStack filter, PoseStack ms, MultiBufferSource buffer, int light, int overlay) { public static void renderItemIntoValueBox(ItemStack filter, PoseStack ms, MultiBufferSource buffer, int light,
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer(); int overlay) {
ItemRenderer itemRenderer = Minecraft.getInstance()
.getItemRenderer();
BakedModel modelWithOverrides = itemRenderer.getModel(filter, null, null, 0); BakedModel modelWithOverrides = itemRenderer.getModel(filter, null, null, 0);
boolean blockItem = modelWithOverrides.isGui3d() && !(modelWithOverrides instanceof ItemMultiLayerBakedModel); boolean blockItem = modelWithOverrides.isGui3d() && !(modelWithOverrides instanceof ItemMultiLayerBakedModel);
float scale = (!blockItem ? .5f : 1f) - 1 / 64f; float scale = (!blockItem ? .5f : 1f) - 1 / 64f;
@ -41,7 +44,9 @@ public class ValueBoxRenderer {
return NUDGE; return NUDGE;
if (block instanceof FenceBlock) if (block instanceof FenceBlock)
return NUDGE; return NUDGE;
if (BlockTags.BUTTONS.contains(block)) if (ForgeRegistries.BLOCKS.getHolder(block)
.map(h -> h.containsTag(BlockTags.BUTTONS))
.orElse(false))
return NUDGE; return NUDGE;
if (block == Blocks.END_ROD) if (block == Blocks.END_ROD)
return NUDGE; return NUDGE;

View file

@ -3,10 +3,10 @@ package com.simibubi.create.foundation.worldgen;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.google.common.collect.ImmutableList;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Pair;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries; import net.minecraft.data.BuiltinRegistries;
@ -14,7 +14,6 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.biome.Biome.BiomeCategory; import net.minecraft.world.level.biome.Biome.BiomeCategory;
import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration; import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature; import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.levelgen.placement.PlacedFeature;
import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec;
@ -33,8 +32,9 @@ public class AllWorldFeatures {
// //
public static final ConfigDrivenFeatureEntry ZINC_ORE = register("zinc_ore", 12, 8, OVERWORLD_BIOMES).between(-63, 70) public static final ConfigDrivenFeatureEntry ZINC_ORE =
.withBlocks(Couple.create(AllBlocks.ZINC_ORE, AllBlocks.DEEPSLATE_ZINC_ORE)); register("zinc_ore", 12, 8, OVERWORLD_BIOMES).between(-63, 70)
.withBlocks(Couple.create(AllBlocks.ZINC_ORE, AllBlocks.DEEPSLATE_ZINC_ORE));
public static final ConfigDrivenFeatureEntry STRIATED_ORES_OVERWORLD = public static final ConfigDrivenFeatureEntry STRIATED_ORES_OVERWORLD =
register("striated_ores_overworld", 32, 1 / 12f, OVERWORLD_BIOMES).between(-30, 70) register("striated_ores_overworld", 32, 1 / 12f, OVERWORLD_BIOMES).between(-30, 70)
@ -72,10 +72,12 @@ public class AllWorldFeatures {
.forEach(entry -> { .forEach(entry -> {
String id = Create.ID + "_" + entry.getKey() String id = Create.ID + "_" + entry.getKey()
.getPath(); .getPath();
ConfigDrivenFeatureEntry value = entry.getValue(); ConfigDrivenFeatureEntry featureEntry = entry.getValue();
Pair<ConfiguredFeature<?, ?>, PlacedFeature> feature = value.getFeature(); featureEntry.configuredFeature = BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, id,
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, id, feature.getFirst()); featureEntry.factory.apply(featureEntry));
Registry.register(BuiltinRegistries.PLACED_FEATURE, id, feature.getSecond()); featureEntry.placedFeature =
BuiltinRegistries.register(BuiltinRegistries.PLACED_FEATURE, id, new PlacedFeature(
featureEntry.configuredFeature, ImmutableList.of(new ConfigDrivenDecorator(featureEntry.id))));
}); });
} }
@ -84,10 +86,9 @@ public class AllWorldFeatures {
Decoration decoStep = GenerationStep.Decoration.UNDERGROUND_ORES; Decoration decoStep = GenerationStep.Decoration.UNDERGROUND_ORES;
ENTRIES.values() ENTRIES.values()
.forEach(entry -> { .forEach(entry -> {
if (!entry.biomeFilter.test(event.getName(), event.getCategory())) ConfigDrivenFeatureEntry value = entry;
return; if (value.biomeFilter.test(event.getName(), event.getCategory()))
generation.addFeature(decoStep, entry.getFeature() generation.addFeature(decoStep, value.placedFeature);
.getSecond());
}); });
} }

View file

@ -38,8 +38,9 @@ public class ConfigDrivenDecorator extends PlacementModifier {
@Override @Override
public Stream<BlockPos> getPositions(PlacementContext context, Random random, BlockPos pos) { public Stream<BlockPos> getPositions(PlacementContext context, Random random, BlockPos pos) {
ConfigDrivenOreConfiguration config = (ConfigDrivenOreConfiguration) entry().getFeature() ConfigDrivenOreConfiguration config = (ConfigDrivenOreConfiguration) entry().configuredFeature.value()
.getFirst().config; .config();
float frequency = config.getFrequency(); float frequency = config.getFrequency();
int floored = Mth.floor(frequency); int floored = Mth.floor(frequency);
int count = floored + (random.nextFloat() < frequency - floored ? 1 : 0); int count = floored + (random.nextFloat() < frequency - floored ? 1 : 0);

View file

@ -2,16 +2,15 @@ package com.simibubi.create.foundation.worldgen;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.simibubi.create.Create; import com.simibubi.create.Create;
import com.simibubi.create.foundation.config.ConfigBase; import com.simibubi.create.foundation.config.ConfigBase;
import com.simibubi.create.foundation.utility.Couple; import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Pair;
import com.tterrag.registrate.util.nullness.NonNullSupplier; import com.tterrag.registrate.util.nullness.NonNullSupplier;
import net.minecraft.core.Holder;
import net.minecraft.data.worldgen.features.OreFeatures; import net.minecraft.data.worldgen.features.OreFeatures;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
@ -37,7 +36,8 @@ public class ConfigDrivenFeatureEntry extends ConfigBase {
protected ConfigFloat frequency; protected ConfigFloat frequency;
Function<ConfigDrivenFeatureEntry, ? extends ConfiguredFeature<?, ?>> factory; Function<ConfigDrivenFeatureEntry, ? extends ConfiguredFeature<?, ?>> factory;
Optional<Pair<ConfiguredFeature<?, ?>, PlacedFeature>> feature = Optional.empty(); Holder<ConfiguredFeature<?, ?>> configuredFeature;
Holder<PlacedFeature> placedFeature;
public ConfigDrivenFeatureEntry(String id, int clusterSize, float frequency) { public ConfigDrivenFeatureEntry(String id, int clusterSize, float frequency) {
this.id = id; this.id = id;
@ -79,25 +79,17 @@ public class ConfigDrivenFeatureEntry extends ConfigBase {
return this; return this;
} }
public Pair<ConfiguredFeature<?, ?>, PlacedFeature> getFeature() {
if (!feature.isPresent()) {
ConfiguredFeature<?, ?> configured = factory.apply(this);
feature = Optional.of(Pair.of(configured, configured.placed(new ConfigDrivenDecorator(id))));
}
return feature.get();
}
private ConfiguredFeature<?, ?> layersFactory(ConfigDrivenFeatureEntry entry) { private ConfiguredFeature<?, ?> layersFactory(ConfigDrivenFeatureEntry entry) {
ConfigDrivenOreConfiguration config = new ConfigDrivenOreConfiguration(ImmutableList.of(), 0, id); ConfigDrivenOreConfiguration config = new ConfigDrivenOreConfiguration(ImmutableList.of(), 0, id);
LayeredOreFeature.LAYER_PATTERNS.put(Create.asResource(id), layers.stream() LayeredOreFeature.LAYER_PATTERNS.put(Create.asResource(id), layers.stream()
.map(NonNullSupplier::get) .map(NonNullSupplier::get)
.toList()); .toList());
return LayeredOreFeature.INSTANCE.configured(config); return new ConfiguredFeature<>(LayeredOreFeature.INSTANCE, config);
} }
private ConfiguredFeature<?, ?> standardFactory(ConfigDrivenFeatureEntry entry) { private ConfiguredFeature<?, ?> standardFactory(ConfigDrivenFeatureEntry entry) {
ConfigDrivenOreConfiguration config = new ConfigDrivenOreConfiguration(createTarget(), 0, id); ConfigDrivenOreConfiguration config = new ConfigDrivenOreConfiguration(createTarget(), 0, id);
return VanillaStyleOreFeature.INSTANCE.configured(config); return new ConfiguredFeature<>(VanillaStyleOreFeature.INSTANCE, config);
} }
private List<TargetBlockState> createTarget() { private List<TargetBlockState> createTarget() {

View file

@ -6,6 +6,7 @@ protected net.minecraft.client.particle.Particle f_107205_ # stoppedByCollision
public net.minecraft.client.renderer.ItemInHandRenderer f_109300_ # mainHandItem public net.minecraft.client.renderer.ItemInHandRenderer f_109300_ # mainHandItem
public net.minecraft.client.renderer.ItemInHandRenderer f_109301_ # offHandItem public net.minecraft.client.renderer.ItemInHandRenderer f_109301_ # offHandItem
public net.minecraft.client.renderer.entity.ItemRenderer f_115096_ # textureManager public net.minecraft.client.renderer.entity.ItemRenderer f_115096_ # textureManager
public net.minecraft.world.entity.item.FallingBlockEntity f_31946_ # blockState
public-f net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket f_132663_ # flyingSpeed public-f net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket f_132663_ # flyingSpeed

View file

@ -5,7 +5,7 @@ license="MIT"
[[mods]] [[mods]]
modId="create" modId="create"
version="0.4f" version="0.4.1"
displayName="Create" displayName="Create"
#updateJSONURL="" #updateJSONURL=""
displayURL="https://www.curseforge.com/minecraft/mc-mods/create" displayURL="https://www.curseforge.com/minecraft/mc-mods/create"
@ -18,20 +18,20 @@ Technology that empowers the player.'''
[[dependencies.create]] [[dependencies.create]]
modId="forge" modId="forge"
mandatory=true mandatory=true
versionRange="[39.0.46,)" versionRange="[40.0.0,)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[dependencies.create]] [[dependencies.create]]
modId="minecraft" modId="minecraft"
mandatory=true mandatory=true
versionRange="[1.18.1,1.19)" versionRange="[1.18.2,1.19)"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[dependencies.create]] [[dependencies.create]]
modId="flywheel" modId="flywheel"
mandatory=true mandatory=true
versionRange="[1.18-0.6.1,1.18-0.6.2)" versionRange="[1.18-0.6.2,1.18-0.6.3)"
ordering="AFTER" ordering="AFTER"
side="CLIENT" side="CLIENT"

View file

@ -7,7 +7,8 @@
"mixins": [ "mixins": [
"CustomItemUseEffectsMixin", "CustomItemUseEffectsMixin",
"accessor.AbstractProjectileDispenseBehaviorAccessor", "accessor.AbstractProjectileDispenseBehaviorAccessor",
"accessor.LivingEntityAccessor" "accessor.LivingEntityAccessor",
"accessor.DispenserBlockAccessor"
], ],
"client": [ "client": [
"DestroyProgressMixin", "DestroyProgressMixin",