Files

142 lines
8.1 KiB
PowerShell

# ============================================================
# Wave Migration Script
# Generated by generate_wave_script.py on 2026-03-16
# Source: tools/migration/mc_type_mappings.json
# ============================================================
. (Join-Path $PSScriptRoot 'Copy-Recursive.ps1')
. (Join-Path $PSScriptRoot 'Nuke-Imports.ps1')
. (Join-Path $PSScriptRoot 'Symbol-Swap.ps1')
. (Join-Path $PSScriptRoot 'Static-Transform.ps1')
. (Join-Path $PSScriptRoot 'Generate-Stubs.ps1')
. (Join-Path $PSScriptRoot 'Dedupe-Imports.ps1')
. (Join-Path $PSScriptRoot 'Build-Report.ps1')
# ============================================================
# STEP 2: Nuke MC imports
# ============================================================
Nuke-Imports -Directory 'core/src/main/java' -ForbiddenPrefixes @(
'net.minecraft.',
'cpw.mods.',
'net.minecraftforge.',
'noppes.npcs.entity.',
'noppes.npcs.client.',
'noppes.npcs.mixin.',
'kamkeel.npcs.network.',
'kamkeel.npcs.entity.',
'noppes.npcs.containers.',
'noppes.npcs.scripted.',
'noppes.npcs.janino.',
'noppes.npcs.wrapper.',
'noppes.npcs.blocks.',
'noppes.npcs.items.',
'noppes.npcs.ai.'
)
# ============================================================
# STEP 3: Symbol-Swap — replace MC types with PA abstractions
# ============================================================
Symbol-Swap -Directory 'core/src/main/java' -Swaps @(
@('NBTTagCompound', 'INbt', 'net.minecraft.nbt.NBTTagCompound', 'noppes.npcs.api.INbt'),
@('EntityPlayer', 'IPlayer', 'net.minecraft.entity.player.EntityPlayer', 'noppes.npcs.api.entity.IPlayer'),
@('EntityPlayerMP', 'IPlayer', 'net.minecraft.entity.player.EntityPlayerMP', 'noppes.npcs.api.entity.IPlayer'),
@('Entity', 'IEntity', 'net.minecraft.entity.Entity', 'noppes.npcs.api.entity.IEntity'),
@('ItemStack', 'IItemStack', 'net.minecraft.item.ItemStack', 'noppes.npcs.api.item.IItemStack'),
@('EntityLivingBase', 'IEntityLivingBase', 'net.minecraft.entity.EntityLivingBase', 'noppes.npcs.api.entity.IEntityLivingBase'),
@('World', 'IWorld', 'net.minecraft.world.World', 'noppes.npcs.api.IWorld'),
@('NBTTagList', 'INbtList', 'net.minecraft.nbt.NBTTagList', 'noppes.npcs.api.INbtList'),
@('DamageSource', 'IDamageSource', 'net.minecraft.util.DamageSource', 'noppes.npcs.api.IDamageSource'),
@('WorldServer', 'IWorld', 'net.minecraft.world.WorldServer', 'noppes.npcs.api.IWorld'),
@('EntityLiving', 'IEntityLiving', 'net.minecraft.entity.EntityLiving', 'noppes.npcs.api.entity.IEntityLiving'),
@('ResourceLocation', 'IResourceLocation', 'net.minecraft.util.ResourceLocation', 'noppes.npcs.api.IResourceLocation'),
@('AxisAlignedBB', 'IBoundingBox', 'net.minecraft.util.AxisAlignedBB', 'noppes.npcs.api.IBoundingBox'),
@('ICommandSender', 'ICommandSender', 'net.minecraft.command.ICommandSender', 'noppes.npcs.api.ICommandSender'),
@('Vec3', 'IVector3', 'net.minecraft.util.Vec3', 'noppes.npcs.api.IVector3'),
@('ChatComponentText', 'ITextComponent', 'net.minecraft.util.ChatComponentText', 'noppes.npcs.api.ITextComponent'),
@('ChatComponentTranslation', 'ITextComponent', 'net.minecraft.util.ChatComponentTranslation', 'noppes.npcs.api.ITextComponent'),
@('IChatComponent', 'ITextComponent', 'net.minecraft.util.IChatComponent', 'noppes.npcs.api.ITextComponent'),
@('ChatStyle', 'ITextStyle', 'net.minecraft.util.ChatStyle', 'noppes.npcs.api.ITextStyle'),
@('MovingObjectPosition', 'IRayTraceResult', 'net.minecraft.util.MovingObjectPosition', 'noppes.npcs.api.IRayTraceResult'),
@('NBTBase', 'INbtBase', 'net.minecraft.nbt.NBTBase', 'noppes.npcs.api.INbtBase'),
@('Potion', 'IPotionType', 'net.minecraft.potion.Potion', 'noppes.npcs.api.IPotionType'),
@('PotionEffect', 'IPotionEffect', 'net.minecraft.potion.PotionEffect', 'noppes.npcs.api.IPotionEffect'),
@('Explosion', 'IExplosion', 'net.minecraft.world.Explosion', 'noppes.npcs.api.IExplosion'),
@('Configuration', 'IForgeConfig', 'net.minecraftforge.common.config.Configuration', 'noppes.npcs.api.IForgeConfig'),
@('Property', 'IConfigProperty', 'net.minecraftforge.common.config.Property', 'noppes.npcs.api.IConfigProperty')
)
# ============================================================
# STEP 4: Static-Transform — regex rewrites
# ============================================================
Static-Transform -Directory 'core/src/main/java' -Transforms @(
@('@SideOnly\s*\(\s*Side\.CLIENT\s*\)', '@ClientOnly'),
@('@SideOnly\s*\(\s*Side\.SERVER\s*\)', '@ServerOnly'),
@('Side\.CLIENT', 'PlatformSide.CLIENT'),
@('Side\.SERVER', 'PlatformSide.SERVER'),
@('MathHelper\.clamp_int\s*\(', 'ValueUtil.clampInt('),
@('MathHelper\.clamp_float\s*\(', 'ValueUtil.clampFloat('),
@('MathHelper\.clamp_double\s*\(', 'ValueUtil.clampDouble('),
@('MathHelper\.sqrt_double\s*\(', 'Math.sqrt('),
@('MathHelper\.sqrt_float\s*\(', '(float)Math.sqrt('),
@('MathHelper\.floor_double\s*\(', 'ValueUtil.floorDouble('),
@('MathHelper\.floor_float\s*\(', 'ValueUtil.floorFloat('),
@('MathHelper\.sin\s*\(', '(float)Math.sin('),
@('MathHelper\.cos\s*\(', '(float)Math.cos('),
@('MathHelper\.abs\s*\(', 'Math.abs('),
@('MathHelper\.ceiling_double_int\s*\(', 'ValueUtil.ceilToInt('),
@('MathHelper\.ceiling_float_int\s*\(', 'ValueUtil.ceilToInt('),
@('EnumChatFormatting\.', 'TextFormatting.'),
@('EnumFacing\.', 'Direction.'),
@('SharedMonsterAttributes\.maxHealth', 'Attributes.MAX_HEALTH'),
@('SharedMonsterAttributes\.movementSpeed', 'Attributes.MOVEMENT_SPEED'),
@('SharedMonsterAttributes\.attackDamage', 'Attributes.ATTACK_DAMAGE'),
@('SharedMonsterAttributes\.followRange', 'Attributes.FOLLOW_RANGE'),
@('SharedMonsterAttributes\.knockbackResistance', 'Attributes.KNOCKBACK_RESISTANCE'),
@('Constants\.NBT\.TAG_COMPOUND', 'NbtConstants.TAG_COMPOUND'),
@('Constants\.NBT\.TAG_STRING', 'NbtConstants.TAG_STRING'),
@('Constants\.NBT\.TAG_LIST', 'NbtConstants.TAG_LIST'),
@('Constants\.NBT\.TAG_INT', 'NbtConstants.TAG_INT'),
@('Constants\.NBT\.TAG_DOUBLE', 'NbtConstants.TAG_DOUBLE'),
@('Constants\.NBT\.TAG_BYTE', 'NbtConstants.TAG_BYTE'),
@('Constants\.NBT\.TAG_FLOAT', 'NbtConstants.TAG_FLOAT'),
@('Constants\.NBT\.TAG_LONG', 'NbtConstants.TAG_LONG'),
@('Constants\.NBT\.TAG_SHORT', 'NbtConstants.TAG_SHORT'),
@('Constants\.NBT\.TAG_INT_ARRAY', 'NbtConstants.TAG_INT_ARRAY'),
@('Constants\.NBT\.TAG_BYTE_ARRAY', 'NbtConstants.TAG_BYTE_ARRAY'),
@('net\.minecraft\.command\.CommandException', 'noppes.npcs.api.CommandException'),
@('new CommandException\(', 'new CommandException('),
@('new ChunkCoordinates\(([^,]+),\s*([^,]+),\s*([^)]+)\)', 'new BlockPos($1, $2, $3)'),
@('\.posX\b', '.getX()'),
@('\.posY\b', '.getY()'),
@('\.posZ\b', '.getZ()'),
@('EnumAction\.', 'ItemAction.')
)
# ============================================================
# STEP 5: Generate stubs for missing dependencies
# ============================================================
Generate-Stubs -Stubs @(
@{ pkg='noppes.npcs'; name='CustomNpcs'; type='class';
body=' public static java.io.File Dir = new java.io.File(".");
public static int DefaultInteractLine = 0;' },
@{ pkg='noppes.npcs'; name='EventHooks'; type='class';
body=' // STUB - event dispatch stays in mc1710' },
@{ pkg='noppes.npcs'; name='LogWriter'; type='class';
body=' public static void info(String msg) {}
public static void warn(String msg) {}
public static void error(String msg) {}
public static void error(String msg, Throwable e) {}' },
@{ pkg='noppes.npcs.controllers'; name='SyncController'; type='class';
body=' // STUB - sync stays in mc1710' }
)
# ============================================================
# STEP 6: Deduplicate imports
# ============================================================
Dedupe-Imports -Directory 'core/src/main/java'
# ============================================================
# STEP 7: Build and report
# ============================================================
Build-Report -GradleTask ':core:compileJava'