Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bunch of cleanup, new EquipmentFactory, all the vehicles now use Ve… #513

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/com/paneedah/mwc/equipment/Armors.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraftforge.common.util.EnumHelper;

public class Armors {
public class Armors implements EquipmentFactory {

// realistic armors
public static Item JPNVG18helmet;
Expand Down Expand Up @@ -65,7 +65,8 @@ 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) {
@Override
public void createEquipment(ModContext modContext) {
Builder marineArmorBuilder = new CustomArmor.Builder()
.withMaterial(Armors.Marine)
.withUnlocalizedName("Marine")
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/paneedah/mwc/equipment/Backpacks.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
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;

public class Backpacks {
public class Backpacks implements EquipmentFactory {

public static Item combatSustainmentBackpackTan;
public static Item combatSustainmentBackpackBlack;
Expand All @@ -22,7 +23,8 @@ public class Backpacks {

public static Item duffleBag;

public static void init() {
@Override
public void createEquipment(ModContext modContext) {

combatSustainmentBackpackTan = new ItemBackpack.Builder()
.withName("combat_sustainment_backpack_tan")
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/paneedah/mwc/equipment/Belts.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.paneedah.mwc.equipment;

import com.paneedah.weaponlib.ModContext;
import net.minecraft.item.Item;

public class Belts {
public class Belts implements EquipmentFactory {

public static Item magazineBelt;

public static void init() {

@Override
public void createEquipment(ModContext modContext) {
// TODO: Finish implementing belts
// magazineBelt = new ItemBelt.Builder()
// .withName("magazine_belt")
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/paneedah/mwc/equipment/Electronics.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -11,15 +12,16 @@
import com.paneedah.weaponlib.perspective.GasDetectorScreenPerspective;
import org.lwjgl.opengl.GL11;

public class Electronics {
public class Electronics implements EquipmentFactory {

public static ItemAttachment<Object> Tablet;

public static void init() {
@Override
public 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)
Expand Down Expand Up @@ -77,7 +79,7 @@ public static void init() {
.withName("tablet")

.withTextureName("Dummy.png")
.build(MWC.modContext);
.build(modContext);

new ItemWirelessCamera.Builder()

Expand Down Expand Up @@ -135,14 +137,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)
Expand Down Expand Up @@ -205,6 +207,6 @@ public static void init() {
.withName("gas-detector")

.withTextureName("Dummy.png")
.build(MWC.modContext);
.build(modContext);
}
}
10 changes: 10 additions & 0 deletions src/main/java/com/paneedah/mwc/equipment/EquipmentFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.paneedah.mwc.equipment;

import com.paneedah.weaponlib.ModContext;

public interface EquipmentFactory {

void createEquipment(ModContext modContext);

}

24 changes: 13 additions & 11 deletions src/main/java/com/paneedah/mwc/equipment/Vests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

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 class Vests implements EquipmentFactory {

public static void init(Object mod) {
@Override
public void createEquipment(ModContext modContext) {

new ItemVest.Builder()
.withName("m43a_chest_harness")
Expand All @@ -27,7 +29,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")
Expand Down Expand Up @@ -67,7 +69,7 @@ public static void init(Object mod) {
.withScale(3, 3, 3)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("molle_green")
Expand All @@ -87,7 +89,7 @@ public static void init(Object mod) {
.withScale(3, 3, 3)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("molle_urban")
Expand All @@ -107,7 +109,7 @@ public static void init(Object mod) {
.withScale(3, 3, 3)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("swat_vest")
Expand All @@ -127,7 +129,7 @@ public static void init(Object mod) {
.withScale(3, 3, 3)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("usMC_vest")
Expand All @@ -152,7 +154,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")
Expand All @@ -178,7 +180,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")
Expand All @@ -204,7 +206,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")
Expand All @@ -230,6 +232,6 @@ public static void init(Object mod) {
.withScale(2.6, 2.6, 2.6)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);
}
}
12 changes: 7 additions & 5 deletions src/main/java/com/paneedah/mwc/proxies/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ 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);

new Backpacks().createEquipment(MWC.modContext);
new Belts().createEquipment(MWC.modContext);
new Vests().createEquipment(MWC.modContext);
new 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();
new Electronics().createEquipment(MWC.modContext);
Grenades.init(mod, this);
CustomSpawnEggs.init(mod, this);
TileEntities.init(this);
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/paneedah/mwc/vehicle/AE86TruenoFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@

public class AE86TruenoFactory implements VehicleFactory {


@Override
public void createVehicle(ModContext modContext) {


StatefulRenderer<VehicleRenderableState> renderer = null;

if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
Expand Down Expand Up @@ -234,7 +232,7 @@
new EntityVehicleConfiguration.Builder()

.withName("ae86trueno")
.withEntityIdSupplier(() -> 10204)

Check warning on line 235 in src/main/java/com/paneedah/mwc/vehicle/AE86TruenoFactory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `10204`

.withPhysicsConfig(new PhysicsConfiguration(
/* WHEELBASE (m)*/ 2.4003,
Expand Down Expand Up @@ -282,7 +280,7 @@
.withOBBDimensions(3.3, 2.5, 1.75)
.withSeat(new Vec3d(-0.89, -0.2, 0.0))
.withRenderer(renderer)
.build(MWC.modContext);
.build(modContext);
}

}
6 changes: 2 additions & 4 deletions src/main/java/com/paneedah/mwc/vehicle/ATVFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@

public class ATVFactory implements VehicleFactory {


@Override
public void createVehicle(ModContext modContext) {


StatefulRenderer<VehicleRenderableState> renderer = null;

if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
Expand Down Expand Up @@ -215,7 +213,7 @@
new EntityVehicleConfiguration.Builder()

.withName("atv_polaris_sportsman_850_2019")
.withEntityIdSupplier(() -> 10205)

Check warning on line 216 in src/main/java/com/paneedah/mwc/vehicle/ATVFactory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `10205`

.withPhysicsConfig(new PhysicsConfiguration(
/* WHEELBASE (m)*/ 1.2827,
Expand Down Expand Up @@ -263,7 +261,7 @@
.withOBBDimensions(1, 1, 1)
.withSeat(new Vec3d(-0.5, 0.2, -0.3))
.withRenderer(renderer)
.build(MWC.modContext);
.build(modContext);
}

}
3 changes: 2 additions & 1 deletion src/main/java/com/paneedah/mwc/vehicle/AudiS4Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

public class AudiS4Factory implements VehicleFactory {

@Override
public void createVehicle(ModContext modContext) {
StatefulRenderer<VehicleRenderableState> renderer = null;

Expand Down Expand Up @@ -197,7 +198,7 @@

new EntityVehicleConfiguration.Builder()
.withName("audis4")
.withEntityIdSupplier(() -> 10202)

Check warning on line 201 in src/main/java/com/paneedah/mwc/vehicle/AudiS4Factory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `10202`
.withPhysicsConfig(new PhysicsConfiguration(
/* WHEELBASE (m)*/ 2.8194,
/* FRONT AREA (m^2) */ 2.2,
Expand Down Expand Up @@ -241,7 +242,7 @@
.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);
}

}
3 changes: 2 additions & 1 deletion src/main/java/com/paneedah/mwc/vehicle/JLTVM1280Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

public class JLTVM1280Factory implements VehicleFactory {

@Override
public void createVehicle(ModContext modContext) {
StatefulRenderer<VehicleRenderableState> renderer = new VehicleRendererBuilder()

Expand Down Expand Up @@ -193,7 +194,7 @@

new EntityVehicleConfiguration.Builder()
.withName("jltv_m1280")
.withEntityIdSupplier(() -> 10203)

Check warning on line 197 in src/main/java/com/paneedah/mwc/vehicle/JLTVM1280Factory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `10203`
.withEnterSound("vehicle-enter")
.withExitSound("vehicle-exit")
.withRunSound("vehicle-driving")
Expand All @@ -204,7 +205,7 @@
// .withAccelerationIncrement(0.015)
// .withForwardDeccelerationFactor(0.97)
.withRenderer(renderer)
.build(MWC.modContext);
.build(modContext);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

public class McLarenSennaFactory implements VehicleFactory {

@Override
public void createVehicle(ModContext modContext) {
StatefulRenderer<VehicleRenderableState> renderer = null;

Expand Down Expand Up @@ -192,7 +193,7 @@

new EntityVehicleConfiguration.Builder()
.withName("MClaren_senna")
.withEntityIdSupplier(() -> 10203)

Check warning on line 196 in src/main/java/com/paneedah/mwc/vehicle/McLarenSennaFactory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `10203`
.withPhysicsConfig(new PhysicsConfiguration(
/* WHEELBASE (m)*/ 2.67,
/* FRONT AREA (m^2) */ 2,
Expand Down Expand Up @@ -235,7 +236,7 @@
.withOBBDimensions(3.5, 2.5, 1.75)
.withSeat(new Vec3d(-0.15, -0.4, 0.5))
.withRenderer(renderer)
.build(MWC.modContext);
.build(modContext);
}

}
13 changes: 4 additions & 9 deletions src/main/java/com/paneedah/mwc/vehicle/PartInit.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

public class SampleVehicleFactory implements VehicleFactory {

@Override
public void createVehicle(ModContext modContext) {

StatefulRenderer<VehicleRenderableState> renderer = new VehicleRendererBuilder()
Expand Down Expand Up @@ -197,7 +198,7 @@

new EntityVehicleConfiguration.Builder()
.withName("vehicle")
.withEntityIdSupplier(() -> 10201)

Check warning on line 201 in src/main/java/com/paneedah/mwc/vehicle/SampleVehicleFactory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `10201`
.withEnterSound("vehicle-enter")
.withExitSound("vehicle-exit")
.withRunSound("vehicle-driving")
Expand All @@ -208,7 +209,7 @@
// .withAccelerationIncrement(0.015)
// .withForwardDeccelerationFactor(0.97)
.withRenderer(renderer)
.build(MWC.modContext);
.build(modContext);
}

}
Loading
Loading