diff --git a/src/main/java/com/paneedah/mwc/WorldGeneratorEventHandler.java b/src/main/java/com/paneedah/mwc/ModernWorldGenerator.java similarity index 94% rename from src/main/java/com/paneedah/mwc/WorldGeneratorEventHandler.java rename to src/main/java/com/paneedah/mwc/ModernWorldGenerator.java index d3a2cd325..4030e4276 100644 --- a/src/main/java/com/paneedah/mwc/WorldGeneratorEventHandler.java +++ b/src/main/java/com/paneedah/mwc/ModernWorldGenerator.java @@ -2,6 +2,7 @@ import com.paneedah.mwc.init.MWCBlocks; import com.paneedah.weaponlib.config.ModernConfigManager; +import lombok.NoArgsConstructor; import net.minecraft.block.Block; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -12,11 +13,9 @@ import java.util.Random; -public class WorldGeneratorEventHandler implements IWorldGenerator { +@NoArgsConstructor +public class ModernWorldGenerator implements IWorldGenerator { - public WorldGeneratorEventHandler() { - - } @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { diff --git a/src/main/java/com/paneedah/mwc/UniversalSoundRegistry.java b/src/main/java/com/paneedah/mwc/UniversalSoundRegistry.java index 9ecb8f1d3..57c302a8a 100644 --- a/src/main/java/com/paneedah/mwc/UniversalSoundRegistry.java +++ b/src/main/java/com/paneedah/mwc/UniversalSoundRegistry.java @@ -6,12 +6,13 @@ * Creates a sound registry for WeaponLib to access in order to play * reloading noises. * + * Example: UniversalSoundLookup.registerSoundToLookup("test_sound"); + * * @author Jim Holden, 2022 */ public class UniversalSoundRegistry { public static void init() { - // Example: UniversalSoundLookup.registerSoundToLookup("test_sound"); UniversalSoundLookup.registerSoundToLookup("bolt_press"); UniversalSoundLookup.registerSoundToLookup("bolt_slap"); UniversalSoundLookup.registerSoundToLookup("chargehandle_back"); diff --git a/src/main/java/com/paneedah/mwc/equipment/Armors.java b/src/main/java/com/paneedah/mwc/equipment/Armors.java index 874603ea4..dfa7d5708 100644 --- a/src/main/java/com/paneedah/mwc/equipment/Armors.java +++ b/src/main/java/com/paneedah/mwc/equipment/Armors.java @@ -65,7 +65,7 @@ public class Armors { static ArmorMaterial Juggernaut = EnumHelper.addArmorMaterial("Juggernaut", "Juggernaut", 20, new int[]{5, 6, 2, 5}, 20, null, 0); static ArmorMaterial Marine = EnumHelper.addArmorMaterial("Marine", "Marine", 60, new int[]{2, 3, 3, 3}, 15, null, 0); - public static void init(Object mod, ModContext modContext) { + public static void createEquipment(ModContext modContext) { Builder marineArmorBuilder = new CustomArmor.Builder() .withMaterial(Armors.Marine) .withUnlocalizedName("Marine") diff --git a/src/main/java/com/paneedah/mwc/equipment/Backpacks.java b/src/main/java/com/paneedah/mwc/equipment/Backpacks.java index 228f422f2..fa5f2fe50 100644 --- a/src/main/java/com/paneedah/mwc/equipment/Backpacks.java +++ b/src/main/java/com/paneedah/mwc/equipment/Backpacks.java @@ -1,6 +1,7 @@ package com.paneedah.mwc.equipment; import com.paneedah.mwc.items.equipment.carryable.ItemBackpack; +import com.paneedah.weaponlib.ModContext; import com.paneedah.weaponlib.animation.Transform; import net.minecraft.item.Item; @@ -22,7 +23,7 @@ public class Backpacks { public static Item duffleBag; - public static void init() { + public static void createEquipment(ModContext modContext) { combatSustainmentBackpackTan = new ItemBackpack.Builder() .withName("combat_sustainment_backpack_tan") diff --git a/src/main/java/com/paneedah/mwc/equipment/Belts.java b/src/main/java/com/paneedah/mwc/equipment/Belts.java index 237fd61a3..69025467f 100644 --- a/src/main/java/com/paneedah/mwc/equipment/Belts.java +++ b/src/main/java/com/paneedah/mwc/equipment/Belts.java @@ -1,13 +1,13 @@ package com.paneedah.mwc.equipment; +import com.paneedah.weaponlib.ModContext; import net.minecraft.item.Item; public class Belts { public static Item magazineBelt; - public static void init() { - + public static void createEquipment(ModContext modContext) { // TODO: Finish implementing belts // magazineBelt = new ItemBelt.Builder() // .withName("magazine_belt") diff --git a/src/main/java/com/paneedah/mwc/equipment/Electronics.java b/src/main/java/com/paneedah/mwc/equipment/Electronics.java index d8f631d93..da62b8b93 100644 --- a/src/main/java/com/paneedah/mwc/equipment/Electronics.java +++ b/src/main/java/com/paneedah/mwc/equipment/Electronics.java @@ -3,6 +3,7 @@ import com.paneedah.mwc.MWC; import com.paneedah.mwc.models.GasDetector; import com.paneedah.weaponlib.ItemAttachment; +import com.paneedah.weaponlib.ModContext; import com.paneedah.weaponlib.electronics.ItemHandheld; import com.paneedah.weaponlib.electronics.ItemTablet; import com.paneedah.weaponlib.electronics.ItemWirelessCamera; @@ -15,11 +16,11 @@ public class Electronics { public static ItemAttachment Tablet; - public static void init() { + public static void createEquipment(ModContext modContext) { Tablet = new ItemTablet.Builder<>() .withViewfinderPositioning(() -> { float scale = 5.9f; - GL11.glScalef(scale, scale / MWC.modContext.getAspectRatio(), scale); + GL11.glScalef(scale, scale / modContext.getAspectRatio(), scale); GL11.glTranslatef(-0.12f, 0.56f, 0.01f); }) .withCreativeTab(MWC.EQUIPMENT_TAB) @@ -77,7 +78,7 @@ public static void init() { .withName("tablet") .withTextureName("Dummy.png") - .build(MWC.modContext); + .build(modContext); new ItemWirelessCamera.Builder() @@ -135,14 +136,14 @@ public static void init() { } ) - .build(MWC.modContext); + .build(modContext); new ItemHandheld.Builder<>() .withScreenPerspectiveType(GasDetectorScreenPerspective.class) .withScreenPositioning(() -> { float scale = 1.9f; - GL11.glScalef(scale, scale / MWC.modContext.getAspectRatio(), scale); + GL11.glScalef(scale, scale / modContext.getAspectRatio(), scale); GL11.glTranslatef(0.017f, 0.16f, 0.17f); }) .withCreativeTab(MWC.EQUIPMENT_TAB) @@ -205,6 +206,6 @@ public static void init() { .withName("gas-detector") .withTextureName("Dummy.png") - .build(MWC.modContext); + .build(modContext); } } diff --git a/src/main/java/com/paneedah/mwc/equipment/Vests.java b/src/main/java/com/paneedah/mwc/equipment/Vests.java index 2f936f80d..b24774f47 100644 --- a/src/main/java/com/paneedah/mwc/equipment/Vests.java +++ b/src/main/java/com/paneedah/mwc/equipment/Vests.java @@ -2,12 +2,13 @@ import com.paneedah.mwc.MWC; import com.paneedah.weaponlib.ItemVest; +import com.paneedah.weaponlib.ModContext; import com.paneedah.weaponlib.animation.Transform; import org.lwjgl.opengl.GL11; public class Vests { - public static void init(Object mod) { + public static void createEquipment(ModContext modContext) { new ItemVest.Builder() .withName("m43a_chest_harness") @@ -27,7 +28,7 @@ public static void init(Object mod) { .withScale(3, 3, 3) .doGLDirect(); }) - .build(MWC.modContext); + .build(modContext); new ItemVest.Builder() .withName("flyye_field_compact_plate_carrier") @@ -67,7 +68,7 @@ public static void init(Object mod) { .withScale(3, 3, 3) .doGLDirect(); }) - .build(MWC.modContext); + .build(modContext); new ItemVest.Builder() .withName("molle_green") @@ -87,7 +88,7 @@ public static void init(Object mod) { .withScale(3, 3, 3) .doGLDirect(); }) - .build(MWC.modContext); + .build(modContext); new ItemVest.Builder() .withName("molle_urban") @@ -107,7 +108,7 @@ public static void init(Object mod) { .withScale(3, 3, 3) .doGLDirect(); }) - .build(MWC.modContext); + .build(modContext); new ItemVest.Builder() .withName("swat_vest") @@ -127,7 +128,7 @@ public static void init(Object mod) { .withScale(3, 3, 3) .doGLDirect(); }) - .build(MWC.modContext); + .build(modContext); new ItemVest.Builder() .withName("usMC_vest") @@ -152,7 +153,7 @@ public static void init(Object mod) { .withScale(2.6, 2.6, 2.6) .doGLDirect(); }) - .build(MWC.modContext); + .build(modContext); new ItemVest.Builder() .withName("usMC_vest_black") @@ -178,7 +179,7 @@ public static void init(Object mod) { .withScale(2.6, 2.6, 2.6) .doGLDirect(); }) - .build(MWC.modContext); + .build(modContext); new ItemVest.Builder() .withName("usMC_vest_green") @@ -204,7 +205,7 @@ public static void init(Object mod) { .withScale(2.6, 2.6, 2.6) .doGLDirect(); }) - .build(MWC.modContext); + .build(modContext); new ItemVest.Builder() .withName("usMC_vest_urban") @@ -230,6 +231,6 @@ public static void init(Object mod) { .withScale(2.6, 2.6, 2.6) .doGLDirect(); }) - .build(MWC.modContext); + .build(modContext); } } diff --git a/src/main/java/com/paneedah/mwc/items/guns/AK47Factory.java b/src/main/java/com/paneedah/mwc/items/guns/AK47Factory.java index 644f5e72b..1bb906c26 100644 --- a/src/main/java/com/paneedah/mwc/items/guns/AK47Factory.java +++ b/src/main/java/com/paneedah/mwc/items/guns/AK47Factory.java @@ -18,7 +18,7 @@ import net.minecraft.util.math.Vec3d; import org.lwjgl.opengl.GL11; -public class AK47Factory { +public class AK47Factory implements GunFactory { public Item createGun(CommonProxy commonProxy) { return new Weapon.Builder() diff --git a/src/main/java/com/paneedah/mwc/proxies/CommonProxy.java b/src/main/java/com/paneedah/mwc/proxies/CommonProxy.java index 66401fbcd..b8459fc78 100644 --- a/src/main/java/com/paneedah/mwc/proxies/CommonProxy.java +++ b/src/main/java/com/paneedah/mwc/proxies/CommonProxy.java @@ -10,6 +10,7 @@ import com.paneedah.mwc.items.melee.TacticalTomahawkFactory; import com.paneedah.mwc.skins.GunSkins; import com.paneedah.mwc.tileentities.TileEntities; +import com.paneedah.mwc.tileentities.TurretBaseFactory; import com.paneedah.mwc.vehicle.Vehicles; import com.paneedah.mwc.weapons.*; import com.paneedah.weaponlib.UniversalSoundLookup; @@ -62,20 +63,24 @@ public void preInit(final MWC mod) { // Special object initialization SpecialAttachments.init(mod, MWC.modContext); - Backpacks.init(); - Belts.init(); - Vests.init(mod); - Armors.init(mod, MWC.modContext); + + Backpacks.createEquipment(MWC.modContext); + Belts.createEquipment(MWC.modContext); + Vests.createEquipment(MWC.modContext); + Armors.createEquipment(MWC.modContext); + Attachments.init(mod); AuxiliaryAttachments.init(mod); GunSkins.init(mod); Bullets.init(mod); Magazines.init(mod); Guns.init(mod, this); - Electronics.init(); + Electronics.createEquipment(MWC.modContext); Grenades.init(mod, this); CustomSpawnEggs.init(mod, this); - TileEntities.init(this); + + TurretBaseFactory.createTileEntity(MWC.modContext); + TileEntities.createTileEntity(MWC.modContext); new TacticalTomahawkFactory().createMelee(this); new BaseballBatFactory().createMelee(this); @@ -91,7 +96,7 @@ public void init(final MWC mod) { Entities.init(this); Vehicles.init(this); - GameRegistry.registerWorldGenerator(new WorldGeneratorEventHandler(), 0); + GameRegistry.registerWorldGenerator(new ModernWorldGenerator(), 0); } public void postInit(final MWC mod, final FMLPostInitializationEvent initializationEvent) { diff --git a/src/main/java/com/paneedah/mwc/tileentities/TileEntities.java b/src/main/java/com/paneedah/mwc/tileentities/TileEntities.java index 2e361efbb..efdcaea3d 100644 --- a/src/main/java/com/paneedah/mwc/tileentities/TileEntities.java +++ b/src/main/java/com/paneedah/mwc/tileentities/TileEntities.java @@ -1,7 +1,7 @@ package com.paneedah.mwc.tileentities; import com.paneedah.mwc.MWC; -import com.paneedah.mwc.proxies.CommonProxy; +import com.paneedah.weaponlib.ModContext; import com.paneedah.weaponlib.tile.CustomTileEntityBlock; import com.paneedah.weaponlib.tile.LootBoxConfiguration; import net.minecraft.block.material.Material; @@ -11,9 +11,7 @@ public class TileEntities { - public static void init(CommonProxy commonProxy) { - new TurretBaseFactory().createTileEntity(MWC.modContext); - + public static void createTileEntity(ModContext modContext) { new LootBoxConfiguration() .withMaterial(Material.ROCK) .withName("weapons_case") diff --git a/src/main/java/com/paneedah/mwc/tileentities/TileEntityFactory.java b/src/main/java/com/paneedah/mwc/tileentities/TileEntityFactory.java deleted file mode 100644 index 3dab721b2..000000000 --- a/src/main/java/com/paneedah/mwc/tileentities/TileEntityFactory.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.paneedah.mwc.tileentities; - -import com.paneedah.weaponlib.ModContext; - -public interface TileEntityFactory { - - void createTileEntity(ModContext modContext); - -} diff --git a/src/main/java/com/paneedah/mwc/tileentities/TurretBaseFactory.java b/src/main/java/com/paneedah/mwc/tileentities/TurretBaseFactory.java index b93e028a1..874bdbae2 100644 --- a/src/main/java/com/paneedah/mwc/tileentities/TurretBaseFactory.java +++ b/src/main/java/com/paneedah/mwc/tileentities/TurretBaseFactory.java @@ -4,14 +4,11 @@ import com.paneedah.weaponlib.ModContext; import com.paneedah.weaponlib.tile.LootBoxConfiguration; import net.minecraft.block.material.Material; -import net.minecraftforge.event.LootTableLoadEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.opengl.GL11; -public class TurretBaseFactory implements TileEntityFactory { +public class TurretBaseFactory { - @Override - public void createTileEntity(ModContext modContext) { + public static void createTileEntity(ModContext modContext) { new LootBoxConfiguration() .withMaterial(Material.ROCK) .withName("turret_base") @@ -24,11 +21,6 @@ public void createTileEntity(ModContext modContext) { GL11.glTranslatef(0.5f, 0f, 0.5f); // GL11.glRotatef(-45F, 0f, 1f, 0f); }) - .build(MWC.modContext); + .build(modContext); } - - @SubscribeEvent - public void lootLoad(LootTableLoadEvent evt) { - } - } diff --git a/src/main/java/com/paneedah/mwc/vehicle/AE86TruenoFactory.java b/src/main/java/com/paneedah/mwc/vehicle/AE86TruenoFactory.java index 344ab7ab4..90b1e658a 100644 --- a/src/main/java/com/paneedah/mwc/vehicle/AE86TruenoFactory.java +++ b/src/main/java/com/paneedah/mwc/vehicle/AE86TruenoFactory.java @@ -15,10 +15,8 @@ public class AE86TruenoFactory implements VehicleFactory { - + @Override public void createVehicle(ModContext modContext) { - - StatefulRenderer renderer = null; if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { @@ -282,7 +280,7 @@ public void createVehicle(ModContext modContext) { .withOBBDimensions(3.3, 2.5, 1.75) .withSeat(new Vec3d(-0.89, -0.2, 0.0)) .withRenderer(renderer) - .build(MWC.modContext); + .build(modContext); } } diff --git a/src/main/java/com/paneedah/mwc/vehicle/ATVFactory.java b/src/main/java/com/paneedah/mwc/vehicle/ATVFactory.java index 884eac66a..9fe6b53df 100644 --- a/src/main/java/com/paneedah/mwc/vehicle/ATVFactory.java +++ b/src/main/java/com/paneedah/mwc/vehicle/ATVFactory.java @@ -21,10 +21,8 @@ public class ATVFactory implements VehicleFactory { - + @Override public void createVehicle(ModContext modContext) { - - StatefulRenderer renderer = null; if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { @@ -263,7 +261,7 @@ public void createVehicle(ModContext modContext) { .withOBBDimensions(1, 1, 1) .withSeat(new Vec3d(-0.5, 0.2, -0.3)) .withRenderer(renderer) - .build(MWC.modContext); + .build(modContext); } } diff --git a/src/main/java/com/paneedah/mwc/vehicle/AudiS4Factory.java b/src/main/java/com/paneedah/mwc/vehicle/AudiS4Factory.java index bdc66eb06..012df0a4a 100644 --- a/src/main/java/com/paneedah/mwc/vehicle/AudiS4Factory.java +++ b/src/main/java/com/paneedah/mwc/vehicle/AudiS4Factory.java @@ -14,6 +14,7 @@ public class AudiS4Factory implements VehicleFactory { + @Override public void createVehicle(ModContext modContext) { StatefulRenderer renderer = null; @@ -241,7 +242,7 @@ public void createVehicle(ModContext modContext) { .withSeat(new Vec3d(0.0, -0.2, 0.0)) .withSeat(new Vec3d(0.5, -0.2, 0.0)) .withRenderer(renderer) - .build(MWC.modContext); + .build(modContext); } } diff --git a/src/main/java/com/paneedah/mwc/vehicle/JLTVM1280Factory.java b/src/main/java/com/paneedah/mwc/vehicle/JLTVM1280Factory.java index 2239bd7a8..070fbc892 100644 --- a/src/main/java/com/paneedah/mwc/vehicle/JLTVM1280Factory.java +++ b/src/main/java/com/paneedah/mwc/vehicle/JLTVM1280Factory.java @@ -9,6 +9,7 @@ public class JLTVM1280Factory implements VehicleFactory { + @Override public void createVehicle(ModContext modContext) { StatefulRenderer renderer = new VehicleRendererBuilder() @@ -204,7 +205,7 @@ public void createVehicle(ModContext modContext) { // .withAccelerationIncrement(0.015) // .withForwardDeccelerationFactor(0.97) .withRenderer(renderer) - .build(MWC.modContext); + .build(modContext); } } diff --git a/src/main/java/com/paneedah/mwc/vehicle/McLarenSennaFactory.java b/src/main/java/com/paneedah/mwc/vehicle/McLarenSennaFactory.java index 11816b39c..0fa488dff 100644 --- a/src/main/java/com/paneedah/mwc/vehicle/McLarenSennaFactory.java +++ b/src/main/java/com/paneedah/mwc/vehicle/McLarenSennaFactory.java @@ -19,6 +19,7 @@ public class McLarenSennaFactory implements VehicleFactory { + @Override public void createVehicle(ModContext modContext) { StatefulRenderer renderer = null; @@ -235,7 +236,7 @@ public void createVehicle(ModContext modContext) { .withOBBDimensions(3.5, 2.5, 1.75) .withSeat(new Vec3d(-0.15, -0.4, 0.5)) .withRenderer(renderer) - .build(MWC.modContext); + .build(modContext); } } diff --git a/src/main/java/com/paneedah/mwc/vehicle/PartInit.java b/src/main/java/com/paneedah/mwc/vehicle/PartInit.java index fe62e262a..19f2c9ab3 100644 --- a/src/main/java/com/paneedah/mwc/vehicle/PartInit.java +++ b/src/main/java/com/paneedah/mwc/vehicle/PartInit.java @@ -12,21 +12,16 @@ public class PartInit { // .withEcoShift(2500, 1200); public static final Transmission audiS4B7Transmission = new Transmission(3.889f, 3.4f, 4500, 1800) - .quickSixSpeed(3.667f, 2.050f, 1.462f, 1.133f, 0.919f, 0.778f) - .withEcoShift(2500, 1200); + .quickSixSpeed(3.667f, 2.050f, 1.462f, 1.133f, 0.919f, 0.778f); public static final Transmission McLarenSennaTransmission = new Transmission(3.31f, 2.8f, 8450, 4000) - .quickSpeed(3.98f, 2.61f, 1.9f, 1.48f, 1.16f, 0.91f, 0.69f) - .withEcoShift(2500, 1200); + .quickSpeed(3.98f, 2.61f, 1.9f, 1.48f, 1.16f, 0.91f, 0.69f); public static final Transmission AE86TruenoTransmission = new Transmission(4.3f, 4.2f, 5300, 3000) - .quickSixSpeed(3.587f, 2.022f, 1.384f, 1.00f, 0.861f, 0.778f) - .withEcoShift(2500, 1200); + .quickSixSpeed(3.587f, 2.022f, 1.384f, 1.00f, 0.861f, 0.778f); public static final Transmission ATVTransmission = new Transmission(3.937f, 3.544f, 2462, 2738) - .quickSixSpeed(3.525f, 2.218f, 1.433f, 1f, 0.861f, 0.778f) - .withEcoShift(2500, 1200); - + .quickSixSpeed(3.525f, 2.218f, 1.433f, 1f, 0.861f, 0.778f); //Gear shift patterns public static final GearShiftPattern STANDARD_SIX_SHIFT = new GearShiftPattern() diff --git a/src/main/java/com/paneedah/mwc/vehicle/SampleVehicleFactory.java b/src/main/java/com/paneedah/mwc/vehicle/SampleVehicleFactory.java index 2e6c12402..94c4dbcc7 100644 --- a/src/main/java/com/paneedah/mwc/vehicle/SampleVehicleFactory.java +++ b/src/main/java/com/paneedah/mwc/vehicle/SampleVehicleFactory.java @@ -10,6 +10,7 @@ public class SampleVehicleFactory implements VehicleFactory { + @Override public void createVehicle(ModContext modContext) { StatefulRenderer renderer = new VehicleRendererBuilder() @@ -208,7 +209,7 @@ public void createVehicle(ModContext modContext) { // .withAccelerationIncrement(0.015) // .withForwardDeccelerationFactor(0.97) .withRenderer(renderer) - .build(MWC.modContext); + .build(modContext); } } diff --git a/src/main/java/com/paneedah/weaponlib/ClientEventHandler.java b/src/main/java/com/paneedah/weaponlib/ClientEventHandler.java index 3d20ee9ed..655d985e2 100644 --- a/src/main/java/com/paneedah/weaponlib/ClientEventHandler.java +++ b/src/main/java/com/paneedah/weaponlib/ClientEventHandler.java @@ -244,7 +244,7 @@ private void update() { PlayerUtil.restorePlayerSpeed(player, SLOW_DOWN_WHILE_ZOOMING_ATTRIBUTE_MODIFIER); } - if (mainHandHeldWeaponInstance != null && mainHandHeldWeaponInstance.getState() == WeaponState.READY && mainHandHeldWeaponInstance.getStateUpdateTimestamp() + DEFAULT_RECONCILE_TIMEOUT_MILLIS < System.currentTimeMillis() && mainHandHeldWeaponInstance.getSyncStartTimestamp() == 0 && mainHandHeldWeaponInstance.getUpdateTimestamp() + DEFAULT_RECONCILE_TIMEOUT_MILLIS < System.currentTimeMillis()) { + if (mainHandHeldWeaponInstance.getState() == WeaponState.READY && mainHandHeldWeaponInstance.getStateUpdateTimestamp() + DEFAULT_RECONCILE_TIMEOUT_MILLIS < System.currentTimeMillis() && mainHandHeldWeaponInstance.getSyncStartTimestamp() == 0 && mainHandHeldWeaponInstance.getUpdateTimestamp() + DEFAULT_RECONCILE_TIMEOUT_MILLIS < System.currentTimeMillis()) { mainHandHeldWeaponInstance.reconcile(); } } else { @@ -439,56 +439,42 @@ public final void onPostRenderPlayer(RenderPlayerEvent.Post event) { @SubscribeEvent public void onRightHandEmpty(PlayerInteractEvent.RightClickEmpty event) { - final EntityPlayer player = MC.player; - - final List entityVehicleList = player.world.getEntitiesWithinAABB(EntityVehicle.class, new AxisAlignedBB(player.getPosition()).grow(10)); - if (entityVehicleList.isEmpty()) { - return; - } - - for (EntityVehicle entityVehicle : entityVehicleList) { - OreintedBB boundingBox = entityVehicle.getOreintedBoundingBox(); - - //boundingBox.move(entityVehicle.posX, entityVehicle.posY, entityVehicle.posZ); - Vec3d start = player.getPositionEyes(MC.getRenderPartialTicks()); - Vec3d endVec = start.add(player.getLookVec().scale(7)); - - boundingBox.updateInverse(); - - if (boundingBox.doRayTrace(start, endVec) != null) { - CHANNEL.sendToServer(new VehicleInteractMessage(true, entityVehicle.getEntityId(), player.getEntityId())); - return; - } - } + handleVehicleInteraction(event, true, 10, 7); } @SubscribeEvent public void onLeftHandEmpty(PlayerInteractEvent.LeftClickEmpty event) { + handleVehicleInteraction(event, false, 3, 4); + } + + private void handleVehicleInteraction(PlayerInteractEvent event, boolean isRightClick, int range, int rayLength) { final EntityPlayer player = MC.player; + if (player == null || player.world == null) { + return; // Early exit if player or world is null + } + + final List entityVehicleList = player.world.getEntitiesWithinAABB( + EntityVehicle.class, + new AxisAlignedBB(player.getPosition()).grow(range) + ); - final List entityVehicleList = player.world.getEntitiesWithinAABB(EntityVehicle.class, new AxisAlignedBB(player.getPosition()).grow(3)); if (entityVehicleList.isEmpty()) { return; } + Vec3d start = player.getPositionEyes(MC.getRenderPartialTicks()); + Vec3d endVec = start.add(player.getLookVec().scale(rayLength)); + for (EntityVehicle entityVehicle : entityVehicleList) { OreintedBB boundingBox = entityVehicle.getOreintedBoundingBox(); - - //boundingBox.move(entityVehicle.posX, entityVehicle.posY, entityVehicle.posZ); - Vec3d start = player.getPositionEyes(MC.getRenderPartialTicks()); - Vec3d endVec = start.add(player.getLookVec().scale(4)); - - //boundingBox.updateInverse(); - if (boundingBox.doRayTrace(start, endVec) != null) { - CHANNEL.sendToServer(new VehicleInteractMessage(false, entityVehicle.getEntityId(), player.getEntityId())); - //entityVehicle.onKillCommand(); - //entityVehicle.setDead(); - return; + CHANNEL.sendToServer(new VehicleInteractMessage(isRightClick, entityVehicle.getEntityId(), player.getEntityId())); + return; // Exit after the first valid interaction } } } + public static TextureAtlasSprite carParticles; @SubscribeEvent diff --git a/src/main/java/com/paneedah/weaponlib/ClientModContext.java b/src/main/java/com/paneedah/weaponlib/ClientModContext.java index cb1af279c..81ee2af07 100644 --- a/src/main/java/com/paneedah/weaponlib/ClientModContext.java +++ b/src/main/java/com/paneedah/weaponlib/ClientModContext.java @@ -125,10 +125,6 @@ public boolean isClient() { return true; } - @Override - public void registerServerSideOnly() { - } - public PerspectiveManager getViewManager() { return viewManager; } @@ -157,11 +153,6 @@ protected EntityPlayer getPlayer(MessageContext ctx) { return MC.player; } - @Override - public PlayerItemInstanceRegistry getPlayerItemInstanceRegistry() { - return playerItemInstanceRegistry; - } - protected SyncManager getSyncManager() { return syncManager; } diff --git a/src/main/java/com/paneedah/weaponlib/ItemVest.java b/src/main/java/com/paneedah/weaponlib/ItemVest.java index 8bba6f22f..2cebb0848 100644 --- a/src/main/java/com/paneedah/weaponlib/ItemVest.java +++ b/src/main/java/com/paneedah/weaponlib/ItemVest.java @@ -1,5 +1,6 @@ package com.paneedah.weaponlib; +import com.paneedah.mwc.ProjectConstants; import com.paneedah.mwc.renderer.ModelSourceTransforms; import com.paneedah.mwc.renderer.StaticModelSourceRenderer; import com.paneedah.weaponlib.animation.Transform; @@ -167,73 +168,50 @@ public Builder withFirstPersonHandPositioning(Runnable leftHand, Runnable rightH public ItemVest build(ModContext modContext) { if (name == null) { - throw new IllegalStateException("ItemBackpack name not set"); + throw new IllegalStateException("ItemVest name not set"); } -// if(size <= 0) { -// throw new IllegalStateException("ItemBackpack size must be greater than 0"); -// } - -// if(guiTextureName == null) { -// throw new IllegalStateException("ItemBackpack gui texture not set"); -// } -// -// if(!guiTextureName.startsWith("textures/gui/")) { -// guiTextureName = "textures/gui/" + guiTextureName; -// } -// ResourceLocation guiTextureLocation = new ResourceLocation(addFileExtension(guiTextureName, ".png")); - - ItemVest item = new ItemVest(modContext, percentDamageBlocked, durability); - + // Register model and texture for the item ServerGearModelHookRegistry.modelArray.add(this.modelFileString); - item.modelFileString = this.modelFileString; item.textureName = this.properTextureName; item.setTranslationKey(ID + "_" + name); - // Register hook + // Register crafting hook for the item CraftingRegistry.registerHook(item); - + // Register the model for the client side, if applicable if (this.modelFileString != null && !FMLCommonHandler.instance().getSide().isServer()) { - try { - //System.out.println("FOR ITEM: " + item.getRegistryName() + " | "); - ModelBase base = (ModelBase) Class.forName(this.modelFileString).newInstance(); - item.texturedModels.add(new Tuple<>(base, addFileExtension(this.properTextureName, ".png"))); - - - } catch (InstantiationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block + ModelBase baseModel = (ModelBase) Class.forName(this.modelFileString).newInstance(); + item.texturedModels.add(new Tuple<>(baseModel, addFileExtension(this.properTextureName, ".png"))); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { + ProjectConstants.LOGGER.info("Error loading model for: " + this.modelFileString); e.printStackTrace(); } - - } + // Add additional model if specified if (model != null) { item.texturedModels.add(new Tuple<>(model, addFileExtension(textureName, ".png"))); } + // Set creative tab if provided if (tab != null) { item.setCreativeTab(tab); - - } - // lientEventHandler.ITEM_REG.add(item); - - modContext.registerRenderableItem(name, item, FMLCommonHandler.instance().getSide() == Side.CLIENT ? new StaticModelSourceRenderer(transforms) : null); + // Register the item with the mod context as renderable + modContext.registerRenderableItem( + name, + item, + FMLCommonHandler.instance().getSide() == Side.CLIENT ? new StaticModelSourceRenderer(transforms) : null + ); + // Queue item for client-side processing if on client side if (FMLCommonHandler.instance().getSide().isClient()) { COOKING_QUEUE.add(item); } diff --git a/src/main/java/com/paneedah/weaponlib/WeaponRenderer.java b/src/main/java/com/paneedah/weaponlib/WeaponRenderer.java index 405ff30db..432ea96ca 100644 --- a/src/main/java/com/paneedah/weaponlib/WeaponRenderer.java +++ b/src/main/java/com/paneedah/weaponlib/WeaponRenderer.java @@ -99,6 +99,8 @@ public class WeaponRenderer extends ModelSource implements IBakedModel { private static final int INVENTORY_TEXTURE_WIDTH = 128; private static final int INVENTORY_TEXTURE_HEIGHT = 128; + private static final ResourceLocation GUN_ICON_SHEET = new ResourceLocation(ID + ":textures/gui/guniconsheet.png"); + private static final Map ARMOR_TEXTURE_RES_MAP = Maps.newHashMap(); private final org.apache.commons.lang3.tuple.Pair pair; @@ -130,8 +132,6 @@ public MultipartRenderStateManager renderC GL11.glScalef(1.0F, -1.0F, 1F); GlStateManager.translate(-8.0F, -8.0F, 0.0F); - MC.getTextureManager().bindTexture(ResourceManager.GUN_ICON_SHEET); + MC.getTextureManager().bindTexture(GUN_ICON_SHEET); // Checks to see if the gun icon sheet has already @@ -4585,7 +4585,7 @@ private void renderCachedInventoryTexture(RenderContext renderC try { - InputStream inputStream = MC.getResourceManager().getResource(ResourceManager.GUN_ICON_SHEET).getInputStream(); + InputStream inputStream = MC.getResourceManager().getResource(GUN_ICON_SHEET).getInputStream(); BufferedImage bf = ImageIO.read(inputStream); gunIconSheetWidth = bf.getWidth(); @@ -4662,17 +4662,6 @@ private void renderCachedInventoryTexture(RenderContext renderC t.draw(); GlStateManager.enableTexture2D(); } - - - - - - - /* - - */ - - } private static void drawTexturedQuadFit(double x, double y, double width, double height, double zLevel) { @@ -4852,159 +4841,86 @@ static void renderSpecialLeftArm(EntityLivingBase player, RenderContext r public static void renderLeftArm(EntityLivingBase player, RenderContext renderContext, Positioner> positioner) { - //if(true) return; - - Render entityRenderObject = MC.getRenderManager() - .getEntityRenderObject(player); + Render entityRenderObject = MC.getRenderManager().getEntityRenderObject(player); RenderPlayer render = (RenderPlayer) entityRenderObject; + + // Bind the player skin texture MC.getTextureManager().bindTexture(((AbstractClientPlayer) player).getLocationSkin()); GL11.glPushMatrix(); - if (AnimationModeProcessor.getInstance().isLegacyMode()) { + // Apply transformations based on the animation mode + if (AnimationModeProcessor.getInstance().isLegacyMode()) { GL11.glTranslatef(0f, -1f, 0f); GL11.glRotatef(-10F, 1f, 0f, 0f); GL11.glRotatef(0F, 0f, 1f, 0f); GL11.glRotatef(10F, 0f, 0f, 1f); } - float MCt = 45f * ((MC.player.ticksExisted % 45) / 45f); - - + // Position the left hand positioner.position(Part.LEFT_HAND, renderContext); + if (DebugPositioner.isDebugModeEnabled()) { DebugPositioner.position(Part.LEFT_HAND, renderContext); } - /* - AnimationData anm = BBLoader.getAnimation("real", "reload", "lefthand"); - //AnimationData anm = BBLoader.loadAnimationData("m16.animation.json", "animation.M16.reload", "lefthand"); - FuckMyLife.instance.bbMap.clear(); - for(Entry tranny : anm.bbTransition.entrySet()) { - FuckMyLife.instance.bbMap.put(tranny.getKey(), tranny.getValue()); - } - - // System.out.println(anm.bbTransition.get(1.5).directTransform()); - FuckMyLife.instance.timer = 0f; - try { - //FuckMyLife.instance.position(FuckMyLife.instance.timer, 4.0f, true); - } catch(Exception e) { - e.printStackTrace(); - }*/ - // System.out.println(anm.bbTransition); - - - /* - FuckMyLife.instance.timer += 0.01f; - FuckMyLife.instance.timer = 0f; - */ - - - //AnimationModeProcessor.getInstance().renderCross(); - - /* - DebugRenderer.setupBasicRender(); - DebugRenderer.renderPoint(Vec3d.ZERO, new Vec3d(1, 0, 0)); - DebugRenderer.destructBasicRender(); - GlStateManager.color(1, 1, 1); - */ - /* - GlStateManager.rotate(57.7232f, 0, 0, 1); - GlStateManager.rotate(26.1991f, 0, 1, 0); - GlStateManager.rotate(-17.5f, 1, 0, 0); - */ - - - /* - if (!OpenGLSelectionHelper.isInSelectionPass && AnimationModeProcessor.getInstance().getFPSMode()) { - - if (OpenGLSelectionHelper.selectID == 1) { - - AnimationModeProcessor.getInstance().renderTransformIndicator(0.2f); - } - }*/ - renderContext.capturePartPosition(Part.LEFT_HAND); - //GL11.glTranslated(1, 0, 0); - //GlStateManager.rotate(0f, 0, 1, 0); - if (!AnimationModeProcessor.getInstance().isLegacyMode()) { - -// GL11.glTranslatef(-0.38f, -0.12f, -0.13f); + // Additional transformations can be applied here if needed } - - // armModel = new ArmModel(); - + // Render the left arm renderLeftArm(render.getMainModel(), (AbstractClientPlayer) player); + // Check for armor on the chest slot ItemStack itemstack = getItemStackFromSlot(player, EntityEquipmentSlot.CHEST); if (itemstack.getItem() instanceof ItemArmor) { render.bindTexture(getArmorResource(player, itemstack, EntityEquipmentSlot.CHEST, null)); ModelBiped armorModel = getArmorModelHook(player, itemstack, EntityEquipmentSlot.CHEST, null); + if (armorModel != null) { renderLeftArm(armorModel, (AbstractClientPlayer) player); } } - /* - * ItemStack itemstack = getItemStackFromSlot(player, EntityEquipmentSlot.CHEST); - - if ( && itemstack.getItem() instanceof ItemArmor) { - // ItemArmor itemarmor = (ItemArmor)itemstack.getItem(); - renderer.bindTexture(getArmorResource(player, itemstack, EntityEquipmentSlot.CHEST, null)); - - ModelBiped armorModel = getArmorModelHook(player, itemstack, EntityEquipmentSlot.CHEST, null); - if (armorModel != null) { - renderRightArm(armorModel, (AbstractClientPlayer) player); - } - } - */ - - // GlStateManager.enableTexture2D(); - GL11.glPopMatrix(); - } - public static void renderRightArm(ModelBiped modelplayer, AbstractClientPlayer clientPlayer) { + public static void renderRightArm(ModelBiped modelPlayer, AbstractClientPlayer clientPlayer) { float f = 1.0F; - GlStateManager.color(f, f, f); - // ModelPlayer modelplayer = renderPlayer.getMainModel(); - // Can ignore private method setModelVisibilities since it was already called - // earlier for left hand - setModelVisibilities(modelplayer, clientPlayer); + // Set the model visibilities + setModelVisibilities(modelPlayer, clientPlayer); GlStateManager.enableBlend(); - modelplayer.swingProgress = 0.0F; - modelplayer.isSneak = false; - modelplayer.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, clientPlayer); + modelPlayer.swingProgress = 0.0F; + modelPlayer.isSneak = false; + modelPlayer.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, clientPlayer); + + // Set right arm rotation angles based on the animation mode if (AnimationModeProcessor.getInstance().isLegacyMode()) { - modelplayer.bipedRightArm.rotateAngleX = -0.3F; - modelplayer.bipedRightArm.rotateAngleY = 0.0F; + modelPlayer.bipedRightArm.rotateAngleX = -0.3F; + modelPlayer.bipedRightArm.rotateAngleY = 0.0F; } else { - modelplayer.bipedRightArm.rotateAngleX = (float) Math.toRadians(-90); - modelplayer.bipedRightArm.rotateAngleY = 0f; - modelplayer.bipedRightArm.rotateAngleZ = 0f; + modelPlayer.bipedRightArm.rotateAngleX = (float) Math.toRadians(-90); + modelPlayer.bipedRightArm.rotateAngleY = 0f; + modelPlayer.bipedRightArm.rotateAngleZ = 0f; } + // Render the right arm + modelPlayer.bipedRightArm.render(0.0625F); - modelplayer.bipedRightArm.render(0.0625F); - - if (modelplayer instanceof ModelPlayer) { + if (modelPlayer instanceof ModelPlayer) { if (AnimationModeProcessor.getInstance().isLegacyMode()) { - ((ModelPlayer) modelplayer).bipedRightArmwear.rotateAngleX = 0.0F; - ((ModelPlayer) modelplayer).bipedRightArmwear.rotateAngleX = -0.3F; + ((ModelPlayer) modelPlayer).bipedRightArmwear.rotateAngleX = -0.3F; } else { - modelplayer.bipedRightArm.rotateAngleX = 0f; - modelplayer.bipedRightArm.rotateAngleY = 0f; - modelplayer.bipedRightArm.rotateAngleZ = 0f; + modelPlayer.bipedRightArm.rotateAngleX = 0f; + modelPlayer.bipedRightArm.rotateAngleY = 0f; + modelPlayer.bipedRightArm.rotateAngleZ = 0f; } - // ((ModelPlayer) modelplayer).bipedRightArmwear.renderer(0.0625F); } GlStateManager.disableBlend(); diff --git a/src/main/java/com/paneedah/weaponlib/animation/AnimationModeProcessor.java b/src/main/java/com/paneedah/weaponlib/animation/AnimationModeProcessor.java index 2e227df6c..8f74e04ac 100644 --- a/src/main/java/com/paneedah/weaponlib/animation/AnimationModeProcessor.java +++ b/src/main/java/com/paneedah/weaponlib/animation/AnimationModeProcessor.java @@ -215,321 +215,149 @@ public Transform getTransformFromSelected() { } public void onTick() { - - //this.transformMode = 1; - - //MC.player.world.setWorldTime(6000); - + // Check for valid context and main held weapon if (ClientModContext.getContext() != null && ClientModContext.getContext().getMainHeldWeapon() != null) { if (this.pwi == null || pwi != ClientModContext.getContext().getMainHeldWeapon()) { Builder builder = getCurrentWeaponRenderBuilder(); pwi = ClientModContext.getContext().getMainHeldWeapon(); - //System.out.println("BUILDER: " + builder + " | PWI: " + pwi); backupFP = builder.firstPersonTransform.copy(); backupFPL = builder.firstPersonLeftHandTransform.copy(); backupFPR = builder.firstPersonRightHandTransform.copy(); } } + // Handle muzzle positioner if (ClientEventHandler.muzzlePositioner) { DebugPositioner.setDebugPart(Part.NONE); OpenGLSelectionHelper.selectID = 4; transformMode = 1; } - if (AnimationGUI.getInstance().editRotButton.isState()) { + // Manage rotation point editing state + editRotationPointMode = AnimationGUI.getInstance().editRotButton.isState(); + if (editRotationPointMode) { transformMode = 1; - editRotationPointMode = true; - } else { - editRotationPointMode = false; } + // Handle mouse input if (Mouse.isButtonDown(0) && !mouseStatus) { mouseStatus = true; onMouseClick(); leftClickLast = System.currentTimeMillis(); - } else if ((mouseStatus && !Mouse.isButtonDown(0))) { + } else if (mouseStatus && !Mouse.isButtonDown(0)) { mouseStatus = false; permissionToDrag = false; leftLock = false; } - if (!Mouse.isButtonDown(0)) { - AnimationModeProcessor.getInstance().atGrab = null; } - + // Handle dragging double dx = Mouse.getDX(); double dy = Mouse.getDY(); - if (permissionToDrag && colorSelected == -1) { - - if (Mouse.isButtonDown(0)) { - // System.out.println(MC.mouseHelper.deltaX); - // double x = MC.mouseHelper.deltaX/1.0; - // double y = MC.mouseHelper.deltaY/300.0; - - - double x = dx / 2f; - double y = dy / 2f; - rot = rot.add(-y, x, 0); - } + if (permissionToDrag && colorSelected == -1 && Mouse.isButtonDown(0)) { + double x = dx / 2f; + double y = dy / 2f; + rot = rot.add(-y, x, 0); } - if (colorSelected != -1 && Mouse.isButtonDown(0)) { - // transformMode = 2; - if (transformMode == 1) { - float m = 0.2f; - - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - m /= 10; - } - - Vec3d vec = Vec3d.ZERO; - switch (colorSelected) { - case 1: - vec = new Vec3d(-dx * m, 0, 0); - // DebugPositioner.incrementXPosition((float) -dx, false); - break; - case 2: - vec = new Vec3d(0, -dy * m, 0); - // DebugPositioner.incrementYPosition((float) -dy, false); - - break; - case 3: - vec = new Vec3d(0, 0, dx * m); - // DebugPositioner.incrementZPosition((float) dx, false); - - break; - } - - - boolean modernMode = true; - - if (ClientEventHandler.muzzlePositioner) { - ClientEventHandler.debugmuzzlePosition = ClientEventHandler.debugmuzzlePosition.add(-vec.x * m * 0.1, vec.y * m * 0.1, vec.z * m * 0.1); - } else if (!modernMode) { - DebugPositioner.incrementXPosition((float) vec.x * m, false); - DebugPositioner.incrementYPosition((float) vec.y * m, false); - DebugPositioner.incrementZPosition((float) vec.z * m, false); - } else if (AnimationGUI.getInstance().magEdit.isState()) { - - - ClientEventHandler.magRotPositioner = ClientEventHandler.magRotPositioner.add(vec.x * m, vec.y * m, vec.z * m); - - } else { - - if (!editRotationPointMode) { - Transform t = getTransformFromSelected(); - - - t.withPosition(t.getPositionX() + vec.x * m, t.getPositionY() + vec.y * m, t.getPositionZ() + vec.z * m); - - if (AnimationGUI.getInstance().leftDrag.isState()) { - t.withRotation(t.getRotationX(), t.getRotationY() - vec.x * 0.4, t.getRotationZ()); - } - - } else { - Transform t = getTransformFromSelected(); - - - t.withRotationPoint(t.getRotationPointX() + vec.x * m, t.getRotationPointY() + vec.y * m, t.getRotationPointZ() + vec.z * m); - - } + // Handle color selection adjustments + if (colorSelected != -1 && Mouse.isButtonDown(0)) { + float m = 0.2f; + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + m /= 10; + } - } + Vec3d vec = Vec3d.ZERO; + switch (colorSelected) { + case 1: + vec = new Vec3d(-dx * m, 0, 0); + break; + case 2: + vec = new Vec3d(0, -dy * m, 0); + break; + case 3: + vec = new Vec3d(0, 0, dx * m); + break; + } + boolean modernMode = true; + if (ClientEventHandler.muzzlePositioner) { + ClientEventHandler.debugmuzzlePosition = ClientEventHandler.debugmuzzlePosition.add(-vec.x * m * 0.1, vec.y * m * 0.1, vec.z * m * 0.1); + } else if (!modernMode) { + DebugPositioner.incrementXPosition((float) vec.x * m, false); + DebugPositioner.incrementYPosition((float) vec.y * m, false); + DebugPositioner.incrementZPosition((float) vec.z * m, false); + } else if (AnimationGUI.getInstance().magEdit.isState()) { + ClientEventHandler.magRotPositioner = ClientEventHandler.magRotPositioner.add(vec.x * m, vec.y * m, vec.z * m); } else { - - - Vec3d vec = Vec3d.ZERO; - switch (colorSelected) { - case 1: - - vec = new Vec3d(0, 1, 0); - // DebugPositioner.incrementYRotation((float) ((float) -dx)); - - // DebugPositioner.incrementXPosition((float) -dx, false); - break; - case 2: - - vec = new Vec3d(1, 0, 0); - // DebugPositioner.incrementXRotation((float) -dy); - break; - case 3: - vec = new Vec3d(0, 0, 1); - // DebugPositioner.incrementZRotation((float) dy); - - break; + Transform t = getTransformFromSelected(); + if (!editRotationPointMode) { + t.withPosition(t.getPositionX() + vec.x * m, t.getPositionY() + vec.y * m, t.getPositionZ() + vec.z * m); + if (AnimationGUI.getInstance().leftDrag.isState()) { + t.withRotation(t.getRotationX(), t.getRotationY() - vec.x * 0.4, t.getRotationZ()); + } + } else { + t.withRotationPoint(t.getRotationPointX() + vec.x * m, t.getRotationPointY() + vec.y * m, t.getRotationPointZ() + vec.z * m); } + } + } - // DebugPositioner.setAutorotate(0, 0, 0); - // Matrix4f rotte = DebugPositioner.rotationMatrix(); - // System.out.println(currentPartMatrix); - /* - * Matrix4f rotte = new Matrix4f(DebugPositioner.rotationMatrix()); - * //rotte.invert(); rotte.transpose(); float m = (float) -dy*0.5f; - * - * - * - * - * double[] angles = MatrixHelper.MatrixToYawPitchRoll(rotte); Position i = - * DebugPositioner.getCurrentPartPosition(); i.xRotation = (float) - * Math.toDegrees(angles[0]); i.yRotation = (float) Math.toDegrees(angles[1]); - * i.zRotation = (float) Math.toDegrees(angles[2]); - * - */ - - // DebugPositioner.setAdjustRotPoint(false); - - float m = (float) -dy * 0.35f; - - - boolean modernMode = true; - - - ScaledResolution scaledresolution = new ScaledResolution(MC); - final int scaledWidth = scaledresolution.getScaledWidth(); - final int scaledHeight = scaledresolution.getScaledHeight(); - int mouseX = Mouse.getX() * scaledWidth / MC.displayWidth; - int mouseY = scaledHeight - Mouse.getY() * scaledHeight / MC.displayHeight - 1; - - Quaternion quat = Arcball.runArcBall(mouseX, mouseY); - double[] quangles = MatrixHelper.toEulerAngles(quat); - - - if (!modernMode) { - DebugPositioner.incrementXRotation((float) (vec.x * m)); - DebugPositioner.incrementYRotation((float) (vec.y * m)); - DebugPositioner.incrementZRotation((float) (vec.z * m)); + // Handle rotation adjustments + if (colorSelected != -1) { + Vec3d vec = Vec3d.ZERO; + switch (colorSelected) { + case 1: + vec = new Vec3d(0, 1, 0); + break; + case 2: + vec = new Vec3d(1, 0, 0); + break; + case 3: + vec = new Vec3d(0, 0, 1); + break; + } - } else { - Builder i = ClientModContext.getContext().getMainHeldWeapon().getWeapon().getRenderer().getWeaponRendererBuilder(); - Transform t = getTransformFromSelected(); + float m = (float) -dy * 0.35f; + boolean modernMode = true; + ScaledResolution scaledResolution = new ScaledResolution(MC); + final int scaledWidth = scaledResolution.getScaledWidth(); + final int scaledHeight = scaledResolution.getScaledHeight(); + int mouseX = Mouse.getX() * scaledWidth / MC.displayWidth; + int mouseY = scaledHeight - Mouse.getY() * scaledHeight / MC.displayHeight - 1; - if (atGrab != null) { - t.withRotation(atGrab.getRotationX() + Math.toDegrees(quangles[0]) * vec.x, atGrab.getRotationY() + Math.toDegrees(quangles[1]) * vec.y, atGrab.getRotationZ() + -Math.toDegrees(quangles[2]) * vec.z); - } - t.printTransform(); - //t.withRotation(t.getRotationX() + vec.x*m*0.1, t.getRotationY() + vec.y*m*0.1, t.getRotationZ() + vec.z*m*0.1); + Quaternion quat = Arcball.runArcBall(mouseX, mouseY); + double[] quangles = MatrixHelper.toEulerAngles(quat); + if (!modernMode) { + DebugPositioner.incrementXRotation((float) (vec.x * m)); + DebugPositioner.incrementYRotation((float) (vec.y * m)); + DebugPositioner.incrementZRotation((float) (vec.z * m)); + } else { + Transform t = getTransformFromSelected(); + if (atGrab != null) { + t.withRotation( + atGrab.getRotationX() + Math.toDegrees(quangles[0]) * vec.x, + atGrab.getRotationY() + Math.toDegrees(quangles[1]) * vec.y, + atGrab.getRotationZ() - Math.toDegrees(quangles[2]) * vec.z + ); } - - - // System.out.println(currentPartMatrix); - - // System.out.println(axis); - - /* - * Matrix4f rotte = new Matrix4f(DebugPositioner.rotationMatrix()); - * - * - * Matrix4f axisM = currentPartMatrix; Vector3f axis = new Vector3f(axisM.m10, - * axisM.m11, axisM.m12); - * - * //rotte.setIdentity(); - * - * //Matrix4f testMa = MatrixHelper.yawPitchRollToMatrix(vec.x*m, vec.y*m, - * vec.z*m); // axis = (Vector3f) axis.scale(-1); axis.normalise(); - * System.out.println(axis); - * - * Matrix4f rot = new Matrix4f(); rot.rotate((float) Math.toRadians(2), axis); - * - * - * - * //rot.invert(); - * - * Matrix4f.mul(rotte, rot, rotte); - * - * double[] angles = MatrixHelper.MatrixToYawPitchRoll(rotte); Position i = - * DebugPositioner.getCurrentPartPosition(); i.yRotation = (float) - * Math.toDegrees(angles[0]); i.xRotation = (float) Math.toDegrees(angles[1]); - * i.zRotation = (float) Math.toDegrees(angles[2]); - * - */ - - // i.zRotation = 45f; - - /* - * i.x = rotte.m30; i.y = rotte.m31; i.z = rotte.m32; - */ - - /* - * i.xRotation = 0; i.yRotation = 0; i.zRotation = 0; - * - * i.x = 0; i.y = 0; i.z = 0; - */ - // Position i = DebugPositioner.getCurrentPartPosition(); - - /* - * i.rOffsetY = 0f; i.rOffsetZ = 0f; i.rOffsetX = 0f; - */ - - /* - * float m = (float) -dy*0.5f; Position i = - * DebugPositioner.getCurrentPartPosition(); Quaternion quat = - * MatrixHelper.fromEulerAngles(i.z, i.x, i.y); - * - * Quaternion q2 = new Quaternion(); q2.setFromAxisAngle(new Vector4f((float) - * Math.toRadians(120), 1, 120, 0)); - * - * Quaternion.mul(quat, q2, quat); - * - * double[] angle = MatrixHelper.toEulerAngles(quat); i.zRotation = (float) - * Math.toDegrees(angle[0]); i.xRotation = (float) Math.toDegrees(angle[1]); - * i.yRotation = (float) Math.toDegrees(angle[2]); - */ - - /* - * Matrix4f test = new Matrix4f(); test.m10 = -69; System.out.println(test); - */ - // System.out.println("yo"); - // vec = new Vec3d(1, 0, 0); - - /* - * vec = ModelRenderTool.transformViaMatrix(vec, rotte); - * - * - * double[] angles = MatrixHelper.MatrixToYawPitchRoll(rotte); Position i = - * DebugPositioner.getCurrentPartPosition(); i.yRotation = (float) - * Math.toDegrees(angles[0]); i.xRotation = (float) Math.toDegrees(angles[1]); - * i.zRotation = (float) Math.toDegrees(angles[2]); - * - * if(1+1==3) { i.yRotation = 0; i.xRotation = 0; i.zRotation = 0; } - */ - /* - * Position i = DebugPositioner.getCurrentPartPosition(); - * - * if(1+1==2) { i.yRotation = 0; i.xRotation = 0; i.zRotation = 0; } - */ - - // DebugPositioner.incrementXRotation((float) (m)); - - /* - * DebugPositioner.incrementXRotation((float) (vec.x*m)); - * DebugPositioner.incrementYRotation((float) (vec.y*m)); - * DebugPositioner.incrementZRotation((float) (vec.z*m)); - */ - + t.printTransform(); } - } + + // Handle right mouse button for panning if (Mouse.isButtonDown(1)) { - // System.out.println(Mouse.getDX()); double x = dx / 10f; double y = dy / 10f; - - // double x = MC.mouseHelper.deltaX/120.0; - // double y = MC.mouseHelper.deltaY/120.0; pan = pan.add(-x, -y, 0); } - - // rot = Vec3d.ZERO; } public int colorSelected = -1; diff --git a/src/main/java/com/paneedah/weaponlib/animation/gui/AnimationGUI.java b/src/main/java/com/paneedah/weaponlib/animation/gui/AnimationGUI.java index 994816262..4f842f336 100644 --- a/src/main/java/com/paneedah/weaponlib/animation/gui/AnimationGUI.java +++ b/src/main/java/com/paneedah/weaponlib/animation/gui/AnimationGUI.java @@ -37,10 +37,6 @@ public class AnimationGUI { private static final AnimationGUI instance = new AnimationGUI(); - - public static final ResourceLocation TEXTURES = new ResourceLocation(ID + ":textures/hud/animguio.png"); - - public ArrayList panels = new ArrayList<>(); public boolean mouseStatus = false; @@ -112,7 +108,6 @@ public RecoilParam getRecoilParams() { public AnimationGUI() { - Panel cameraPanel = new Panel(this, "Functionality", 10, 10, 20); // cam reset 0 diff --git a/src/main/java/com/paneedah/weaponlib/animation/gui/Button.java b/src/main/java/com/paneedah/weaponlib/animation/gui/Button.java index 1d4ff4ce9..d89df7370 100644 --- a/src/main/java/com/paneedah/weaponlib/animation/gui/Button.java +++ b/src/main/java/com/paneedah/weaponlib/animation/gui/Button.java @@ -6,14 +6,11 @@ public class Button { - public double x = 0; - public double y = 0; + public double x, y; public String tooltip; - public int id; - - public int size = 0; + public int size; public boolean state = false; public boolean isToggle = false; diff --git a/src/main/java/com/paneedah/weaponlib/render/GLModelBuilder.java b/src/main/java/com/paneedah/weaponlib/render/GLModelBuilder.java index e3e5866be..3b3c52c51 100644 --- a/src/main/java/com/paneedah/weaponlib/render/GLModelBuilder.java +++ b/src/main/java/com/paneedah/weaponlib/render/GLModelBuilder.java @@ -17,7 +17,7 @@ public class GLModelBuilder { /** * Creates a static VBO * - * @param How many floats are you storing? + * @param floatCount How many floats are you storing? * * @return The VBO's identity */ diff --git a/src/main/java/com/paneedah/weaponlib/render/ModificationGUI.java b/src/main/java/com/paneedah/weaponlib/render/ModificationGUI.java index 711129ce4..49bd02f06 100644 --- a/src/main/java/com/paneedah/weaponlib/render/ModificationGUI.java +++ b/src/main/java/com/paneedah/weaponlib/render/ModificationGUI.java @@ -4,6 +4,7 @@ import com.paneedah.weaponlib.WeaponAttachmentAspect.FlaggedAttachment; import com.paneedah.weaponlib.command.DebugCommand; import com.paneedah.weaponlib.config.BalancePackManager; +import com.paneedah.weaponlib.jim.util.LangTools; import com.paneedah.weaponlib.render.gui.ColorPalette; import com.paneedah.weaponlib.render.gui.GUIRenderHelper; import com.paneedah.weaponlib.render.gui.GUIRenderHelper.StringAlignment; @@ -211,7 +212,7 @@ public static ModificationGroup fromID(int id) { * faster to just look it up here. * (Attachment = 0, Modification = 1, Customization = 2) * - * @param ID (0-2) + * @param id (0-2) * * @return String with first letter capatilized */ @@ -242,7 +243,7 @@ public static class TooltipBuilder { /** * Sets tooltip builder's color * - * @param Hex color code + * @param color The color code */ public void setColor(int color) { this.color = color; @@ -251,7 +252,7 @@ public void setColor(int color) { /** * Adds a line with a bullet point in front of it * - * @param line + * @param text The text to add a bullet point to */ public void addBulletPoint(String text) { addLine("� " + text); @@ -436,24 +437,6 @@ public void setPos(double x, double y) { } - - /** - * Translates an unlocalized name via {@link TextComponentTranslation} - * - * @param Unlocalized item name - * - * @return Localized item name - */ - public static String translate(String unlocalized) { - return new TextComponentTranslation(unlocalized + ".name").getFormattedText(); - } - - public double getGUIScale() { - - return 0.3; - } - - /** * Allows the class to update things like alpha without losing track of the initial color */ @@ -613,7 +596,7 @@ public void render(ModContext modContext) { 30, 205, 1.0, ColorPalette.WHITE); GUIRenderHelper.drawScaledString( - TextFormatting.GOLD + translate(weapon.getTranslationKey()), + TextFormatting.GOLD + LangTools.formatName(weapon.getTranslationKey()), 30, 30, 1.0, ColorPalette.WHITE); GUIRenderHelper.drawScaledString( "Damage :: " + TextFormatting.GOLD + String.format("%.2f", (BalancePackManager.getNetGunDamage(weapon))), @@ -856,7 +839,7 @@ public void drawModificationTab(ScaledResolution sr, ModificationTab tab, int mo pwi); tooltip.addLine(TextFormatting.BOLD + "Is Required By:"); for (ItemAttachment req : requirees) - tooltip.addBulletPoint(translate(req.getTranslationKey())); + tooltip.addBulletPoint(LangTools.formatName(req.getTranslationKey())); } if (isInClick) { @@ -1013,10 +996,10 @@ public void drawModificationTab(ScaledResolution sr, ModificationTab tab, int mo tooltip.color = TOOLTIP_COL_ERROR; - tooltip.addBulletPoint(translate(flag.getAttachment().getTranslationKey())); + tooltip.addBulletPoint(LangTools.formatName(flag.getAttachment().getTranslationKey())); tooltip.addLine(TextFormatting.BOLD + "Required Mods: "); for (ItemAttachment required : flag.getRequiredParts()) { - tooltip.addBulletPoint(translate(required.getTranslationKey())); + tooltip.addBulletPoint(LangTools.formatName(required.getTranslationKey())); } } // drawTexturedRect(i+11, 150, 0, 300, 89, 89, 512, 512); diff --git a/src/main/java/com/paneedah/weaponlib/render/ResourceManager.java b/src/main/java/com/paneedah/weaponlib/render/ResourceManager.java deleted file mode 100644 index 630f5e6fe..000000000 --- a/src/main/java/com/paneedah/weaponlib/render/ResourceManager.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.paneedah.weaponlib.render; - -import net.minecraft.util.ResourceLocation; - -import static com.paneedah.mwc.ProjectConstants.ID; - -public class ResourceManager { - // Controls some guns icon textures - public static final ResourceLocation GUN_ICON_SHEET = new ResourceLocation(ID + ":textures/gui/guniconsheet.png"); -} diff --git a/src/main/java/com/paneedah/weaponlib/render/SpriteSheetTools.java b/src/main/java/com/paneedah/weaponlib/render/SpriteSheetTools.java index d39e52da2..319f3df8c 100644 --- a/src/main/java/com/paneedah/weaponlib/render/SpriteSheetTools.java +++ b/src/main/java/com/paneedah/weaponlib/render/SpriteSheetTools.java @@ -43,38 +43,55 @@ public double getMaxV() { public void setMaxV(double maxV) { this.maxV = maxV; } - } - + /** + * Retrieves a square sprite from a sprite sheet. + * + * @param id The index of the sprite. + * @param spriteSize The size of the sprite. + * @param width The width of the sprite sheet. + * @param height The height of the sprite sheet. + * @return A new Sprite object representing the sprite's coordinates. + */ public static Sprite getSquareSprite(int id, double spriteSize, double width, double height) { - - //id = 2; int columns = (int) Math.floor(width / spriteSize); int rows = (int) Math.floor(height / spriteSize); double u = (id % columns) * spriteSize / width; double v = Math.floor(id / columns) * spriteSize / height; - //System.out.println(u + " | " + v + " | " + (columns)); return new Sprite(u, v, u + (spriteSize / width), v + (spriteSize / height)); } + /** + * Retrieves a rectangular sprite from a sprite sheet, with an option to flip the sprite. + * + * @param id The index of the sprite. + * @param spriteWidth The width of the sprite. + * @param spriteHeight The height of the sprite. + * @param width The width of the sprite sheet. + * @param height The height of the sprite sheet. + * @param flip Whether to flip the sprite horizontally. + * @return A new Sprite object representing the sprite's coordinates. + */ public static Sprite getRectSprite(int id, double spriteWidth, double spriteHeight, double width, double height, boolean flip) { int columns = (int) Math.floor(width / spriteWidth); int rows = (int) Math.floor(height / spriteHeight); double u = (id % columns) * spriteWidth / width; - double v = (id / columns) * spriteWidth / height; - - if (flip) { + double v = Math.floor(id / columns) * spriteHeight / height; + double minU = u; + double maxU = u + (spriteWidth / width); + double minV = v; + double maxV = v + (spriteHeight / height); - return new Sprite(u, v, u + (spriteWidth / width), v + (spriteHeight / height)); - - } else { - return new Sprite(u, v, u + (spriteWidth / width), v + (spriteHeight / height)); - + // If flipping horizontally, swap minU and maxU + if (flip) { + double temp = minU; + minU = maxU; + maxU = temp; } + return new Sprite(minU, minV, maxU, maxV); } - } diff --git a/src/main/java/com/paneedah/weaponlib/render/modern/RayTraceUtil.java b/src/main/java/com/paneedah/weaponlib/render/modern/RayTraceUtil.java deleted file mode 100644 index 2cfbdce87..000000000 --- a/src/main/java/com/paneedah/weaponlib/render/modern/RayTraceUtil.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.paneedah.weaponlib.render.modern; - -public class RayTraceUtil { - - -} diff --git a/src/main/java/com/paneedah/weaponlib/render/qrender/QBoxer.java b/src/main/java/com/paneedah/weaponlib/render/qrender/QBoxer.java deleted file mode 100644 index f7e062a8e..000000000 --- a/src/main/java/com/paneedah/weaponlib/render/qrender/QBoxer.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.paneedah.weaponlib.render.qrender; - -import net.minecraft.client.model.ModelBox; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.model.PositionTextureVertex; -import net.minecraft.client.model.TexturedQuad; -import net.minecraft.util.math.Vec3d; -import org.lwjgl.util.vector.Matrix4f; -import org.lwjgl.util.vector.Vector4f; - -public class QBoxer extends ModelBox { - - private PositionTextureVertex[] vertexPositions; - private TexturedQuad[] quadList; - - - /* - * CONSTRUCTOR INFO - */ - public int texU; - public int texV; - public float x; - public float y; - public float z; - public int dx; - public int dy; - public int dz; - public float delta; - public boolean mirror; - - - public QBoxer(ModelRenderer renderer, int texU, int texV, float x, float y, float z, int dx, int dy, int dz, - float delta, boolean mirror) { - super(renderer, texU, texV, x, y, z, dx, dy, dz, delta, mirror); - - /* - this.vertexPositions = new PositionTextureVertex[8]; - this.quadList = new TexturedQuad[6]; - float f = x + (float)dx; - float f1 = y + (float)dy; - float f2 = z + (float)dz; - x = x - delta; - y = y - delta; - z = z - delta; - f = f + delta; - f1 = f1 + delta; - f2 = f2 + delta; - - if (mirror) - { - float f3 = f; - f = x; - x = f3; - } - - PositionTextureVertex positiontexturevertex7 = new PositionTextureVertex(x, y, z, 0.0F, 0.0F); - PositionTextureVertex positiontexturevertex = new PositionTextureVertex(f, y, z, 0.0F, 8.0F); - PositionTextureVertex positiontexturevertex1 = new PositionTextureVertex(f, f1, z, 8.0F, 8.0F); - PositionTextureVertex positiontexturevertex2 = new PositionTextureVertex(x, f1, z, 8.0F, 0.0F); - PositionTextureVertex positiontexturevertex3 = new PositionTextureVertex(x, y, f2, 0.0F, 0.0F); - PositionTextureVertex positiontexturevertex4 = new PositionTextureVertex(f, y, f2, 0.0F, 8.0F); - PositionTextureVertex positiontexturevertex5 = new PositionTextureVertex(f, f1, f2, 8.0F, 8.0F); - PositionTextureVertex positiontexturevertex6 = new PositionTextureVertex(x, f1, f2, 8.0F, 0.0F); - - - applyMatrixTransforms(positiontexturevertex, openGLMAT); - applyMatrixTransforms(positiontexturevertex1, openGLMAT); - applyMatrixTransforms(positiontexturevertex2, openGLMAT); - applyMatrixTransforms(positiontexturevertex3, openGLMAT); - applyMatrixTransforms(positiontexturevertex4, openGLMAT); - applyMatrixTransforms(positiontexturevertex5, openGLMAT); - applyMatrixTransforms(positiontexturevertex6, openGLMAT); - applyMatrixTransforms(positiontexturevertex7, openGLMAT); - - this.vertexPositions[0] = positiontexturevertex7; - this.vertexPositions[1] = positiontexturevertex; - this.vertexPositions[2] = positiontexturevertex1; - this.vertexPositions[3] = positiontexturevertex2; - this.vertexPositions[4] = positiontexturevertex3; - this.vertexPositions[5] = positiontexturevertex4; - this.vertexPositions[6] = positiontexturevertex5; - this.vertexPositions[7] = positiontexturevertex6; - this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex4, positiontexturevertex, positiontexturevertex1, positiontexturevertex5}, texU + dz + dx, texV + dz, texU + dz + dx + dz, texV + dz + dy, renderer.textureWidth, renderer.textureHeight); - this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex7, positiontexturevertex3, positiontexturevertex6, positiontexturevertex2}, texU, texV + dz, texU + dz, texV + dz + dy, renderer.textureWidth, renderer.textureHeight); - this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex4, positiontexturevertex3, positiontexturevertex7, positiontexturevertex}, texU + dz, texV, texU + dz + dx, texV + dz, renderer.textureWidth, renderer.textureHeight); - this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex1, positiontexturevertex2, positiontexturevertex6, positiontexturevertex5}, texU + dz + dx, texV + dz, texU + dz + dx + dx, texV, renderer.textureWidth, renderer.textureHeight); - this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex, positiontexturevertex7, positiontexturevertex2, positiontexturevertex1}, texU + dz, texV + dz, texU + dz + dx, texV + dz + dy, renderer.textureWidth, renderer.textureHeight); - this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] {positiontexturevertex3, positiontexturevertex4, positiontexturevertex5, positiontexturevertex6}, texU + dz + dx + dz, texV + dz, texU + dz + dx + dz + dx, texV + dz + dy, renderer.textureWidth, renderer.textureHeight); - - if (mirror) - { - for (TexturedQuad texturedquad : this.quadList) - { - texturedquad.flipFace(); - } - }*/ - } - - - public void applyMatrixTransforms(PositionTextureVertex vert, Matrix4f openGLMAT) { - Vec3d v = vert.vector3D; - Vector4f v3d = new Vector4f((float) v.x, (float) v.y, (float) v.z, 1.0f); - - - //org.lwjgl.util.vector.Matrix4f openGLMAT = MatrixHelper.captureMatrix(); - Vector4f r = org.lwjgl.util.vector.Matrix4f.transform(openGLMAT, v3d, null); - vert.vector3D = new Vec3d(r.x, r.y, r.z); - - } - -} diff --git a/src/main/java/com/paneedah/weaponlib/render/qrender/QOven.java b/src/main/java/com/paneedah/weaponlib/render/qrender/QOven.java deleted file mode 100644 index 59705ac9a..000000000 --- a/src/main/java/com/paneedah/weaponlib/render/qrender/QOven.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.paneedah.weaponlib.render.qrender; - -import net.minecraft.client.model.ModelBase; - -public class QOven { - - public void bake(ModelBase model) { - - } - -} diff --git a/src/main/java/com/paneedah/weaponlib/render/scopes/Reticle.java b/src/main/java/com/paneedah/weaponlib/render/scopes/Reticle.java index f71d62ad7..dabcc229c 100644 --- a/src/main/java/com/paneedah/weaponlib/render/scopes/Reticle.java +++ b/src/main/java/com/paneedah/weaponlib/render/scopes/Reticle.java @@ -1,5 +1,7 @@ package com.paneedah.weaponlib.render.scopes; +import lombok.Getter; +import lombok.Setter; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.Vec3d; @@ -11,12 +13,11 @@ public class Reticle { private static final int DEFAULT_TINT = 0x576574; - private ResourceLocation reticleTexture; + @Getter @Setter private ResourceLocation reticleTexture; private Type reticleType; - - private float textureScale; - private Vec3d backgroundColor; + @Setter @Getter private float textureScale; + @Setter @Getter private Vec3d backgroundColor; public enum Type { HOLOGRAPHIC, @@ -45,30 +46,6 @@ private static Vec3d extractColorFromHex(int color) { return new Vec3d(col.getRed() / 255f, col.getBlue() / 255f, col.getGreen() / 255f); } - public ResourceLocation getReticleTexture() { - return reticleTexture; - } - - public void setReticleTexture(ResourceLocation reticleTexture) { - this.reticleTexture = reticleTexture; - } - - public float getTextureScale() { - return textureScale; - } - - public void setTextureScale(float textureScale) { - this.textureScale = textureScale; - } - - - public Vec3d getBackgroundColor() { - return backgroundColor; - } - - public void setBackgroundColor(Vec3d backgroundColor) { - this.backgroundColor = backgroundColor; - } public static int getDefaultTint() { return DEFAULT_TINT; diff --git a/src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityRenderer.java b/src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityRenderer.java index b75534aff..f0fc1bb64 100644 --- a/src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityRenderer.java +++ b/src/main/java/com/paneedah/weaponlib/tile/CustomTileEntityRenderer.java @@ -7,7 +7,18 @@ import java.util.function.Consumer; -public class CustomTileEntityRenderer extends net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer> { +/** + * Custom renderer for TileEntity with a specified model and texture. + * + * @param The type of CustomTileEntity being rendered. + */ +public class CustomTileEntityRenderer> + extends net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer { + + private static final float TRANSLATE_Y = 1.0F; + private static final float SCALE_FACTOR = 1.0F; + private static final float ROTATION_ANGLE = 90f; + private static final float MODEL_RENDER_SCALE = 0.0625f; private final ModelBase model; private final ResourceLocation textureResource; @@ -20,30 +31,52 @@ public CustomTileEntityRenderer(ModelBase model, ResourceLocation textureResourc this.positioning = positioning; } + /** + * Renders the tile entity with appropriate transformations. + * + * @param tileEntity The tile entity being rendered. + * @param posX The x position for rendering. + * @param posY The y position for rendering. + * @param posZ The z position for rendering. + * @param partialTicks Partial ticks for smoother rendering. + * @param destroyStage The destroy stage of the block. + * @param alpha The alpha value for transparency. + */ @Override - public void render(CustomTileEntity tileEntity, double posX, double posY, double posZ, float partialTicks, int destroyStage, float alpha) { + public void render(T tileEntity, double posX, double posY, double posZ, + float partialTicks, int destroyStage, float alpha) { GL11.glPushMatrix(); - this.bindTexture(textureResource); + bindTexture(textureResource); + setupRenderingTransformations(tileEntity, posX, posY, posZ); + + // Call the positioning consumer to apply additional transformations if necessary + positioning.accept(tileEntity); + + // Render the model + model.render(null, 0f, 0f, 0f, 0f, 0f, MODEL_RENDER_SCALE); + + GL11.glPopMatrix(); + } - // GL11.glEnable(GL12.GL_RESCALE_NORMAL); + /** + * Sets up the rendering transformations based on tile entity's position and orientation. + * + * @param tileEntity The tile entity being rendered. + * @param posX The x position for rendering. + * @param posY The y position for rendering. + * @param posZ The z position for rendering. + */ + private void setupRenderingTransformations(T tileEntity, double posX, double posY, double posZ) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glTranslatef((float) posX, (float) posY + 1.0F, (float) posZ + 1.0F); - GL11.glScalef(1.0F, -1.0F, -1.0F); + GL11.glTranslatef((float) posX, (float) posY + TRANSLATE_Y, (float) posZ + TRANSLATE_Y); + GL11.glScalef(SCALE_FACTOR, -SCALE_FACTOR, -SCALE_FACTOR); GL11.glTranslatef(0.5F, 0.5F, 0.5F); - GL11.glRotatef(90f * tileEntity.getSide(), 0, 1f, 0); - GL11.glRotatef(-90f, 0, 1f, 0); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + // Rotate based on the side of the tile entity + GL11.glRotatef(ROTATION_ANGLE * tileEntity.getSide(), 0, 1f, 0); + GL11.glRotatef(-ROTATION_ANGLE, 0, 1f, 0); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glTranslatef(0F, -0.5F, 0F); - - //System.out.println("Rendering side " + ((CustomTileEntity) tileEntity).getSide()); -// GL11.glRotatef(-90f * ((CustomTileEntity) tileEntity).getSide(), 0, 1f, 0); - positioning.accept(tileEntity); - //GL11.glEnable(GL11.GL_CULL_FACE); - model.render(null, 0f, 0f, 0f, 0f, 0f, 0.0625f); - - // GL11.glDisable(GL12.GL_RESCALE_NORMAL); - GL11.glPopMatrix(); } } diff --git a/src/main/java/com/paneedah/weaponlib/tile/LootBoxTileEntity.java b/src/main/java/com/paneedah/weaponlib/tile/LootBoxTileEntity.java index 82638b81e..df5414488 100644 --- a/src/main/java/com/paneedah/weaponlib/tile/LootBoxTileEntity.java +++ b/src/main/java/com/paneedah/weaponlib/tile/LootBoxTileEntity.java @@ -14,6 +14,8 @@ import java.util.Set; +import static com.paneedah.mwc.ProjectConstants.LOGGER; + public class LootBoxTileEntity extends CustomTileEntity { private static final String TAG_TIME = "T"; @@ -35,7 +37,7 @@ public void dropContents(World world, BlockPos pos, EntityPlayer player) { lastEquipmentDispenseTimestamp = world.getWorldTime(); Equipment equipment = configuration.getEquipmentOptions().pick(EnumDifficulty.EASY); if (equipment != null && equipment.item != null) { - System.out.println("Dropping " + equipment.item.getTranslationKey()); + LOGGER.info("Dropping " + equipment.item.getTranslationKey()); player.playSound(configuration.getDispenseSound(), 0.15f, 1); ItemStack equipmentItemStack = ItemStack.EMPTY; if (equipment.item instanceof Weapon) { diff --git a/src/main/java/com/paneedah/weaponlib/vehicle/forjosh.java b/src/main/java/com/paneedah/weaponlib/vehicle/forjosh.java deleted file mode 100644 index 78cd8fdeb..000000000 --- a/src/main/java/com/paneedah/weaponlib/vehicle/forjosh.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.paneedah.weaponlib.vehicle; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fml.relauncher.ReflectionHelper; -import net.minecraftforge.items.ItemStackHandler; - -import java.lang.reflect.Method; - -public class forjosh { - - public static ItemStackHandler getVMWSlots(EntityPlayer player) { - Method m = null; - try { - m = ReflectionHelper.findMethod(Class.forName("com.paneedah.mwc.capabilities.EquipmentCapability"), "getInventory", null, EntityLivingBase.class); - } catch (Exception e) { - return null; - } - Object inventory = null; - try { - inventory = m.invoke(null, player); - } catch (Exception e) { - return null; - } - ItemStack[] backpack = null; - if (inventory != null) { - try { - backpack = (ItemStack[]) ReflectionHelper.findField(Class.forName("com.paneedah.mwc.equipment.inventory.EquipmentInventory"), "inventory").get(inventory); - } catch (Exception e) { - return null; - } - } - ItemStackHandler handler = new ItemStackHandler(2); - handler.setStackInSlot(0, backpack[0]); - handler.setStackInSlot(1, backpack[1]); - return handler; - } - - public static byte[] getBytes(ItemStackHandler handler) { - ItemStack one = handler.getStackInSlot(0); - ItemStack two = handler.getStackInSlot(1); - - NBTTagCompound comp = new NBTTagCompound(); - comp.setTag("firstItem", one.getTagCompound()); - comp.setTag("secondItem", two.getTagCompound()); - - return comp.toString().getBytes(); - } - - -} diff --git a/src/main/java/com/paneedah/weaponlib/vehicle/jimphysics/Transmission.java b/src/main/java/com/paneedah/weaponlib/vehicle/jimphysics/Transmission.java index d61415126..c1a967acf 100644 --- a/src/main/java/com/paneedah/weaponlib/vehicle/jimphysics/Transmission.java +++ b/src/main/java/com/paneedah/weaponlib/vehicle/jimphysics/Transmission.java @@ -27,8 +27,8 @@ public class Transmission { public int upshiftRPM = 0; public int downshiftRPM = 0; - public int eUShift = 0; - public int eDShift = 0; + public int eUShift = 2500; + public int eDShift = 1200; /** * Transmission Alterable Settings