From bd59ae5970bd7a3e67c164968d024591a4c0206d Mon Sep 17 00:00:00 2001 From: Boblet Date: Wed, 5 Feb 2025 16:45:49 +0100 Subject: [PATCH] flixes --- changelog | 17 +-- .../container/ContainerPASource.java | 5 +- .../java/com/hbm/items/ItemCustomLore.java | 119 ++++++++++++++++++ src/main/java/com/hbm/items/ModItems.java | 2 + .../weapon/sedna/factory/GunFactory.java | 4 +- .../weapon/sedna/factory/Orchestras.java | 7 ++ .../weapon/sedna/factory/XFactory35800.java | 43 +++++++ .../com/hbm/main/ModEventHandlerClient.java | 3 + .../hbm/tileentity/TileEntityLoadedBase.java | 2 +- 9 files changed, 183 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/hbm/items/weapon/sedna/factory/XFactory35800.java diff --git a/changelog b/changelog index 55e5f6d36..eebc67df8 100644 --- a/changelog +++ b/changelog @@ -1,16 +1,3 @@ -## Changed -* Changed PA power draw penalties from x5 to x10 -* Particles will now crash instantly if the dipole has both penalties in effect (underspeed + undersized ring) - * This means that undersized accelerators require appropriate tier coils, and overtiered accelerators (i.e. high coils for low velocities) need to meet the size requirement - * Accelerators where both penalties take effect are usually tiny ones with single tier coils (usually the highest tier required) which are lame -* DNT nano suit helmets now require quantum circuits instead of bismuth ones -* Made particle capsules more expensive - * Since invalid recipes no longer void containers, this shouldn't really be a huge deal -* Both quadrupoles and dipoles now have a power cap of 2.5MHE -* RFCs now use 250kHE per pass (instead of 100k) -* Heavy water extraction now has a NEI handler - ## Fixed -* Fixed particle detector not consuming power -* Fixed empty capsules not being recoverable from the color coded slots on the particle source -* Fixed particle detector nor charging from batteries \ No newline at end of file +* Fixed items being annihilated when shift clicking them into the particle source +* Fixed packet optimization not allowing packets to be sent when the day night cycle is halted \ No newline at end of file diff --git a/src/main/java/com/hbm/inventory/container/ContainerPASource.java b/src/main/java/com/hbm/inventory/container/ContainerPASource.java index 4b30637f5..f9d41eb6b 100644 --- a/src/main/java/com/hbm/inventory/container/ContainerPASource.java +++ b/src/main/java/com/hbm/inventory/container/ContainerPASource.java @@ -3,6 +3,7 @@ package com.hbm.inventory.container; import com.hbm.inventory.SlotTakeOnly; import com.hbm.items.ModItems; import com.hbm.tileentity.machine.albion.TileEntityPASource; +import com.hbm.util.InventoryUtil; import api.hbm.energymk2.IBatteryItem; import net.minecraft.entity.player.EntityPlayer; @@ -59,9 +60,9 @@ public class ContainerPASource extends Container { } else { if(rStack.getItem() instanceof IBatteryItem || rStack.getItem() == ModItems.battery_creative) { - if(!this.mergeItemStack(stack, 0, 1, false)) return null; + if(!InventoryUtil.mergeItemStack(this.inventorySlots, stack, 0, 1, false)) return null; } else { - if(!this.mergeItemStack(stack, 1, 3, false)) return null; + if(!InventoryUtil.mergeItemStack(this.inventorySlots, stack, 1, 3, false)) return null; } } diff --git a/src/main/java/com/hbm/items/ItemCustomLore.java b/src/main/java/com/hbm/items/ItemCustomLore.java index 15dab0dd7..10cf5461b 100644 --- a/src/main/java/com/hbm/items/ItemCustomLore.java +++ b/src/main/java/com/hbm/items/ItemCustomLore.java @@ -1,5 +1,6 @@ package com.hbm.items; +import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -14,6 +15,7 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; public class ItemCustomLore extends Item { @@ -104,4 +106,121 @@ public class ItemCustomLore extends Item { setTextureName(RefStrings.MODID + ':' + uloc); return super.setUnlocalizedName(uloc); } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + if(stack.getItem() == ModItems.undefined && stack.getItemDamage() != 99) return ("" + StatCollector.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + ".name")).trim(); + + return name.getResult(); + } + + public static String[] names = new String[] { + "THE DEFAULT", "NEXT ONE", "ANOTHER ONE", "NON-STANDARD NAME", "AMBIGUOUS TITLE", "SHORT" + }; + + public static Random rand = new Random(); + public static int currentIndex = 0; + public static ScramblingName name = new ScramblingName(names[0]); + + public static void updateSystem() { + name.updateTick(names); + } + + /** + * A surprise tool we need for later + * @author hbm + */ + public static class ScramblingName { + + public String previous; + public String next; + public String[] previousFrags; + public String[] nextFrags; + public String[] frags; + public int[] mask; + public int age = 0; + + public ScramblingName(String init) { + previous = next = init; + frags = init.split(""); + mask = new int[frags.length]; + previousFrags = chop(previous, frags.length); + nextFrags = chop(next, frags.length); + } + + public String getResult() { + return String.join("", frags); + } + + public void updateTick(String[] nextNames) { + age++; + try { + //pick new name + if(age % 200 == 0) nextName(nextNames); + //run substitution + if(age % 5 == 0) scramble(); + } catch(Exception ex) { } + } + + public void nextName(String[] nextNames) { + if(nextNames.length < 2) return; + + this.previous = this.next; + + String initial = next; + //keep choosing new names until it's different + while(initial.equals(next)) { + next = nextNames[rand.nextInt(nextNames.length)]; + } + + //frag setup + int length = Math.min(previous.length(), next.length()); + this.previousFrags = chop(previous, length); + this.frags = chop(previous, length); + this.nextFrags = chop(next, length); + mask = new int[length]; + } + + public void scramble() { + + //all fragments that haven't been substituted + List indices = new ArrayList(); + + for(int i = 0; i < mask.length; i++) { + int m = mask[i]; + //mask 0 means not yet processed + if(m == 0) indices.add(i); + //mask 1-5 means obfuscated + if(m > 0 && m <= 5) mask[i]++; + //mask >5 means replaced + if(m > 5) frags[i] = nextFrags[i]; + } + + //if there's at least one index listed, start processing + if(!indices.isEmpty()) { + int toSwitch = indices.get(rand.nextInt(indices.size())); + mask[toSwitch] = 1; + frags[toSwitch] = EnumChatFormatting.OBFUSCATED + previousFrags[toSwitch] + EnumChatFormatting.RESET; + } + } + + public String[] chop(String name, int parts) { + if(parts == name.length()) return name.split(""); + + double index = 0; + double incrementPerStep = (double) name.length() / (double) parts; + List slices = new ArrayList(); + + for(int i = 0; i < parts; i++) { + int end = (i == parts - 1) ? name.length() : (int) (index + incrementPerStep); + slices.add(name.substring((int) index, end)); + index += incrementPerStep; + } + + String[] chop = slices.toArray(new String[parts]); + //System.out.println("Chopped " + name + " into " + parts + " pieces: " + chop); + + return chop; + } + } } diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index b5a3174e3..2d5e828bc 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -1500,6 +1500,7 @@ public class ModItems { public static Item gun_hangman; public static Item gun_bolter; public static Item gun_folly; + public static Item gun_aberrator; public static Item gun_double_barrel; public static Item gun_double_barrel_sacred_dragon; @@ -6493,6 +6494,7 @@ public class ModItems { GameRegistry.registerItem(gun_hangman, gun_hangman.getUnlocalizedName()); GameRegistry.registerItem(gun_bolter, gun_bolter.getUnlocalizedName()); GameRegistry.registerItem(gun_folly, gun_folly.getUnlocalizedName()); + GameRegistry.registerItem(gun_aberrator, gun_aberrator.getUnlocalizedName()); GameRegistry.registerItem(gun_double_barrel, gun_double_barrel.getUnlocalizedName()); GameRegistry.registerItem(gun_double_barrel_sacred_dragon, gun_double_barrel_sacred_dragon.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java index afd0b437a..93775156f 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactory.java @@ -65,6 +65,7 @@ public class GunFactory { XFactoryFolly.init(); XFactoryTurret.init(); XFactory10ga.init(); + XFactory35800.init(); /// PROXY BULLSHIT /// MainRegistry.proxy.registerGunCfg(); @@ -124,6 +125,7 @@ public class GunFactory { public static enum EnumAmmoSecret { FOLLY_SM, FOLLY_NUKE, - M44_EQUESTRIAN, G12_EQUESTRIAN, BMG50_EQUESTRIAN + M44_EQUESTRIAN, G12_EQUESTRIAN, BMG50_EQUESTRIAN, + P35_800 } } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java index ae862270a..998181543 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java @@ -1278,4 +1278,11 @@ public class Orchestras { if(timer == 2) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.dryFireClick", 1F, 1F); } }; + + public static BiConsumer ORCHESTRA_ABERRATOR = (stack, ctx) -> { + EntityLivingBase entity = ctx.entity; + if(entity.worldObj.isRemote) return; + AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex); + int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex); + }; } diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory35800.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory35800.java new file mode 100644 index 000000000..665562be5 --- /dev/null +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactory35800.java @@ -0,0 +1,43 @@ +package com.hbm.items.weapon.sedna.factory; + +import java.util.function.BiFunction; + +import com.hbm.items.ModItems; +import com.hbm.items.weapon.sedna.BulletConfig; +import com.hbm.items.weapon.sedna.Crosshair; +import com.hbm.items.weapon.sedna.GunConfig; +import com.hbm.items.weapon.sedna.ItemGunBaseNT; +import com.hbm.items.weapon.sedna.Receiver; +import com.hbm.items.weapon.sedna.ItemGunBaseNT.WeaponQuality; +import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmoSecret; +import com.hbm.items.weapon.sedna.mags.MagazineFullReload; +import com.hbm.render.anim.BusAnimation; +import com.hbm.render.anim.HbmAnimations.AnimType; +import com.hbm.util.DamageResistanceHandler.DamageClass; + +import net.minecraft.item.ItemStack; + +public class XFactory35800 { + + public static BulletConfig p35800; + + public static void init() { + + p35800 = new BulletConfig().setItem(EnumAmmoSecret.P35_800).setupDamageClass(DamageClass.LASER).setBeam().setSpread(0.0F).setLife(5).setRenderRotations(false).setOnBeamImpact(BulletConfig.LAMBDA_STANDARD_BEAM_HIT); + + ModItems.gun_aberrator = new ItemGunBaseNT(WeaponQuality.SECRET, new GunConfig() + .dura(2_000).draw(10).inspect(26).reloadSequential(true).crosshair(Crosshair.CIRCLE) + .rec(new Receiver(0) + .dmg(50F).delay(8).reload(44).jam(36).sound("hbm:weapon.fire.laser", 1.0F, 1.0F) + .mag(new MagazineFullReload(0, 24).addConfigs(p35800)) + .offset(0.75, -0.0625 * 1.5, -0.1875) + .setupStandardFire()) + .setupStandardConfiguration() + .anim(LAMBDA_ABERRATOR).orchestra(Orchestras.ORCHESTRA_ABERRATOR) + ).setUnlocalizedName("gun_aberrator"); + } + + @SuppressWarnings("incomplete-switch") public static BiFunction LAMBDA_ABERRATOR = (stack, type) -> { + return null; + }; +} diff --git a/src/main/java/com/hbm/main/ModEventHandlerClient.java b/src/main/java/com/hbm/main/ModEventHandlerClient.java index 79ea907c7..ce72c3279 100644 --- a/src/main/java/com/hbm/main/ModEventHandlerClient.java +++ b/src/main/java/com/hbm/main/ModEventHandlerClient.java @@ -25,6 +25,7 @@ import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.gui.GUIArmorTable; import com.hbm.inventory.gui.GUIScreenPreview; import com.hbm.inventory.gui.GUIScreenWikiRender; +import com.hbm.items.ItemCustomLore; import com.hbm.items.ModItems; import com.hbm.items.armor.*; import com.hbm.items.machine.ItemDepletedFuel; @@ -1389,6 +1390,8 @@ public class ModEventHandlerClient { client.sendQueue.addToSendQueue(new C0CPacketInput(client.moveStrafing, client.moveForward, client.movementInput.jump, client.movementInput.sneak)); } } + + if(event.phase == event.phase.END) ItemCustomLore.updateSystem(); } @SubscribeEvent diff --git a/src/main/java/com/hbm/tileentity/TileEntityLoadedBase.java b/src/main/java/com/hbm/tileentity/TileEntityLoadedBase.java index 15e7bf426..b81fcd6cc 100644 --- a/src/main/java/com/hbm/tileentity/TileEntityLoadedBase.java +++ b/src/main/java/com/hbm/tileentity/TileEntityLoadedBase.java @@ -77,7 +77,7 @@ public class TileEntityLoadedBase extends TileEntity implements ILoadedTile, IBu // In my testing, this can be reliably reproduced with a full fluid barrel, for instance. // I think it might be fixable by doing something with getDescriptionPacket() and onDataPacket(), // but this sidesteps the problem for the mean time. - if(preBuf.equals(lastPackedBuf) && this.worldObj.getWorldTime() % 20 != 0) return; + if(preBuf.equals(lastPackedBuf) && this.worldObj.getTotalWorldTime() % 20 != 0) return; this.lastPackedBuf = preBuf.copy();