Skip to content

Commit

Permalink
1.21 Port XXV
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Aug 10, 2024
1 parent 5242a86 commit f6b8815
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 102 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ neoForge {
version = project.neo_version

parchment {
minecraftVersion = project.parchment_minecraft_version
mappingsVersion = project.parchment_version
minecraftVersion = project.minecraft_version
}

accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
Expand Down Expand Up @@ -105,8 +105,8 @@ repositories {
dependencies {
jarJar(implementation("com.tterrag.registrate:Registrate:${registrate_version}"))

compileOnly("dev.engine_room.flywheel:flywheel-forge-api-${minecraft_version}:${flywheel_version}")
jarJar(runtimeOnly("dev.engine_room.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}"))
compileOnly("dev.engine_room.flywheel:flywheel-forge-api-${flywheel_minecraft_version}:${flywheel_version}")
jarJar(runtimeOnly("dev.engine_room.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}"))

compileOnly("mezz.jei:jei-${jei_minecraft_version}-common-api:${jei_version}")
compileOnly("mezz.jei:jei-${jei_minecraft_version}-neoforge-api:${jei_version}")
Expand Down
9 changes: 6 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ mod_id = create
maven_group = com.simibubi.create

# Mod Dependencies
minecraft_version = 1.21
minecraft_version = 1.21.1
minecraft_version_range=[1.21,1.21.1)

neo_version = 21.0.167
neo_version = 21.1.4
neo_version_range=[21.0.0-beta,)
loader_version_range=[4,)

parchment_version = 2024.06.23
# Set to default if you want it to use the same version as what `minecraft_version` is set to
parchment_minecraft_version = 1.21
parchment_version = 2024.07.28

# From maven.ithundxr.dev/snapshots
registrate_version = MC1.21-1.3.0+49

# From maven.ithundxr.dev/hidden
flywheel_minecraft_version = 1.21
flywheel_version = 1.0.0-beta-fork.4
flywheel_version_range = [1.0.0-alpha,2.0)

Expand Down
86 changes: 70 additions & 16 deletions src/main/java/com/simibubi/create/AllEnchantments.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,76 @@
package com.simibubi.create;

import com.simibubi.create.content.equipment.potatoCannon.PotatoProjectileTypeManager;

import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.HolderSet;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.worldgen.BootstrapContext;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.entity.EquipmentSlotGroup;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentEffectComponents;
import net.minecraft.world.item.enchantment.LevelBasedValue;
import net.minecraft.world.item.enchantment.effects.SetValue;
import net.minecraft.world.level.storage.loot.predicates.MatchTool;

public class AllEnchantments {
public static final ResourceKey<Enchantment>
POTATO_RECOVERY = key("potato_recovery"),
CAPACITY = key("capacity");

private static ResourceKey<Enchantment> key(String name) {
return ResourceKey.create(Registries.ENCHANTMENT, Create.asResource(name));
}

public static void bootstrap(BootstrapContext<Enchantment> context) {
HolderGetter<Item> itemHolderGetter = context.lookup(Registries.ITEM);

register(
context,
POTATO_RECOVERY,
Enchantment.enchantment(
Enchantment.definition(
HolderSet.direct(AllItems.POTATO_CANNON),
10,
3,
Enchantment.dynamicCost(15, 15),
Enchantment.dynamicCost(45, 15),
1,
EquipmentSlotGroup.MAINHAND
)
).withEffect(
EnchantmentEffectComponents.AMMO_USE,
new SetValue(LevelBasedValue.perLevel(0.0F, 33.3333333333F)),
MatchTool.toolMatches(
ItemPredicate.Builder.item().of(
PotatoProjectileTypeManager.getItems().toArray(Item[]::new)
)
)
)
);

register(
context,
CAPACITY,
Enchantment.enchantment(
Enchantment.definition(
itemHolderGetter.getOrThrow(AllTags.AllItemTags.PRESSURIZED_AIR_SOURCES.tag),
10,
3,
Enchantment.dynamicCost(15, 15),
Enchantment.dynamicCost(45, 15),
1,
EquipmentSlotGroup.MAINHAND
)
)
);
}

// fixme waiting for Registrate
/* public static final RegistryEntry<Enchantment, PotatoRecoveryEnchantment> POTATO_RECOVERY = REGISTRATE.object("potato_recovery")
.enchantment(EnchantmentCategory.BOW, PotatoRecoveryEnchantment::new)
.addSlots(EquipmentSlot.MAINHAND, EquipmentSlot.OFFHAND)
.lang("Potato Recovery")
.rarity(Rarity.UNCOMMON)
.register();
public static final RegistryEntry<Enchantment, CapacityEnchantment> CAPACITY = REGISTRATE.object("capacity")
.enchantment(EnchantmentCategory.ARMOR_CHEST, CapacityEnchantment::new)
.addSlots(EquipmentSlot.CHEST)
.lang("Capacity")
.rarity(Rarity.COMMON)
.register();*/

public static void register() {}
private static void register(BootstrapContext<Enchantment> context, ResourceKey<Enchantment> key, Enchantment.Builder builder) {
context.register(key, builder.build(key.location()));
}

}
1 change: 0 additions & 1 deletion src/main/java/com/simibubi/create/Create.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public static void onCtor(IEventBus modEventBus, ModContainer modContainer) {
AllMenuTypes.register();
AllEntityTypes.register();
AllBlockEntityTypes.register();
AllEnchantments.register();
AllRecipeTypes.register(modEventBus);
AllParticleTypes.register(modEventBus);
AllStructureProcessorTypes.register(modEventBus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.simibubi.create.AllBlockEntityTypes;
import com.simibubi.create.AllDataComponents;
import com.simibubi.create.AllEnchantments;
import com.simibubi.create.AllShapes;
import com.simibubi.create.content.kinetics.base.HorizontalKineticBlock;
import com.simibubi.create.foundation.block.IBE;
Expand Down Expand Up @@ -108,8 +109,7 @@ public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, LivingEnt
if (stack == null)
return;
withBlockEntityDo(worldIn, pos, be -> {
// fixme waiting for Registrate
// be.setCapacityEnchantLevel(stack.getEnchantmentLevel(AllEnchantments.CAPACITY.get()));
be.setCapacityEnchantLevel(stack.getEnchantmentLevel(worldIn.holderOrThrow(Registries.ENCHANTMENT).value().getHolderOrThrow(AllEnchantments.CAPACITY)));
be.setAirLevel(stack.getOrDefault(AllDataComponents.BACKTANK_AIR, 0));
if (stack.isEnchanted())
be.setEnchantmentTag(stack.getAllEnchantments(worldIn.registryAccess().lookupOrThrow(Registries.ENCHANTMENT)));
Expand Down Expand Up @@ -158,10 +158,7 @@ public ItemStack getCloneItemStack(LevelReader pLevel, BlockPos pos, BlockState
ItemEnchantments enchants = blockEntityOptional.map(BacktankBlockEntity::getEnchantments)
.orElse(ItemEnchantments.EMPTY);
if (!enchants.isEmpty()) {
ItemEnchantments.Mutable merged = new ItemEnchantments.Mutable(enchants);
stack.getTagEnchantments().entrySet().forEach(e -> merged.set(e.getKey(), e.getIntValue()));

stack.set(DataComponents.ENCHANTMENTS, merged.toImmutable());
enchants.entrySet().forEach(e -> stack.enchant(e.getKey(), e.getIntValue()));
}

blockEntityOptional.map(BacktankBlockEntity::getCustomName).ifPresent(customName ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.simibubi.create.content.equipment.armor;

import java.util.List;
import java.util.Map;

import com.simibubi.create.foundation.advancement.AllAdvancements;

import net.minecraft.core.Holder;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
Expand All @@ -20,6 +20,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.enchantment.ItemEnchantments;
import net.minecraft.world.level.Level;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
Expand All @@ -35,26 +36,24 @@ public DivingHelmetItem(Holder<ArmorMaterial> material, Properties properties, R
}

@Override
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) {
if (enchantment == Enchantments.AQUA_AFFINITY) {
public boolean supportsEnchantment(ItemStack stack, Holder<Enchantment> enchantment) {
if (enchantment.is(Enchantments.AQUA_AFFINITY))
return false;
}
return super.canApplyAtEnchantingTable(stack, enchantment);
return super.supportsEnchantment(stack, enchantment);
}

@Override
public int getEnchantmentLevel(ItemStack stack, Enchantment enchantment) {
if (enchantment == Enchantments.AQUA_AFFINITY) {
public int getEnchantmentLevel(ItemStack stack, Holder<Enchantment> enchantment) {
if (enchantment.is(Enchantments.AQUA_AFFINITY)) {
return 1;
}
return super.getEnchantmentLevel(stack, enchantment);
}

@Override
public Map<Enchantment, Integer> getAllEnchantments(ItemStack stack) {
Map<Enchantment, Integer> map = super.getAllEnchantments(stack);
map.put(Enchantments.AQUA_AFFINITY, 1);
return map;
public ItemEnchantments getAllEnchantments(ItemStack stack, HolderLookup.RegistryLookup<Enchantment> lookup) {
stack.enchant(lookup.getOrThrow(Enchantments.AQUA_AFFINITY), 1);
return super.getAllEnchantments(stack, lookup);
}

public static boolean isWornBy(Entity entity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import java.util.function.Consumer;
import java.util.function.Predicate;

import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;

import org.jetbrains.annotations.Nullable;

import com.simibubi.create.AllEnchantments;
Expand All @@ -31,6 +28,9 @@
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.Mth;
Expand Down Expand Up @@ -68,18 +68,18 @@ public boolean canAttackBlock(BlockState state, Level world, BlockPos pos, Playe
}

@Override
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) {
if (enchantment == Enchantments.POWER_ARROWS)
public boolean supportsEnchantment(ItemStack stack, Holder<Enchantment> enchantment) {
if (enchantment.is(Enchantments.POWER))
return true;
if (enchantment == Enchantments.PUNCH_ARROWS)
if (enchantment.is(Enchantments.PUNCH))
return true;
if (enchantment == Enchantments.FLAMING_ARROWS)
if (enchantment.is(Enchantments.FLAME))
return true;
if (enchantment == Enchantments.MOB_LOOTING)
if (enchantment.is(Enchantments.LOOTING))
return true;
if (enchantment == AllEnchantments.POTATO_RECOVERY.get())
if (enchantment.is(AllEnchantments.POTATO_RECOVERY))
return true;
return super.canApplyAtEnchantingTable(stack, enchantment);
return super.supportsEnchantment(stack, enchantment);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.jetbrains.annotations.NotNull;

import com.simibubi.create.AllEnchantments;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.damageTypes.CreateDamageSources;
Expand Down Expand Up @@ -32,7 +33,6 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
Expand Down Expand Up @@ -74,17 +74,9 @@ public PotatoCannonProjectileType getProjectileType() {
public void setEnchantmentEffectsFromCannon(ItemStack cannon) {
Registry<Enchantment> enchantmentRegistry = registryAccess().registryOrThrow(Registries.ENCHANTMENT);

int power = cannon.getEnchantmentLevel(enchantmentRegistry.getHolderOrThrow(Enchantments.POWER));
int punch = cannon.getEnchantmentLevel(enchantmentRegistry.getHolderOrThrow(Enchantments.PUNCH));
int flame = cannon.getEnchantmentLevel(enchantmentRegistry.getHolderOrThrow(Enchantments.FLAME));
int recovery = 0;// fixme waiting for Registrate cannon.getEnchantmentLevel(AllEnchantments.POTATO_RECOVERY.get());

if (power > 0)
additionalDamageMult = 1 + power * .2f;
if (punch > 0)
additionalKnockback = punch * .5f;
if (flame > 0)
igniteForSeconds(100);
int recovery = cannon.getEnchantmentLevel(enchantmentRegistry.getHolderOrThrow(AllEnchantments.POTATO_RECOVERY));

// fixme checkover if this is actually needed anymore
if (recovery > 0)
recoveryChance = .125f + recovery * .125f;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;

import com.google.gson.Gson;
Expand Down Expand Up @@ -52,6 +53,10 @@ public static PotatoCannonProjectileType getTypeForItem(Item item) {
return ITEM_TO_TYPE_MAP.get(item);
}

public static Set<Item> getItems() {
return ITEM_TO_TYPE_MAP.keySet();
}

public static Optional<PotatoCannonProjectileType> getTypeForStack(ItemStack item) {
if (item.isEmpty())
return Optional.empty();
Expand Down

This file was deleted.

Loading

0 comments on commit f6b8815

Please sign in to comment.