Migrate to minecraft 1.20 #70

Merged
BlakeRain merged 1 commits from BlakeRain/utamacraft:main into main 2024-02-11 17:02:40 +00:00
38 changed files with 321 additions and 252 deletions
Showing only changes of commit bc6cea3cec - Show all commits

3
.gitignore vendored
View File

@ -84,3 +84,6 @@ run
# File generated by JDT.LS
.factorypath
# Generated by Gradle
src/generated/

View File

@ -131,7 +131,7 @@ repositories {
maven {
url "https://squiddev.cc/maven/"
content {
includeGroup("org.squiddev")
includeGroup("cc.tweaked")
}
}
@ -164,9 +164,9 @@ dependencies {
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
// Compile against only the Curios API artifact
compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${minecraft_version}-${curios_version}:api"))
compileOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}:api"))
// Use the full Curios API jar at runtime
runtimeOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${minecraft_version}-${curios_version}"))
runtimeOnly(fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}"))
// compile against the JEI API but do not include it at runtime
compileOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}"))
@ -175,16 +175,18 @@ dependencies {
runtimeOnly(fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}"))
// CC:Tweaked API
implementation(fg.deobf("org.squiddev:cc-tweaked-${minecraft_version}:${cct_version}"))
implementation(fg.deobf("cc.tweaked:cc-tweaked-${minecraft_version}-forge:${cct_version}"))
// compileOnly fg.deobf("cc.tweaked:cc-tweaked-${minecraft_version}-forge-api:${cct_version}")
// compileOnly fg.deobf("cc.tweaked:cc-tweaked-${minecraft_version}-core-api:${cct_version}")
// Mekanism: useful for testing energy and so on.
runtimeOnly(fg.deobf("mekanism:Mekanism:${minecraft_version}-${mekanism_version}"))
// Storage Drawers: useful for testing different storage interfaces.
runtimeOnly(fg.deobf("curse.maven:storage-drawers-223852:3884263"))
runtimeOnly(fg.deobf("curse.maven:storage-drawers-223852:4668552"))
// Create: useful for testing recipies
runtimeOnly(fg.deobf("curse.maven:create-328085:4835190"))
runtimeOnly(fg.deobf("curse.maven:create-328085:4835191"))
}
mixin {

View File

@ -6,15 +6,15 @@ org.gradle.daemon=false
## Environment Properties
# The Minecraft version must agree with the Forge version to get a valid artifact.
minecraft_version=1.19.2
minecraft_version=1.20.1
# The Minecraft version range can use any release version of Minecraft as bounds.
minecraft_version_range=[1.19.2,1.20)
minecraft_version_range=[1.20.1,1.21)
# The Forge version must agree with the Minecraft version to get a valid artifact.
forge_version=43.3.5
forge_version=47.2.0
# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[43,)
forge_version_range=[47,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[41,)
loader_version_range=[47,)
# The mapping channel to use for mappings.
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
@ -33,18 +33,18 @@ loader_version_range=[41,)
mapping_channel=parchment
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=2022.11.27-1.19.2
mapping_version=2023.09.03-1.20.1
## Dependency Properties
# The version of CC:Tweaked we're building against
cct_version=1.101.3
cct_version=1.109.5
# The version of JEI that we're building against
jei_version=11.6.0.1015
jei_version=15.3.0.1
# The version of Mekanism we use when testing
mekanism_version=10.3.8.477
mekanism_version=10.4.5.19
# The version of Curios we use
curios_version=5.1.4.1
curios_version=5.7.0+1.20.1
## Mod Properties
@ -56,7 +56,7 @@ mod_name=Utamacraft Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT License
# The mod version. See https://semver.org/
mod_version=0.2.9-1.19
mod_version=0.3.0-1.20.1
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View File

@ -21,7 +21,7 @@ import net.minecraftforge.registries.RegistryObject;
*/
public class CCRegistration {
public static final DeferredRegister<TurtleUpgradeSerialiser<?>> TURTLE_SERIALIZERS = DeferredRegister
.create(TurtleUpgradeSerialiser.REGISTRY_ID, Utamacraft.MOD_ID);
.create(TurtleUpgradeSerialiser.registryId(), Utamacraft.MOD_ID);
public static final RegistryObject<TurtleUpgradeSerialiser<TurtlePlayerUpgrade>> PLAYER_TURTLE = TURTLE_SERIALIZERS
.register(ID.PLAYER_TURTLE.getPath(),

View File

@ -6,6 +6,7 @@ import net.banutama.utamacraft.block.custom.ModBlocks;
import net.banutama.utamacraft.block.entity.ModBlockEntities;
import net.banutama.utamacraft.integrations.curios.CuriosRenderers;
import net.banutama.utamacraft.integrations.curios.CuriousLayerDefinitions;
import net.banutama.utamacraft.item.ModCreativeModeTab;
import net.banutama.utamacraft.item.ModItems;
import net.banutama.utamacraft.networking.ModMessages;
@ -14,26 +15,22 @@ import net.banutama.utamacraft.screen.DigitizerScreen;
import net.banutama.utamacraft.screen.InsolatorScreen;
import net.banutama.utamacraft.screen.ModMenuTypes;
import net.banutama.utamacraft.sound.ModSounds;
import net.banutama.utamacraft.world.feature.ModConfiguredFeatures;
import net.banutama.utamacraft.world.feature.ModPlacedFeatures;
import net.minecraft.client.RecipeBookCategories;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.RegisterRecipeBookCategoriesEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;
import top.theillusivec4.curios.api.SlotTypeMessage;
import top.theillusivec4.curios.api.SlotTypePreset;
// The value here should match an entry in the META-INF/mods.toml file
@Mod(Utamacraft.MOD_ID)
@ -45,6 +42,7 @@ public class Utamacraft {
LOGGER.info("Utamacraft initializing");
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
ModCreativeModeTab.register(bus);
ModItems.register(bus);
ModBlocks.register(bus);
ModBlockEntities.register(bus);
@ -52,10 +50,9 @@ public class Utamacraft {
ModMenuTypes.register(bus);
ModSounds.register(bus);
ModRecipes.register(bus);
ModConfiguredFeatures.register(bus);
ModPlacedFeatures.register(bus);
bus.addListener(this::commonSetup);
bus.addListener(this::addCreative);
MinecraftForge.EVENT_BUS.register(this);
}
@ -65,6 +62,16 @@ public class Utamacraft {
});
}
private void addCreative(BuildCreativeModeTabContentsEvent event) {
if (event.getTabKey() == CreativeModeTabs.INGREDIENTS) {
event.accept(ModItems.BULB);
event.accept(ModItems.PCB);
event.accept(ModItems.FIBER_GLASS);
event.accept(ModItems.TUNGSTEN_INGOT);
event.accept(ModItems.TUNGSTEN_RAW);
}
}
@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public static class ModEvents {
@SubscribeEvent
@ -74,11 +81,11 @@ public class Utamacraft {
CuriosRenderers.register();
}
@SubscribeEvent
public static void onIntermodEnqueue(InterModEnqueueEvent event) {
InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE,
() -> SlotTypePreset.NECKLACE.getMessageBuilder().build());
}
// @SubscribeEvent
// public static void onIntermodEnqueue(InterModEnqueueEvent event) {
// InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE,
// () -> SlotTypePreset.NECKLACE.getMessageBuilder().build());
// }
}
@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)

View File

@ -1,5 +1,7 @@
package net.banutama.utamacraft.block.custom;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -10,7 +12,6 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.shapes.VoxelShape;
public class AwarenessBlock extends BaseEntityBlock {
@ -20,8 +21,8 @@ public class AwarenessBlock extends BaseEntityBlock {
super(getProperties());
}
public static Block.Properties getProperties() {
return Block.Properties.of(Material.STONE)
public static BlockBehaviour.Properties getProperties() {
return BlockBehaviour.Properties.copy(Blocks.STONE)
.noOcclusion()
.strength(1.5f, 6.0f)
.noOcclusion();

View File

@ -1,5 +1,7 @@
package net.banutama.utamacraft.block.custom;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockBehaviour;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -16,17 +18,11 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Mirror;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
@ -41,8 +37,8 @@ public class DigitizerBlock extends BaseEntityBlock {
registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH));
}
private static Block.Properties getProperties() {
return Block.Properties.of(Material.STONE)
private static BlockBehaviour.Properties getProperties() {
return BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK)
.noOcclusion()
.isValidSpawn(DigitizerBlock::blockSpawning)
.isRedstoneConductor(DigitizerBlock::notSolid)

View File

@ -19,12 +19,12 @@ import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
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.DirectionProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
@ -43,8 +43,8 @@ public class InsolatorBlock extends BaseEntityBlock {
registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH).setValue(ACTIVE, false));
}
private static Block.Properties getProperties() {
return Block.Properties.of(Material.METAL)
private static BlockBehaviour.Properties getProperties() {
return BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK)
.noOcclusion()
.strength(2.0f, 6.0f)
.noOcclusion()

View File

@ -3,15 +3,14 @@ package net.banutama.utamacraft.block.custom;
import java.util.function.Supplier;
import net.banutama.utamacraft.Utamacraft;
import net.banutama.utamacraft.item.ModCreativeModeTab;
import net.banutama.utamacraft.item.ModItems;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DropExperienceBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
@ -25,17 +24,17 @@ public class ModBlocks {
public static final RegistryObject<Block> ETHEREAL_GLASS_TINTED = registerBlock("ethereal_glass_tinted",
EtherealGlassTintedBlock::new);
public static final RegistryObject<Block> TUNGSTEN_ORE = registerBlock("tungsten_ore",
() -> new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE)
() -> new DropExperienceBlock(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK)
.strength(6.0f)
.requiresCorrectToolForDrops(),
UniformInt.of(3, 7)));
public static final RegistryObject<Block> DEEPSLATE_TUNGSTEN_ORE = registerBlock("deepslate_tungsten_ore",
() -> new DropExperienceBlock(BlockBehaviour.Properties.of(Material.STONE)
() -> new DropExperienceBlock(BlockBehaviour.Properties.copy(Blocks.STONE)
.strength(6.0f)
.requiresCorrectToolForDrops(),
UniformInt.of(3, 7)));
public static final RegistryObject<Block> TUNGSTEN_BLOCK = registerBlock("tungsten_block",
() -> new Block(BlockBehaviour.Properties.of(Material.METAL)
() -> new Block(BlockBehaviour.Properties.copy(Blocks.IRON_BLOCK)
.strength(12.0f)
.requiresCorrectToolForDrops()));
public static final RegistryObject<Block> INSOLATOR = registerBlock("insolator", InsolatorBlock::new);
@ -50,7 +49,7 @@ public class ModBlocks {
private static <T extends Block> void registerBlockItem(String name, RegistryObject<T> block) {
ModItems.ITEMS.register(name,
() -> new BlockItem(block.get(), new Item.Properties().tab(ModCreativeModeTab.TAB)));
() -> new BlockItem(block.get(), new Item.Properties()));
}
public static void register(IEventBus bus) {

View File

@ -240,9 +240,9 @@ public class InsolatorBlockEntity extends BlockEntity implements MenuProvider {
// Insert the recipe output in to the output slot.
ItemStack output = inventory.getStackInSlot(2);
if (output.isEmpty()) {
inventory.setStackInSlot(2, recipe.getResultItem().copy());
inventory.setStackInSlot(2, recipe.getResultItem(null).copy());
} else {
output.grow(recipe.getResultItem().getCount());
output.grow(recipe.getResultItem(null).getCount());
}
resetProgress(recipe.getTicks());
@ -267,12 +267,12 @@ public class InsolatorBlockEntity extends BlockEntity implements MenuProvider {
// If the output isn't empty, and the item in the output is different to the
// output of the recipe, we cannot process.
if (!output.isEmpty() && output.getItem() != recipe.getResultItem().getItem()) {
if (!output.isEmpty() && output.getItem() != recipe.getResultItem(null).getItem()) {
return false;
}
// Make sure that the output is not saturated.
return output.getCount() + recipe.getResultItem().getCount() <= output.getMaxStackSize();
return output.getCount() + recipe.getResultItem(null).getCount() <= output.getMaxStackSize();
}
private Optional<InsolatorRecipe> getRecipe() {

View File

@ -0,0 +1,20 @@
package net.banutama.utamacraft.datagen;
import net.banutama.utamacraft.Utamacraft;
import net.banutama.utamacraft.world.ModWorldgenProvider;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(modid = Utamacraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class DataGenerators {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
var gen = event.getGenerator();
var out = gen.getPackOutput();
var efh = event.getExistingFileHelper();
var lp = event.getLookupProvider();
gen.addProvider(event.includeServer(), new ModWorldgenProvider(out, lp));
}
}

View File

@ -2,8 +2,7 @@ package net.banutama.utamacraft.integrations.computercraft;
import dan200.computercraft.api.lua.*;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.core.asm.NamedMethod;
import dan200.computercraft.core.asm.PeripheralMethod;
import dan200.computercraft.core.methods.PeripheralMethod;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
@ -13,10 +12,10 @@ public class BoundMethod {
private final String name;
private final PeripheralMethod method;
public BoundMethod(@NotNull Object target, @NotNull NamedMethod<PeripheralMethod> method) {
public BoundMethod(@NotNull Object target, @NotNull String name, @NotNull PeripheralMethod method) {
this.target = target;
this.name = method.getName();
this.method = method.getMethod();
this.name = name;
this.method = method;
}
@NotNull

View File

@ -1,48 +1,23 @@
package net.banutama.utamacraft.integrations.computercraft.peripheral;
import dan200.computercraft.api.lua.IArguments;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.lua.MethodResult;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IDynamicPeripheral;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.core.asm.PeripheralMethod;
import net.banutama.utamacraft.integrations.computercraft.BoundMethod;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
public abstract class BasePeripheral implements IDynamicPeripheral {
public abstract class BasePeripheral implements IPeripheral {
protected final String type;
protected final BasePeripheralOwner owner;
protected final List<BoundMethod> methods;
protected final Set<IComputerAccess> computers = Collections.newSetFromMap(new ConcurrentHashMap<>());
protected BasePeripheral(String type, BasePeripheralOwner owner) {
this.type = type;
this.owner = owner;
this.methods = PeripheralMethod.GENERATOR.getMethods(this.getClass()).stream()
.map(named -> new BoundMethod(this, named)).collect(Collectors.toList());
}
@NotNull
@Override
public String @NotNull [] getMethodNames() {
return methods.stream().map(BoundMethod::getName).toArray(String[]::new);
}
@NotNull
@Override
public MethodResult callMethod(@NotNull IComputerAccess computer, @NotNull ILuaContext context, int method,
@NotNull IArguments arguments) throws LuaException {
return methods.get(method).apply(computer, context, arguments);
}
@NotNull

View File

@ -58,12 +58,12 @@ public class InsolatorRecipeCategory implements IRecipeCategory<InsolatorRecipe>
@Override
public void setRecipe(@NotNull IRecipeLayoutBuilder builder, @NotNull InsolatorRecipe recipe,
@NotNull IFocusGroup focuses) {
builder.addSlot(RecipeIngredientRole.INPUT, 86, 15)
builder.addSlot(RecipeIngredientRole.INPUT, 152, 10)
.addIngredients(recipe.getIngredients().get(0));
builder.addSlot(RecipeIngredientRole.INPUT, 33, 16)
builder.addSlot(RecipeIngredientRole.INPUT, 78, 10)
.addIngredients(ForgeTypes.FLUID_STACK, List.of(recipe.getFluid()))
.setFluidRenderer(64000, false, 9, 60);
builder.addSlot(RecipeIngredientRole.OUTPUT, 86, 60)
.addItemStack(recipe.getResultItem());
builder.addSlot(RecipeIngredientRole.OUTPUT, 152, 10)
.addItemStack(recipe.getResultItem(null));
}
}

View File

@ -1,26 +1,11 @@
package net.banutama.utamacraft.item;
import net.minecraft.core.NonNullList;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
import dan200.computercraft.shared.Registry;
public abstract class BaseItem extends Item {
public BaseItem(@NotNull Properties properties) {
super(properties.tab(ModCreativeModeTab.TAB));
}
public static void createTurtleStacks(@NotNull NonNullList<ItemStack> stack, @NotNull ResourceLocation peripheral) {
ItemStack turtleStack = new ItemStack(Registry.ModItems.TURTLE_NORMAL.get());
turtleStack.getOrCreateTag().putString("RightUpgrade", peripheral.toString());
stack.add(turtleStack);
ItemStack advancedTurtleStack = new ItemStack(Registry.ModItems.TURTLE_ADVANCED.get());
advancedTurtleStack.getOrCreateTag().putString("RightUpgrade", peripheral.toString());
stack.add(advancedTurtleStack);
super(properties);
}
}

View File

@ -39,7 +39,7 @@ public class FireWardItem extends Item implements ICurioItem {
}
private static Properties getProperties() {
return new Properties().tab(ModCreativeModeTab.TAB).stacksTo(1);
return new Properties().stacksTo(1);
}
@Override

View File

@ -1,17 +1,67 @@
package net.banutama.utamacraft.item;
import dan200.computercraft.shared.ModRegistry;
import net.banutama.utamacraft.CCRegistration;
import net.banutama.utamacraft.Utamacraft;
import net.banutama.utamacraft.block.custom.ModBlocks;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;
import org.checkerframework.checker.units.qual.A;
import org.jetbrains.annotations.NotNull;
@Mod.EventBusSubscriber(modid = Utamacraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
import java.util.Collection;
import java.util.Set;
public class ModCreativeModeTab {
public static final CreativeModeTab TAB = new CreativeModeTab("utamacraft_tab") {
@Override
public @NotNull ItemStack makeIcon() {
return new ItemStack(ModItems.BULB.get());
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS =
DeferredRegister.create(Registries.CREATIVE_MODE_TAB, Utamacraft.MOD_ID);
public static final RegistryObject<CreativeModeTab> UTAMACRAFT_TAB = CREATIVE_MODE_TABS.register("utamacraft_tab", () -> {
return CreativeModeTab.builder().icon(() -> new ItemStack(ModItems.BULB.get()))
.title(Component.translatable("creativetab.utamacraft_tab"))
.displayItems((params, output) -> {
output.accept(ModItems.BULB.get());
output.accept(ModItems.FIBER_GLASS.get());
output.accept(ModItems.PCB.get());
output.accept(ModItems.FIRE_WARD.get());
output.accept(ModItems.PLAYER_PERIPHERAL.get());
output.accept(ModItems.TELEPORTER_PERIPHERAL.get());
output.accept(ModItems.TUNGSTEN_INGOT.get());
output.accept(ModItems.TUNGSTEN_RAW.get());
output.accept(ModBlocks.AWARENESS_BLOCK.get());
output.accept(ModBlocks.DEEPSLATE_TUNGSTEN_ORE.get());
output.accept(ModBlocks.TUNGSTEN_BLOCK.get());
output.accept(ModBlocks.DIGITIZER.get());
output.accept(ModBlocks.ETHEREAL_GLASS.get());
output.accept(ModBlocks.ETHEREAL_GLASS_TINTED.get());
output.accept(ModBlocks.INSOLATOR.get());
output.accept(ModBlocks.TUNGSTEN_ORE.get());
output.acceptAll(turtleWithPeripheral(CCRegistration.ID.PLAYER_TURTLE));
output.acceptAll(turtleWithPeripheral(CCRegistration.ID.TELEPORTER_TURTLE));
})
.build();
});
private static Collection<ItemStack> turtleWithPeripheral(ResourceLocation peripheral) {
ItemStack turtleStack = new ItemStack(ModRegistry.Items.TURTLE_NORMAL.get());
turtleStack.getOrCreateTag().putString("RightUpgrade", peripheral.toString());
ItemStack advanctedTurtleStack = new ItemStack(ModRegistry.Items.TURTLE_ADVANCED.get());
advanctedTurtleStack.getOrCreateTag().putString("RightUpgrade", peripheral.toString());
return Set.of(turtleStack, advanctedTurtleStack);
}
public static void register(IEventBus bus) {
CREATIVE_MODE_TABS.register(bus);
}
};
}

View File

@ -27,6 +27,6 @@ public class ModItems {
}
private static Item simpleItem() {
return new Item(new Item.Properties().tab(ModCreativeModeTab.TAB));
return new Item(new Item.Properties());
}
}

View File

@ -1,23 +1,9 @@
package net.banutama.utamacraft.item;
import net.banutama.utamacraft.CCRegistration;
import net.minecraft.core.NonNullList;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
public class PlayerPeripheralItem extends BaseItem {
public PlayerPeripheralItem() {
super(new Item.Properties().stacksTo(16));
}
@Override
public void fillItemCategory(@NotNull CreativeModeTab group, @NotNull NonNullList<ItemStack> items) {
super.fillItemCategory(group, items);
if (allowedIn(group)) {
createTurtleStacks(items, CCRegistration.ID.PLAYER_TURTLE);
}
}
}

View File

@ -1,23 +1,9 @@
package net.banutama.utamacraft.item;
import net.banutama.utamacraft.CCRegistration;
import net.minecraft.core.NonNullList;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
public class TeleporterPeripheralItem extends BaseItem {
public TeleporterPeripheralItem() {
super(new Item.Properties().stacksTo(16));
}
@Override
public void fillItemCategory(@NotNull CreativeModeTab group, @NotNull NonNullList<ItemStack> items) {
super.fillItemCategory(group, items);
if (allowedIn(group)) {
createTurtleStacks(items, CCRegistration.ID.TELEPORTER_TURTLE);
}
}
}

View File

@ -1,6 +1,7 @@
package net.banutama.utamacraft.mixin;
import net.banutama.utamacraft.item.ModItems;
import net.minecraft.tags.DamageTypeTags;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
@ -17,12 +18,14 @@ public class EntityMixin {
@Inject(at = @At("HEAD"), method = "isInvulnerableTo", cancellable = true)
private void checkInvulnerabilities(DamageSource source, CallbackInfoReturnable<Boolean> cir) {
if (((Object) this) instanceof LivingEntity living) {
if (source.isFire()) {
ItemStack res = CuriosApi
.getCuriosHelper()
.findFirstCurio(living, ModItems.FIRE_WARD.get())
if (source.is(DamageTypeTags.IS_FIRE)) {
ItemStack res = CuriosApi.getCuriosInventory(living).map(inventory -> {
return inventory
.findFirstCurio(ModItems.FIRE_WARD.get())
.map(SlotResult::stack)
.orElse(ItemStack.EMPTY);
}).orElse(ItemStack.EMPTY);
if (!res.isEmpty()) {
cir.setReturnValue(true);
}

View File

@ -21,7 +21,7 @@ public class ModMessages {
INSTANCE.messageBuilder(DumpInsolatorFluidPacket.class, 0x0000, NetworkDirection.PLAY_TO_SERVER)
.encoder(DumpInsolatorFluidPacket::encode)
.decoder(DumpInsolatorFluidPacket::decode)
.consumer(DumpInsolatorFluidPacket::handle)
// .consumer(DumpInsolatorFluidPacket::handle)
.add();
}

View File

@ -34,7 +34,7 @@ public class DumpInsolatorFluidPacket {
ServerPlayer player = context.getSender();
if (player == null) return;
BlockEntity blockEntity = player.level.getBlockEntity(pos);
BlockEntity blockEntity = player.level().getBlockEntity(pos);
if (blockEntity instanceof InsolatorBlockEntity insolator) {
insolator.dumpFluids();
}

View File

@ -4,6 +4,7 @@ import com.google.gson.JsonObject;
import com.mojang.serialization.JsonOps;
import net.banutama.utamacraft.Utamacraft;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
@ -41,7 +42,7 @@ public class InsolatorRecipe implements Recipe<SimpleContainer> {
}
@Override
public @NotNull ItemStack assemble(@NotNull SimpleContainer pContainer) {
public @NotNull ItemStack assemble(@NotNull SimpleContainer pContainer, RegistryAccess access) {
return output;
}
@ -59,7 +60,7 @@ public class InsolatorRecipe implements Recipe<SimpleContainer> {
}
@Override
public @NotNull ItemStack getResultItem() {
public @NotNull ItemStack getResultItem(RegistryAccess access) {
return output.copy();
}
@ -83,7 +84,8 @@ public class InsolatorRecipe implements Recipe<SimpleContainer> {
return NonNullList.of(Ingredient.EMPTY, input);
}
// public static class Type implements RecipeType<InsolatorRecipe> {
// public static class Type implements RecipeType<InsolatorRecipe> {
// public static final Type INSTANCE = new Type();
// public static final String ID = "insolator";
// private Type() {

View File

@ -18,7 +18,7 @@ public class DigitizerMenu extends BaseAbstractContainerMenu {
// Client constructor
public DigitizerMenu(int id, Inventory inventory, FriendlyByteBuf extraData) {
this(id, inventory, inventory.player.level.getBlockEntity(extraData.readBlockPos()));
this(id, inventory, inventory.player.level().getBlockEntity(extraData.readBlockPos()));
}
// Server constructor

View File

@ -3,6 +3,7 @@ package net.banutama.utamacraft.screen;
import java.util.List;
import java.util.Optional;
import net.minecraft.client.gui.GuiGraphics;
import org.jetbrains.annotations.NotNull;
import com.mojang.blaze3d.systems.RenderSystem;
@ -36,17 +37,17 @@ public class DigitizerScreen extends AbstractContainerScreen<DigitizerMenu> {
}
@Override
protected void renderBg(@NotNull PoseStack stack, float partialTick, int mouseX, int mouseY) {
protected void renderBg(@NotNull GuiGraphics gui, float pPartialTick, int pMouseX, int pMouseY) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.setShaderTexture(0, TEXTURE);
blit(stack, leftPos, topPos, 0, 0, imageWidth, imageHeight);
renderEnergy(stack, leftPos + 8, topPos + 8);
gui.blit(TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight);
renderEnergy(gui, leftPos + 8, topPos + 8);
}
@Override
protected void renderLabels(@NotNull PoseStack pPoseStack, int pMouseX, int pMouseY) {
protected void renderLabels(@NotNull GuiGraphics gui, int pMouseX, int pMouseY) {
int x = (width - imageWidth) / 2;
int y = (height - imageHeight) / 2;
@ -54,11 +55,11 @@ public class DigitizerScreen extends AbstractContainerScreen<DigitizerMenu> {
EnergyStorage energy = menu.getBlockEntity().getEnergy();
List<Component> components = TooltipUtils.getEnergyTooltip(energy.getEnergyStored(),
energy.getMaxEnergyStored());
renderTooltip(pPoseStack, components, Optional.empty(), pMouseX - x, pMouseY - y);
gui.renderTooltip(font, components, Optional.empty(), pMouseX - x, pMouseY - y);
}
}
private void renderEnergy(@NotNull PoseStack stack, int x, int y) {
private void renderEnergy(@NotNull GuiGraphics gui, int x, int y) {
EnergyStorage energy = menu.getBlockEntity().getEnergy();
if (energy.getEnergyStored() <= 0 || energy.getMaxEnergyStored() <= 0) {
return;
@ -66,13 +67,13 @@ public class DigitizerScreen extends AbstractContainerScreen<DigitizerMenu> {
final int ENERGY_HEIGHT = 60;
int stored = (int) (ENERGY_HEIGHT * ((float) energy.getEnergyStored() / (float) energy.getMaxEnergyStored()));
fillGradient(stack, x, y + (ENERGY_HEIGHT - stored), x + 9, y + 60, 0xffb51500, 0xff600b00);
gui.fillGradient(x, y + (ENERGY_HEIGHT - stored), x + 9, y + 60, 0xffb51500, 0xff600b00);
}
@Override
public void render(@NotNull PoseStack stack, int mouseX, int mouseY, float delta) {
renderBackground(stack);
super.render(stack, mouseX, mouseY, delta);
renderTooltip(stack, mouseX, mouseY);
public void render(@NotNull GuiGraphics gui, int mouseX, int mouseY, float delta) {
renderBackground(gui);
super.render(gui, mouseX, mouseY, delta);
renderTooltip(gui, mouseX, mouseY);
}
}

View File

@ -19,7 +19,7 @@ public class InsolatorMenu extends BaseAbstractContainerMenu {
// Client Constructor
public InsolatorMenu(int id, Inventory inventory, FriendlyByteBuf extraData) {
this(id, inventory, inventory.player.level.getBlockEntity(extraData.readBlockPos()));
this(id, inventory, inventory.player.level().getBlockEntity(extraData.readBlockPos()));
}
// Server Constructor

View File

@ -9,6 +9,7 @@ import net.banutama.utamacraft.screen.utils.FluidSprite;
import net.banutama.utamacraft.screen.utils.MouseUtils;
import net.banutama.utamacraft.screen.utils.TiledSprite;
import net.banutama.utamacraft.screen.utils.TooltipUtils;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.GameRenderer;
@ -49,52 +50,46 @@ public class InsolatorScreen extends AbstractContainerScreen<InsolatorMenu> {
leftPos = (width - imageWidth) / 2;
topPos = (height - imageHeight) / 2;
dumpButton = addRenderableWidget(new Button(
leftPos + 8, topPos + 52,
60, 20, DUMP_BUTTON, this::onDumpPress,
(button, stack, mouseX, mouseY) -> {
if (menu.getBlockEntity().getFluidTank().getFluid().getAmount() <= 0) {
renderTooltip(stack, DUMP_BUTTON_TOOLTIP_EMPTY, mouseX, mouseY);
} else {
renderTooltip(stack, DUMP_BUTTON_TOOLTIP, mouseX, mouseY);
}
}));
dumpButton = addRenderableWidget(
new Button.Builder(DUMP_BUTTON, this::onDumpPress)
.pos(leftPos + 8, topPos + 52)
.size(60, 20)
.build());
}
@Override
protected void renderBg(@NotNull PoseStack stack, float partialTick, int mouseX, int mouseY) {
protected void renderBg(@NotNull GuiGraphics graphics, float partialTick, int mouseX, int mouseY) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.setShaderTexture(0, TEXTURE);
blit(stack, leftPos, topPos, 0, 0, imageWidth, imageHeight);
renderBulb(stack);
renderProgressArrow(stack);
renderFluid(stack, leftPos + 99, topPos + 11);
renderEnergy(stack, leftPos + 112, topPos + 11);
graphics.blit(TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight);
renderBulb(graphics);
renderProgressArrow(graphics);
renderFluid(graphics, leftPos + 99, topPos + 11);
renderEnergy(graphics, leftPos + 112, topPos + 11);
}
@Override
protected void renderLabels(@NotNull PoseStack pPoseStack, int pMouseX, int pMouseY) {
protected void renderLabels(@NotNull GuiGraphics graphics, int pMouseX, int pMouseY) {
int x = (width - imageWidth) / 2;
int y = (height - imageHeight) / 2;
if (MouseUtils.isMouseOver(pMouseX, pMouseY, x + 98, y + 10, 11, 62)) {
FluidTank tank = menu.getBlockEntity().getFluidTank();
List<Component> components = TooltipUtils.getFluidTooltip(tank.getFluid(), 64000);
renderTooltip(pPoseStack, components, Optional.empty(),
pMouseX - x, pMouseY - y);
graphics.renderTooltip(font, components, Optional.empty(), pMouseX - x, pMouseY - y);
}
if (MouseUtils.isMouseOver(pMouseX, pMouseY, x + 111, y + 10, 11, 62)) {
EnergyStorage energy = menu.getBlockEntity().getEnergy();
List<Component> components = TooltipUtils.getEnergyTooltip(energy.getEnergyStored(),
energy.getMaxEnergyStored());
renderTooltip(pPoseStack, components, Optional.empty(), pMouseX - x, pMouseY - y);
graphics.renderTooltip(font, components, Optional.empty(), pMouseX - x, pMouseY - y);
}
}
private void renderEnergy(@NotNull PoseStack stack, int x, int y) {
private void renderEnergy(@NotNull GuiGraphics graphics, int x, int y) {
EnergyStorage energy = menu.getBlockEntity().getEnergy();
if (energy.getEnergyStored() <= 0 || energy.getMaxEnergyStored() <= 0) {
return;
@ -102,10 +97,10 @@ public class InsolatorScreen extends AbstractContainerScreen<InsolatorMenu> {
final int ENERGY_HEIGHT = 60;
int stored = (int) (ENERGY_HEIGHT * ((float) energy.getEnergyStored() / (float) energy.getMaxEnergyStored()));
fillGradient(stack, x, y + (ENERGY_HEIGHT - stored), x + 9, y + 60, 0xffb51500, 0xff600b00);
graphics.fillGradient(x, y + (ENERGY_HEIGHT - stored), x + 9, y + 60, 0xffb51500, 0xff600b00);
}
private void renderFluid(@NotNull PoseStack stack, int x, int y) {
private void renderFluid(@NotNull GuiGraphics graphics, int x, int y) {
FluidStack fluid = menu.getBlockEntity().getFluidTank().getFluid();
if (fluid.getFluid().isSame(Fluids.EMPTY)) {
return;
@ -119,37 +114,38 @@ public class InsolatorScreen extends AbstractContainerScreen<InsolatorMenu> {
int scaled = Math.min(FLUID_HEIGHT, Math.max(amount > 0 ? 1 : 0, (amount * FLUID_HEIGHT) / 64000));
RenderSystem.enableBlend();
stack.pushPose();
stack.translate(x, y, 0);
var pose = graphics.pose();
pose.pushPose();
pose.translate(x, y, 0);
TiledSprite.drawTiledSprite(stack, 9, FLUID_HEIGHT, tint, scaled, sprite, 16);
TiledSprite.drawTiledSprite(pose, 9, FLUID_HEIGHT, tint, scaled, sprite, 16);
stack.popPose();
pose.popPose();
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.disableBlend();
}
private void renderProgressArrow(PoseStack stack) {
private void renderProgressArrow(GuiGraphics graphics) {
if (menu.getBlockEntity().getActive()) {
int ticks = menu.getBlockEntity().getTicks();
if (ticks != 0) {
float ratio = (float) menu.getBlockEntity().getProgress() / (float) ticks;
blit(stack, leftPos + 156, topPos + 28, 176, 0, 8, (int) (25.0f * ratio));
graphics.blit(TEXTURE, leftPos + 156, topPos + 28, 176, 0, 8, (int)(25.0f * ratio));
}
}
}
private void renderBulb(PoseStack stack) {
private void renderBulb(GuiGraphics graphics) {
if (menu.getBlockEntity().getActive()) {
blit(stack, leftPos + 133, topPos + 37, 176, 25, 9, 14);
graphics.blit(TEXTURE, leftPos + 133, topPos + 37, 176, 25, 9, 14);
}
}
@Override
public void render(@NotNull PoseStack stack, int mouseX, int mouseY, float delta) {
renderBackground(stack);
super.render(stack, mouseX, mouseY, delta);
renderTooltip(stack, mouseX, mouseY);
public void render(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float delta) {
renderBackground(graphics);
super.render(graphics, mouseX, mouseY, delta);
renderTooltip(graphics, mouseX, mouseY);
}
private void onDumpPress(Button button) {

View File

@ -2,7 +2,7 @@ package net.banutama.utamacraft.screen.utils;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import com.mojang.math.Matrix4f;
import org.joml.Matrix4f;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.world.inventory.InventoryMenu;

View File

@ -13,10 +13,13 @@ public class ModSounds {
public static final DeferredRegister<SoundEvent> SOUNDS =
DeferredRegister.create(ForgeRegistries.SOUND_EVENTS, Utamacraft.MOD_ID);
public static final RegistryObject<SoundEvent> INSOLATOR =
SOUNDS.register("insolator", () -> new SoundEvent(new ResourceLocation(Utamacraft.MOD_ID, "insolator")));
public static final RegistryObject<SoundEvent> INSOLATOR = registerSoundEvent("insolator");
public static void register(IEventBus eventBus) {
SOUNDS.register(eventBus);
}
private static RegistryObject<SoundEvent> registerSoundEvent(String name) {
return SOUNDS.register(name, () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(Utamacraft.MOD_ID, name)));
}
}

View File

@ -4,6 +4,7 @@ import com.mojang.authlib.GameProfile;
import net.banutama.utamacraft.Utamacraft;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
@ -59,15 +60,20 @@ public class SimpleFakePlayer extends FakePlayer {
HitResult blockHit = null;
if (skipBlock) {
Vec3 to = traceContext.getTo();
blockHit = BlockHitResult.miss(to, traceDirection, new BlockPos(to));
Vec3i toi = new Vec3i((int)to.x, (int)to.y, (int)to.z);
blockHit = BlockHitResult.miss(to, traceDirection, new BlockPos(toi));
} else {
blockHit = BlockGetter.traverseBlocks(traceContext.getFrom(), traceContext.getTo(), traceContext, (clipContext, pos) -> {
if (level.isEmptyBlock(pos)) {
if (level().isEmptyBlock(pos)) {
return null;
}
return new BlockHitResult(new Vec3(pos.getX(), pos.getY(), pos.getZ()), traceDirection, pos, false);
}, clipContext -> BlockHitResult.miss(clipContext.getTo(), traceDirection, new BlockPos(clipContext.getTo())));
}, clipContext -> {
Vec3 to = clipContext.getTo();
Vec3i toi = new Vec3i((int)to.x, (int)to.y, (int)to.z);
return BlockHitResult.miss(clipContext.getTo(), traceDirection, new BlockPos(toi));
});
}
if (skipEntity) {
@ -75,7 +81,7 @@ public class SimpleFakePlayer extends FakePlayer {
}
List<Entity> entities =
level.getEntities(
level().getEntities(
this,
this.getBoundingBox()
.expandTowards(look.x * range, look.y * range, look.z * range)
@ -137,12 +143,12 @@ public class SimpleFakePlayer extends FakePlayer {
HitResult hit = findHit(range, skipEntity, skipBlock, entityFilter);
if (hit instanceof BlockHitResult blockHit) {
InteractionResult res =
gameMode.useItemOn(this, level, getMainHandItem(), InteractionHand.MAIN_HAND, blockHit);
gameMode.useItemOn(this, level(), getMainHandItem(), InteractionHand.MAIN_HAND, blockHit);
if (res.consumesAction()) {
return res;
}
return gameMode.useItem(this, level, getMainHandItem(), InteractionHand.MAIN_HAND);
return gameMode.useItem(this, level(), getMainHandItem(), InteractionHand.MAIN_HAND);
} else if (hit instanceof EntityHitResult) {
// TODO: Interact with an entity?
return InteractionResult.FAIL;

View File

@ -0,0 +1,23 @@
package net.banutama.utamacraft.world;
import net.banutama.utamacraft.Utamacraft;
import net.banutama.utamacraft.world.feature.ModConfiguredFeatures;
import net.banutama.utamacraft.world.feature.ModPlacedFeatures;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistrySetBuilder;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraftforge.common.data.DatapackBuiltinEntriesProvider;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
public class ModWorldgenProvider extends DatapackBuiltinEntriesProvider {
public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder()
.add(Registries.CONFIGURED_FEATURE, ModConfiguredFeatures::bootstrap)
.add(Registries.PLACED_FEATURE, ModPlacedFeatures::bootstrap);
public ModWorldgenProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
super(output, registries, BUILDER, Set.of(Utamacraft.MOD_ID));
}
}

View File

@ -1,38 +1,43 @@
package net.banutama.utamacraft.world.feature;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import net.banutama.utamacraft.Utamacraft;
import net.banutama.utamacraft.block.custom.ModBlocks;
import net.minecraft.core.Registry;
import net.minecraft.data.worldgen.features.OreFeatures;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;
import net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest;
import net.minecraft.world.level.levelgen.structure.templatesystem.TagMatchTest;
import java.util.List;
public class ModConfiguredFeatures {
public static final DeferredRegister<ConfiguredFeature<?, ?>> CONFIGURED_FEATURES =
DeferredRegister.create(Registry.CONFIGURED_FEATURE_REGISTRY, Utamacraft.MOD_ID);
public static final ResourceKey<ConfiguredFeature<?, ?>> TUNGSTEN_ORE_KEY = registerKey("tungsten_ore");
public static final Supplier<List<OreConfiguration.TargetBlockState>> OVERWORLD_TUNGSTEN_ORES =
Suppliers.memoize(() -> {
return List.of(
OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, ModBlocks.TUNGSTEN_ORE.get().defaultBlockState()),
OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, ModBlocks.DEEPSLATE_TUNGSTEN_ORE.get().defaultBlockState())
);
});
public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
RuleTest stoneRep = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES);
RuleTest deepslateRep = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES);
public static final RegistryObject<ConfiguredFeature<?, ?>> TUNGSTEN_ORE =
CONFIGURED_FEATURES.register("tungsten_ore", () -> {
return new ConfiguredFeature<>(Feature.ORE, new OreConfiguration(OVERWORLD_TUNGSTEN_ORES.get(), 7));
});
List<OreConfiguration.TargetBlockState> overworldOres =
List.of(
OreConfiguration.target(stoneRep, ModBlocks.TUNGSTEN_ORE.get().defaultBlockState()),
OreConfiguration.target(deepslateRep, ModBlocks.DEEPSLATE_TUNGSTEN_ORE.get().defaultBlockState()));
public static void register(IEventBus bus) {
CONFIGURED_FEATURES.register(bus);
register(context, TUNGSTEN_ORE_KEY, Feature.ORE, new OreConfiguration(overworldOres, 9));
}
public static ResourceKey<ConfiguredFeature<?, ?>> registerKey(String name) {
return ResourceKey.create(Registries.CONFIGURED_FEATURE, new ResourceLocation(Utamacraft.MOD_ID, name));
}
private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(BootstapContext<ConfiguredFeature<?, ?>> context,
ResourceKey<ConfiguredFeature<?, ?>> key,
F feature, FC configuration) {
context.register(key, new ConfiguredFeature<>(feature, configuration));
}
}

View File

@ -2,8 +2,15 @@ package net.banutama.utamacraft.world.feature;
import net.banutama.utamacraft.Utamacraft;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
import net.minecraft.world.level.levelgen.placement.*;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
@ -12,29 +19,23 @@ import net.minecraftforge.registries.RegistryObject;
import java.util.List;
public class ModPlacedFeatures {
public static final DeferredRegister<PlacedFeature> PLACED_FEATURES =
DeferredRegister.create(Registry.PLACED_FEATURE_REGISTRY, Utamacraft.MOD_ID);
public static final ResourceKey<PlacedFeature> TUNGSTEN_ORE_PLACED_KEY = registerKey("tungsten_ore_placed");
public static final RegistryObject<PlacedFeature> TUNGSTEN_ORE_PLACED =
PLACED_FEATURES.register("tungsten_ore_placed", () -> new PlacedFeature(
ModConfiguredFeatures.TUNGSTEN_ORE.getHolder().get(),
commonOrePlacement(7,
HeightRangePlacement.triangle(
VerticalAnchor.aboveBottom(-80),
VerticalAnchor.aboveBottom(80)
)
)
));
public static void bootstrap(BootstapContext<PlacedFeature> context) {
HolderGetter<ConfiguredFeature<?, ?>> cf = context.lookup(Registries.CONFIGURED_FEATURE);
public static void register(IEventBus bus) {
PLACED_FEATURES.register(bus);
var p = HeightRangePlacement.uniform(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(80));
register(context, TUNGSTEN_ORE_PLACED_KEY, cf.getOrThrow(ModConfiguredFeatures.TUNGSTEN_ORE_KEY), p);
}
private static List<PlacementModifier> commonOrePlacement(int veinsPerChunk, PlacementModifier modifier) {
return orePlacement(CountPlacement.of(veinsPerChunk), modifier);
private static ResourceKey<PlacedFeature> registerKey(String name) {
return ResourceKey.create(Registries.PLACED_FEATURE, new ResourceLocation(Utamacraft.MOD_ID, name));
}
private static List<PlacementModifier> orePlacement(PlacementModifier a, PlacementModifier b) {
return List.of(a, InSquarePlacement.spread(), b, BiomeFilter.biome());
private static void register(BootstapContext<PlacedFeature> context,
ResourceKey<PlacedFeature> key,
Holder<ConfiguredFeature<?, ?>> configuration,
PlacementModifier modifier) {
context.register(key, new PlacedFeature(configuration, List.of(modifier)));
}
}

View File

@ -25,7 +25,7 @@
"item.utamacraft.tungsten_block": "Tungsten Block",
"item.utamacraft.tungsten_ingot": "Tungsten Ingot",
"item.utamacraft.tungsten_raw": "Raw Tungsten",
"itemGroup.utamacraft_tab": "Utamacraft",
"creativetab.utamacraft_tab": "Utamacraft",
"tooltip.utamacraft.energy": "Energy",
"tooltip.utamacraft.energy.amount": "%s FE",
"tooltip.utamacraft.energy.amount.with_capacity": "%s / %s FE",

View File

@ -0,0 +1,11 @@
{
"entities": ["minecraft:player"],
"slots": [
"belt",
"body",
"charm",
"head",
"necklace",
"ring"
]
}

View File

@ -0,0 +1,4 @@
{
"size": 2,
"add_cosmetic": true
}

View File

@ -1,5 +1,8 @@
{
"homepage": "https://git.blakerain.com/bans-minecraft/utamacraft",
"1.20.1": {
"0.3.0-1.20.1": "Migrate to Minecraft 1.20.1"
},
"1.19.2": {
"0.2.9-1.19": "Added the teleportation peripheral",
"0.2.8-1.19": "Fixes for various peripherals",
@ -16,6 +19,8 @@
"0.0.1-1.19": "Initial release"
},
"promos": {
"1.20.1-latest": "0.3.0-1.20.1",
"1.20.1-recommended": "0.3.0-1.20.1"
"1.19.2-latest": "0.2.9-1.19",
"1.19.2-recommended": "0.2.9-1.19"
}