Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
modImplementation(ctnh.createliquidfuel)
// modImplementation(ctnh.createoreexcavation)
modImplementation(ctnh.creatediesel)
modImplementation(ctnh.immersiveaircraft)
modImplementation(ctnh.createnewage)

// season
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/github/cpearl0/ctnhcore/CTNHCoreGTAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import io.github.cpearl0.ctnhcore.data.recipe.*;
import io.github.cpearl0.ctnhcore.data.recipe.chain.*;
import io.github.cpearl0.ctnhcore.data.recipe.cogniassembly.WetwareCircuit;
import io.github.cpearl0.ctnhcore.data.recipe.create.CreateMetallurgyRecipes;
import io.github.cpearl0.ctnhcore.data.recipe.create.CreateOreExcavationRecipes;
import io.github.cpearl0.ctnhcore.data.recipe.create.CreateRecipes;
import io.github.cpearl0.ctnhcore.data.recipe.generated.HyperRotorRecipes;
import io.github.cpearl0.ctnhcore.data.recipe.immersiveaircraft.ImmersiveAircraftRecipes;
import io.github.cpearl0.ctnhcore.data.recipe.mana.DigesterRecipes;
import io.github.cpearl0.ctnhcore.data.recipe.mana.EternalGardenRecipes;
import io.github.cpearl0.ctnhcore.data.recipe.mana.MiscManaRecipes;
Expand All @@ -15,6 +18,7 @@
import io.github.cpearl0.ctnhcore.data.recipe.modmodify.EIORecipes;
import io.github.cpearl0.ctnhcore.data.recipe.modmodify.omnicells.QuantumOmniRecipes;
import io.github.cpearl0.ctnhcore.data.recipe.multiblock.*;
import io.github.cpearl0.ctnhcore.data.recipe.tconstruct.TConstructRecipes;
import io.github.cpearl0.ctnhcore.registry.*;
import io.github.cpearl0.ctnhcore.registry.machines.CTNHMachines;

Expand Down Expand Up @@ -118,6 +122,8 @@ public void addRecipes(Consumer<FinishedRecipe> provider) {
NaquadahReactorRecipes.init(provider);
DefaultRecipes.init(provider);
CrafttableScriptRecipe.init(provider);
ApothesisScriptRecipe.init(provider);
SophisticatedBackpacksScriptRecipe.init(provider);
AlumiumChain.init(provider);
PlatinumLine.init(provider);
BrineChain.init(provider);
Expand Down Expand Up @@ -153,6 +159,10 @@ public void addRecipes(Consumer<FinishedRecipe> provider) {
ZirconChain.init(provider);

CreateRecipes.init(provider);
ImmersiveAircraftRecipes.init(provider);
CreateOreExcavationRecipes.init(provider);
CreateMetallurgyRecipes.init(provider);
TConstructRecipes.init(provider);

CasingRecipes.init(provider);
UHVPartsRecipe.init(provider);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package io.github.cpearl0.ctnhcore.common.tconstruct;
package io.github.cpearl0.ctnhcore;

import io.github.cpearl0.ctnhcore.CTNHCore;
import io.github.cpearl0.ctnhcore.common.tconstruct.materials.CTNHConstructMaterialRecipes;
import io.github.cpearl0.ctnhcore.common.tconstruct.modifier.FortificationModifier;
import io.github.cpearl0.ctnhcore.common.tconstruct.modifier.GlobalTraveller;
import io.github.cpearl0.ctnhcore.common.tconstruct.recipes.CTNHConstructCastingRecipes;
import io.github.cpearl0.ctnhcore.common.tconstruct.recipes.CTNHConstructMeltingRecipes;
import io.github.cpearl0.ctnhcore.common.tconstruct.recipes.CTNHConstructModifierRecipes;
import io.github.cpearl0.ctnhcore.common.tconstruct.modifier.SnowcityModifier;
import io.github.cpearl0.ctnhcore.data.recipe.tconstruct.CTNHConstructCastingRecipes;
import io.github.cpearl0.ctnhcore.data.recipe.tconstruct.CTNHConstructMeltingRecipes;
import io.github.cpearl0.ctnhcore.data.recipe.tconstruct.CTNHConstructModifierRecipes;
import io.github.cpearl0.ctnhcore.data.provider.CTNHConstructMaterialPartTextureGenerator;
import io.github.cpearl0.ctnhcore.data.provider.CTNHConstructMaterialRenderInfoProvider;
import io.github.cpearl0.ctnhcore.data.provider.CTNHConstructMaterialSpriteProvider;
Expand All @@ -23,7 +24,7 @@
import slimeknights.tconstruct.library.addon.TiCAddon;

@TiCAddon(requiredMods = CTNHCore.MODID)
public class CTNHTiCAddon implements ITiCAddon, ITiCStaticModifierAddon {
public class CTNHCoreTiCAddon implements ITiCAddon, ITiCStaticModifierAddon {

@Override
public String addonModId() {
Expand All @@ -33,6 +34,8 @@ public String addonModId() {
@Override
public void registerStaticModifiers(StaticModifierRegistrar registrar) {
registrar.register("global_traveller", GlobalTraveller::new);
registrar.register("snow_city", SnowcityModifier::new);
registrar.register("fortification", FortificationModifier::new);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.gregtechceu.gtceu.GTCEu;

import net.createmod.ponder.api.scene.SceneBuilder;

import tech.vixhentx.mcmod.ctnhlib.client.ponder.CTNHPonderSceneBuilder;

import static io.github.cpearl0.ctnhcore.registry.CTNHRegistration.REGISTRATE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

public final class CTNHCorePonderScenes {

private CTNHCorePonderScenes() {
}
private CTNHCorePonderScenes() {}

public static void register(PonderSceneRegistrationHelper<ResourceLocation> helper) {
helper.forComponents(CTPPMultiblockMachines.BIG_DAM.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import io.github.cpearl0.ctnhcore.CTNHConfig;
import io.github.cpearl0.ctnhcore.CTNHCore;
import io.github.cpearl0.ctnhcore.client.ponder.CTNHCorePonderPlugin;
import io.github.cpearl0.ctnhcore.common.world.CTNHChunkLoading;
import io.github.cpearl0.ctnhcore.data.CTNHCoreDatagen;
import io.github.cpearl0.ctnhcore.client.ponder.CTNHCorePonderPlugin;
import io.github.cpearl0.ctnhcore.data.materials.AeCrystalScienceMaterials;
import io.github.cpearl0.ctnhcore.data.materials.AeOmniMaterials;
import io.github.cpearl0.ctnhcore.registry.*;
Expand All @@ -14,7 +14,6 @@
import io.github.cpearl0.ctnhcore.registry.machines.GTMachineModify;
import io.github.cpearl0.ctnhcore.registry.material.CTNHMaterials;
import io.github.cpearl0.ctnhcore.registry.material.GTMaterialAddon;
import tech.vixhentx.mcmod.ctnhlib.client.ponder.CTNHPonderLang;

import com.gregtechceu.gtceu.api.GTCEuAPI;
import com.gregtechceu.gtceu.api.data.DimensionMarker;
Expand All @@ -41,6 +40,8 @@
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

import tech.vixhentx.mcmod.ctnhlib.client.ponder.CTNHPonderLang;

import java.util.Set;

@Mod.EventBusSubscriber(modid = CTNHCore.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
Expand Down Expand Up @@ -135,7 +136,7 @@ public static void gatherData(GatherDataEvent event) {
generator.addProvider(true, new BiomeTagsLoader(packOutput, registries, existingFileHelper));
DatapackBuiltinEntriesProvider provider = generator.addProvider(true, new DatapackBuiltinEntriesProvider(
packOutput, registries, new RegistrySetBuilder()
.add(Registries.DAMAGE_TYPE, CTNHDamageTypes::bootstrap),
.add(Registries.DAMAGE_TYPE, CTNHDamageTypes::bootstrap),
set));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package io.github.cpearl0.ctnhcore.common.tconstruct.modifier;

import io.github.cpearl0.ctnhcore.CTNHCore;
import io.github.cpearl0.ctnhcore.registry.CTNHConstructModifier;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;

import com.ctnhlang.CN;
import com.ctnhlang.Category;
import com.ctnhlang.Domain;
import com.ctnhlang.EN;
import com.ctnhlang.Key;
import slimeknights.tconstruct.library.modifiers.Modifier;
import slimeknights.tconstruct.library.modifiers.ModifierEntry;
import slimeknights.tconstruct.library.modifiers.ModifierHooks;
import slimeknights.tconstruct.library.modifiers.hook.armor.OnAttackedModifierHook;
import slimeknights.tconstruct.library.module.ModuleHookMap;
import slimeknights.tconstruct.library.tools.context.EquipmentContext;
import slimeknights.tconstruct.library.tools.helper.ModifierUtil;
import slimeknights.tconstruct.library.tools.nbt.IToolStackView;
import tech.vixhentx.mcmod.ctnhlib.langprovider.Lang;
import twilightforest.capabilities.CapabilityList;

@Domain("modifier")
@Category("fortification")
public class FortificationModifier extends Modifier implements OnAttackedModifierHook {

private static final String SHIELD_COOLDOWN = CTNHCore.MODID + ":fortification_shield_cooldown";
private static final int INITIAL_COOLDOWN = 600;

@EN("Fortification")
@CN("护盾")
@Key("modifier.ctnhcore.fortification")
static Lang name;

@EN("Calls on Twilight Forest shields when hurt.")
@CN("受伤时调用暮色森林护盾。")
@Key("modifier.ctnhcore.fortification.description")
static Lang description;

@Override
protected void registerHooks(ModuleHookMap.Builder hookBuilder) {
hookBuilder.addHook(this, ModifierHooks.ON_ATTACKED);
}

@Override
public void onAttacked(IToolStackView tool, ModifierEntry modifier, EquipmentContext context,
EquipmentSlot slotType, DamageSource source, float amount, boolean isDirectDamage) {
if (context.getEntity() instanceof Player player) {
applyShield(player);
}
}

public static void tickCooldown(Player player) {
CompoundTag data = player.getPersistentData();
if (!data.contains(SHIELD_COOLDOWN)) {
data.putInt(SHIELD_COOLDOWN, INITIAL_COOLDOWN);
return;
}
int cooldown = data.getInt(SHIELD_COOLDOWN);
if (cooldown > 0) {
data.putInt(SHIELD_COOLDOWN, cooldown - 1);
}
}

public static void applyShield(Player player) {
if (player.level().isClientSide) return;
int totalLevel = getTotalLevel(player);
if (totalLevel <= 0) return;

CompoundTag data = player.getPersistentData();
if (data.getInt(SHIELD_COOLDOWN) > 0) return;

// 迁移自 kubejs/server_scripts/src/tconstruct/modiifiers/fortification.js;直接调用暮色森林能力,替代原指令。
player.getCapability(CapabilityList.SHIELDS)
.ifPresent(shields -> shields.setShields(totalLevel, true));
int cooldown = Math.max(400, (int) (100 * (1 - 0.05 * totalLevel)));
data.putInt(SHIELD_COOLDOWN, cooldown);
}

private static int getTotalLevel(Player player) {
int level = getLevel(player.getMainHandItem()) + getLevel(player.getOffhandItem());
for (EquipmentSlot slot : new EquipmentSlot[] { EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS,
EquipmentSlot.FEET }) {
level += getLevel(player.getItemBySlot(slot));
}
return level;
}

private static int getLevel(ItemStack stack) {
if (stack.isEmpty()) return 0;
return ModifierUtil.getModifierLevel(stack, CTNHConstructModifier.Ids.FORTIFICATION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.github.cpearl0.ctnhcore.common.tconstruct.modifier;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;

import com.ctnhlang.CN;
import com.ctnhlang.Category;
import com.ctnhlang.Domain;
import com.ctnhlang.EN;
import com.ctnhlang.Key;
import slimeknights.tconstruct.library.modifiers.Modifier;
import slimeknights.tconstruct.library.modifiers.ModifierEntry;
import slimeknights.tconstruct.library.modifiers.ModifierHooks;
import slimeknights.tconstruct.library.modifiers.hook.combat.MeleeHitModifierHook;
import slimeknights.tconstruct.library.module.ModuleHookMap;
import slimeknights.tconstruct.library.tools.context.ToolAttackContext;
import slimeknights.tconstruct.library.tools.helper.ModifierUtil;
import slimeknights.tconstruct.library.tools.nbt.IToolStackView;
import tech.vixhentx.mcmod.ctnhlib.langprovider.Lang;

@Domain("modifier")
@Category("snowcity")
public class SnowcityModifier extends Modifier implements MeleeHitModifierHook {

@EN("Snowcity")
@CN("斯诺大习题")
@Key("modifier.ctnhcore.snowcity")
static Lang name;

@EN("Has a chance to drop gold when attacking.")
@CN("攻击时概率掉落金。")
@Key("modifier.ctnhcore.snowcity.description")
static Lang description;

@Override
protected void registerHooks(ModuleHookMap.Builder hookBuilder) {
hookBuilder.addHook(this, ModifierHooks.MELEE_HIT);
}

@Override
public void afterMeleeHit(IToolStackView tool, ModifierEntry modifier, ToolAttackContext context,
float damageDealt) {
Level level = context.getLevel();
Entity target = context.getTarget();
if (level.isClientSide || context.getPlayerAttacker() == null || target == null) return;

// 迁移自 kubejs/server_scripts/src/tconstruct/modiifiers/snowcity.js。
int chance = modifier.getLevel() * 10;
double x = target.getX() + level.random.nextInt(3) - 1;
double y = target.getY() + 1;
double z = target.getZ() + level.random.nextInt(3) - 1;
if (level.random.nextInt(100) < chance) {
ModifierUtil.dropItem(level, x, y, z, new ItemStack(Items.GOLD_INGOT));
}
if (level.random.nextInt(1000) < chance) {
ModifierUtil.dropItem(level, x, y, z, new ItemStack(Items.GOLD_BLOCK));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ protected void addModifiers() {
buildModifier(CTNHConstructModifier.Ids.GLOBAL_TRAVELLER)
.levelDisplay(ModifierLevelDisplay.NO_LEVELS)
.build();
buildModifier(CTNHConstructModifier.Ids.SNOW_CITY)
.build();
buildModifier(CTNHConstructModifier.Ids.FORTIFICATION)
.build();
}
}
Loading
Loading