11package noppes .npcs ;
22
3- import net .minecraft .nbt .NBTBase ;
4- import net .minecraft .nbt . NBTTagCompound ;
5- import net .minecraft . nbt . NBTTagInt ;
6- import net . minecraft . nbt . NBTTagList ;
3+ import net .minecraft .nbt .* ;
4+ import net .minecraft .world . World ;
5+ import net .minecraftforge . common . util . Constants ;
6+ import noppes . npcs . constants . EnumPotionType ;
77import noppes .npcs .controllers .data .Line ;
88import noppes .npcs .controllers .data .Lines ;
99import noppes .npcs .entity .EntityNPCInterface ;
@@ -49,6 +49,23 @@ public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound
4949 if (compound .hasKey ("DialogDarkenScreen" )) {
5050 compound .removeTag ("DialogDarkenScreen" );
5151 }
52+
53+ if (compound .hasKey ("FiringDelay" ) && compound .hasKey ("DelayVariance" )) {
54+ int min = compound .getInteger ("FiringDelay" );
55+ int max = compound .getInteger ("DelayVariance" );
56+ compound .setInteger ("minDelay" , min );
57+ compound .setInteger ("maxDelay" , max );
58+ compound .removeTag ("FiringDelay" );
59+ compound .removeTag ("DelayVariance" );
60+ }
61+
62+ if (compound .hasKey ("pEffect" )) {
63+ int effect = compound .getInteger ("pEffect" );
64+ EnumPotionType enumPotionType = EnumPotionType .fromOrdinal (effect );
65+ if (enumPotionType == EnumPotionType .Fire ) {
66+ compound .setBoolean ("pBurnItem" , true );
67+ }
68+ }
5269 }
5370 if (npc .npcVersion < 12 ) {
5471 CompatabilityFix (compound , npc .advanced .writeToNBT (new NBTTagCompound ()));
@@ -110,6 +127,56 @@ public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound
110127
111128 compound .setIntArray ("StartPosNew" , new int []{x , y , z });
112129 }
130+
131+ NBTTagList movingPathLegacy = compound .getTagList ("MovingPath" , Constants .NBT .TAG_LIST );
132+
133+ if (movingPathLegacy .tagCount () > 0 ) {
134+ NBTTagList MovingPathNew = new NBTTagList ();
135+
136+ for (int i = movingPathLegacy .tagCount () - 1 ; i >= 0 ; i --) {
137+ NBTTagList array = (NBTTagList ) movingPathLegacy .removeTag (i );
138+
139+ if (array .tagCount () == 3 ) {
140+ int x = array .getCompoundTagAt (0 ).getInteger ("Slot" );
141+ int y = array .getCompoundTagAt (1 ).getInteger ("Slot" );
142+ int z = array .getCompoundTagAt (2 ).getInteger ("Slot" );
143+
144+ NBTTagCompound pathPoint = new NBTTagCompound ();
145+ pathPoint .setIntArray ("Array" , new int []{x , y , z });
146+
147+ MovingPathNew .appendTag (pathPoint );
148+ }
149+ }
150+
151+ NBTTagList finalList = new NBTTagList ();
152+ for (int i = MovingPathNew .tagCount () - 1 ; i >= 0 ; i --) {
153+ finalList .appendTag (MovingPathNew .getCompoundTagAt (i ));
154+ }
155+
156+ compound .setTag ("MovingPathNew" , finalList );
157+ }
158+
159+ if (compound .hasKey ("NpcJob" )) {
160+ int npcJob = compound .getInteger ("NpcJob" );
161+ if (npcJob == 5 ) {
162+ compound .setByte ("BossBar" , (byte ) 1 );
163+ compound .setInteger ("NpcJob" , 0 );
164+ }
165+ }
166+
167+ if (compound .hasKey ("SkinColor" )) {
168+ int skinColor = compound .getInteger ("SkinColor" );
169+ if (skinColor != 16777215 ) {
170+ compound .setBoolean ("TintEnabled" , true );
171+ compound .setInteger ("GeneralTint" , skinColor );
172+ compound .setInteger ("GeneralAlpha" , 100 );
173+ compound .setBoolean ("GeneralTintEnabled" , true );
174+ }
175+ }
176+
177+ if (!compound .getString ("GlowTexture" ).isEmpty () && compound .getInteger ("NpcVisible" ) == 1 ) {
178+ compound .setInteger ("NpcVisible" , 2 );
179+ }
113180 }
114181 if (npc .npcVersion == 13 ) {
115182 boolean bo = compound .getBoolean ("HealthRegen" );
@@ -123,6 +190,16 @@ public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound
123190 npc .npcVersion = ModRev ;
124191 }
125192
193+ public static void CheckSpawnerCompatibility (NBTTagCompound compound , int x , int y , int z , World world ) {
194+ for (int i = 1 ; i <= 6 ; i ++) {
195+ NBTTagCompound tag = compound .getCompoundTag ("SpawnerNBT" + i );
196+ if (tag .hasNoTags () || tag .getInteger ("ModRev" ) == ModRev ) continue ;
197+
198+ tag .setString ("id" , "customnpcs.CustomNpc" );
199+ compound .setTag ("SpawnerNBT" + i , tag );
200+ }
201+ }
202+
126203 public static void CheckModelCompatibility (EntityNPCInterface npc , NBTTagCompound compound ) {
127204 if (npc .npcVersion == ModRev )
128205 return ;
0 commit comments