mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Basis of casing system
All untested and should be considered still in-development. Just commiting for backup.
This commit is contained in:
parent
e75e328653
commit
51e392011e
@ -72,7 +72,6 @@ public class WeaponRecipes {
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_quadro, 1), new Object[] { "SSS", "SSS", "CM ", 'S', ModItems.hull_small_steel, 'C', ModItems.circuit_targeting_tier3, 'M', ModItems.mechanism_launcher_2 });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_hk69, 1), new Object[] { "SSI", " MB", 'S', ModItems.hull_small_steel, 'I', FE.ingot(), 'M', ModItems.mechanism_launcher_1, 'B', ModItems.bolt_tungsten });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_stinger, 1), new Object[] { "SSW", "CMW", 'S', STEEL.plate(), 'W', TI.plate(), 'C', ModItems.circuit_red_copper, 'M', ModItems.mechanism_launcher_2 });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.ammo_stinger_rocket, 4), new Object[] { "SS ", "STI", " IR", 'S', STEEL.plate(), 'T', Item.getItemFromBlock(Blocks.tnt), 'I', AL.plate(), 'R', REDSTONE.dust() });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_revolver, 1), new Object[] { "SSM", " RW", 'S', STEEL.plate(), 'W', KEY_PLANKS, 'R', ModItems.wire_aluminium, 'M', ModItems.mechanism_revolver_1 });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_revolver_saturnite, 1), new Object[] { "SSM", " RW", 'S', BIGMT.plate(), 'W', KEY_PLANKS, 'R', ModItems.wire_tungsten, 'M', ModItems.mechanism_revolver_2 });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.gun_revolver_iron, 1), new Object[] { "SSM", " RW", 'S', FE.plate(), 'W', KEY_PLANKS, 'R', ModItems.wire_aluminium, 'M', ModItems.mechanism_revolver_1 });
|
||||
@ -215,8 +214,8 @@ public class WeaponRecipes {
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.ammo_folly_du, 1), new Object[] { " B ", "EEE", " S ", 'B', ModItems.folly_bullet_du, 'E', ModBlocks.det_charge, 'S', ModItems.folly_shell });
|
||||
|
||||
//Rockets
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.ammo_rocket, 1), new Object[] { " T ", "GCG", " P ", 'T', Blocks.tnt, 'G', ModItems.rocket_fuel, 'C', ModItems.casing_50, 'P', ModItems.primer_50 });// I got tired of changing *all* of them, the stock one is always the first one anyway
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.ammo_rocket, 2), new Object[] { " T ", "GCG", " P ", 'T', ANY_PLASTICEXPLOSIVE.ingot(), 'G', ModItems.rocket_fuel, 'C', ModItems.casing_50, 'P', ModItems.primer_50 });
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.ammo_rocket, 1), new Object[] { " T ", "GCG", " P ", 'T', ModItems.ball_dynamite, 'G', ModItems.rocket_fuel, 'C', ModItems.hull_small_aluminium, 'P', ModItems.primer_50 });// I got tired of changing *all* of them, the stock one is always the first one anyway
|
||||
CraftingManager.addRecipeAuto(new ItemStack(ModItems.ammo_rocket, 2), new Object[] { " T ", "GCG", " P ", 'T', ANY_PLASTICEXPLOSIVE.ingot(), 'G', ModItems.rocket_fuel, 'C', ModItems.hull_small_aluminium, 'P', ModItems.primer_50 });
|
||||
CraftingManager.addRecipeAuto(ModItems.ammo_rocket.stackFromEnum(AmmoRocket.HE), new Object[] { "G", "R", 'G', ANY_PLASTICEXPLOSIVE.ingot(), 'R', ModItems.ammo_rocket });
|
||||
CraftingManager.addRecipeAuto(ModItems.ammo_rocket.stackFromEnum(AmmoRocket.INCENDIARY), new Object[] { "G", "R", 'G', P_RED.dust(), 'R', ModItems.ammo_rocket });
|
||||
CraftingManager.addRecipeAuto(ModItems.ammo_rocket.stackFromEnum(AmmoRocket.PHOSPHORUS), new Object[] { "G", "R", 'G', P_WHITE.ingot(), 'R', ModItems.ammo_rocket });
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package com.hbm.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.hbm.lib.HbmCollection.EnumGunManufacturer;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.particle.SpentCasingConfig;
|
||||
import com.hbm.render.anim.BusAnimation;
|
||||
import com.hbm.render.anim.HbmAnimations.AnimType;
|
||||
import com.hbm.render.util.RenderScreenOverlay.Crosshair;
|
||||
@ -32,7 +35,7 @@ public class GunConfiguration implements Cloneable {
|
||||
public int durability;
|
||||
|
||||
//animations!
|
||||
public HashMap<AnimType, BusAnimation> animations = new HashMap<AnimType, BusAnimation>();
|
||||
public final Map<AnimType, BusAnimation> animations = new EnumMap<>(AnimType.class);
|
||||
//whether ot not to disable crosshais when sneaking
|
||||
public boolean hasSights;
|
||||
|
||||
@ -89,6 +92,9 @@ public class GunConfiguration implements Cloneable {
|
||||
|
||||
//crosshair
|
||||
public Crosshair crosshair;
|
||||
|
||||
/**Controller for spent casings. If {@code Optional.empty()} it will not eject casings.**/
|
||||
public Optional<SpentCasingConfig> casingConfig = Optional.empty();
|
||||
|
||||
public static final int MODE_NORMAL = 0;
|
||||
public static final int MODE_RELEASE = 1;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.hbm.handler.guncfg;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.hbm.entity.projectile.EntityBulletBase;
|
||||
import com.hbm.handler.BulletConfigSyncingUtil;
|
||||
@ -133,7 +132,7 @@ public class Gun556mmFactory {
|
||||
|
||||
public static GunConfiguration getMLRConfig()
|
||||
{
|
||||
GunConfiguration config = new GunConfiguration();
|
||||
final GunConfiguration config = new GunConfiguration();
|
||||
|
||||
config.rateOfFire = 2;
|
||||
config.roundsPerCycle = 1;
|
||||
@ -156,7 +155,6 @@ public class Gun556mmFactory {
|
||||
config.config.addAll(HbmCollection.NATO);
|
||||
config.config.addAll(HbmCollection.NATOFlechette);
|
||||
|
||||
config.animations = new HashMap<>();
|
||||
config.animations.put(AnimType.CYCLE, new BusAnimation()
|
||||
.addBus("RECOIL", new BusAnimationSequence()
|
||||
.addKeyframe(new BusAnimationKeyframe(-0.35, 0, 0, 30))
|
||||
@ -167,7 +165,7 @@ public class Gun556mmFactory {
|
||||
|
||||
public static GunConfiguration getG36Config()
|
||||
{
|
||||
GunConfiguration config = new GunConfiguration();
|
||||
final GunConfiguration config = new GunConfiguration();
|
||||
|
||||
config.rateOfFire = 3;
|
||||
config.roundsPerCycle = 1;
|
||||
@ -188,7 +186,6 @@ public class Gun556mmFactory {
|
||||
|
||||
config.config.addAll(HbmCollection.NATO);
|
||||
|
||||
config.animations = new HashMap<>();
|
||||
config.animations.put(AnimType.CYCLE, new BusAnimation()
|
||||
.addBus("RECOIL", new BusAnimationSequence()
|
||||
.addKeyframe(new BusAnimationKeyframe(-0.35, 0, 0, 30))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ServerProxy {
|
||||
public abstract class ServerProxy {
|
||||
|
||||
//sort by estimated time of display. longer lasting ones should be sorted at the top.
|
||||
public static final int ID_DUCK = 0;
|
||||
@ -28,50 +28,46 @@ public class ServerProxy {
|
||||
public static final int ID_GUN_MODE = 8;
|
||||
public static final int ID_GAS_HAZARD = 9;
|
||||
|
||||
public void registerRenderInfo() { }
|
||||
public void registerTileEntitySpecialRenderer() { }
|
||||
public void registerItemRenderer() { }
|
||||
public void registerEntityRenderer() { }
|
||||
public void registerBlockRenderer() { }
|
||||
public abstract void registerRenderInfo();
|
||||
public abstract void registerTileEntitySpecialRenderer();
|
||||
public abstract void registerItemRenderer();
|
||||
public abstract void registerEntityRenderer();
|
||||
public abstract void registerBlockRenderer();
|
||||
|
||||
public void particleControl(double x, double y, double z, int type) { }
|
||||
public abstract void particleControl(double x, double y, double z, int type);
|
||||
|
||||
public void spawnParticle(double x, double y, double z, String type, float[] args) { }
|
||||
public abstract void spawnParticle(double x, double y, double z, String type, float... args);
|
||||
|
||||
public void effectNT(NBTTagCompound data) { }
|
||||
public abstract void effectNT(NBTTagCompound data);
|
||||
|
||||
public void registerMissileItems() { }
|
||||
public abstract void registerMissileItems();
|
||||
|
||||
public AudioWrapper getLoopedSound(String sound, float x, float y, float z, float volume, float pitch) { return null; }
|
||||
public AudioWrapper getLoopedSoundStartStop(World world, String sound, String start, String stop, float x, float y, float z, float volume, float pitch) { return null; }
|
||||
public abstract AudioWrapper getLoopedSound(String sound, float x, float y, float z, float volume, float pitch);
|
||||
public abstract AudioWrapper getLoopedSoundStartStop(World world, String sound, String start, String stop, float x, float y, float z, float volume, float pitch);
|
||||
|
||||
public void playSound(String sound, Object data) { }
|
||||
public abstract void playSound(String sound, Object data);
|
||||
|
||||
public void displayTooltip(String msg, int id) {
|
||||
displayTooltip(msg, 1000, id);
|
||||
}
|
||||
public void displayTooltip(String msg, int time, int id) { }
|
||||
public abstract void displayTooltip(String msg, int time, int id);
|
||||
|
||||
public boolean getIsKeyPressed(EnumKeybind key) {
|
||||
return false;
|
||||
}
|
||||
public EntityPlayer me() {
|
||||
return null;
|
||||
}
|
||||
public abstract boolean getIsKeyPressed(EnumKeybind key);
|
||||
public abstract EntityPlayer me();
|
||||
|
||||
public boolean isVanished(Entity e) {
|
||||
return false;
|
||||
}
|
||||
public abstract boolean isVanished(Entity e);
|
||||
|
||||
public void openLink(String url) { }
|
||||
public abstract void openLink(String url);
|
||||
|
||||
@SuppressWarnings({ "unused", "static-method" })
|
||||
public SoundWrapper getTileSound(String sound, ISoundSourceTE source) {
|
||||
return new SoundWrapper();
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
public List<ItemStack> getSubItems(ItemStack stack) {
|
||||
|
||||
List<ItemStack> list = new ArrayList();
|
||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
||||
list.add(stack);
|
||||
return list;
|
||||
}
|
||||
|
||||
97
src/main/java/com/hbm/particle/ParticleSpentCasing.java
Normal file
97
src/main/java/com/hbm/particle/ParticleSpentCasing.java
Normal file
@ -0,0 +1,97 @@
|
||||
package com.hbm.particle;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.particle.SpentCasingConfig.CasingType;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ParticleSpentCasing extends EntityFX
|
||||
{
|
||||
private static final ResourceLocation TEXTURE_BRASS = new ResourceLocation(RefStrings.MODID, "textures/particle/casing_brass.png"),
|
||||
TEXTURE_SHOTGUN = new ResourceLocation(RefStrings.MODID, "textures/particle/casing_shotgun.png"),
|
||||
TEXTURE_AR2 = new ResourceLocation(RefStrings.MODID, "textures/particle/casing_ar2.png");
|
||||
|
||||
private final TextureManager textureManager;
|
||||
|
||||
private final float momentumPitch, momentumYaw;
|
||||
private final CasingType casingType;
|
||||
public ParticleSpentCasing(TextureManager textureManager, World world, double x, double y, double z, double mx, double my, double mz, CasingType casingType, float momentumPitch, float momentumYaw)
|
||||
{
|
||||
super(world, x, y, z, mx, my, mz);
|
||||
particleMaxAge = 120;
|
||||
this.textureManager = textureManager;
|
||||
this.casingType = casingType;
|
||||
this.momentumPitch = momentumPitch;
|
||||
this.momentumYaw = momentumYaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
super.onUpdate();
|
||||
|
||||
prevRotationPitch = rotationPitch;
|
||||
prevRotationYaw = rotationYaw;
|
||||
|
||||
if (!onGround)
|
||||
{
|
||||
rotationPitch += momentumPitch;
|
||||
rotationYaw += momentumYaw;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(
|
||||
Tessellator tessellator, float interp, float x, float y, float z,
|
||||
float tx, float tz
|
||||
)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
super.renderParticle(tessellator, interp, x, y, z, tx, tz);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
final ResourceLocation texture;
|
||||
switch (casingType)
|
||||
{
|
||||
case AR2: texture = TEXTURE_AR2; break;
|
||||
case BRASS: texture = TEXTURE_BRASS; break;
|
||||
case SHOTGUN: texture = TEXTURE_SHOTGUN; break;
|
||||
default: throw new IllegalStateException("CasingType [" + casingType + "] is not recognized, cannot render spent casing!");
|
||||
}
|
||||
textureManager.bindTexture(texture);
|
||||
|
||||
final float scale = particleScale * 0.1f,
|
||||
xInterp = (float) (prevPosX + (posX - prevPosX) * interp - interpPosX),
|
||||
yInterp = (float) (prevPosY + (posY - prevPosY) * interp - interpPosY),
|
||||
zInterp = (float) (prevPosZ + (posZ - prevPosZ) * interp - interpPosZ);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setNormal(0, 1, 0);
|
||||
tessellator.setBrightness(240);
|
||||
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
||||
tessellator.addVertexWithUV(xInterp - x * scale - tx * scale, yInterp - y, zInterp - z * scale - tz * scale, 0, 0);
|
||||
tessellator.addVertexWithUV(xInterp - x * scale + tx * scale, yInterp + y, zInterp - z * scale + tz * scale, 0, 1);
|
||||
tessellator.addVertexWithUV(xInterp + x * scale + tx * scale, yInterp + y, zInterp + z * scale + tz * scale, 1, 1);
|
||||
tessellator.addVertexWithUV(xInterp + x * scale - tx * scale, yInterp - y, zInterp + z * scale - tz * scale, 1, 0);
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
200
src/main/java/com/hbm/particle/SpentCasingConfig.java
Normal file
200
src/main/java/com/hbm/particle/SpentCasingConfig.java
Normal file
@ -0,0 +1,200 @@
|
||||
package com.hbm.particle;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SpentCasingConfig implements Cloneable
|
||||
{
|
||||
|
||||
public enum CasingType
|
||||
{
|
||||
/**The typical ejected type. Most pistols, rifles, and even cannons will likely use it.**/
|
||||
BRASS,
|
||||
/**Shotgun shells.**/
|
||||
SHOTGUN,
|
||||
/**AR2 pulse rifle plugs.**/
|
||||
AR2;
|
||||
}
|
||||
|
||||
/**Change position of the ejecting shell.**/
|
||||
private final double offsetX, offsetY, offsetZ;
|
||||
/**Set initial motion after ejecting.**/
|
||||
private final double motionX, motionY, motionZ;
|
||||
/**Rescale the sprite to match the approximate scale of the rounds.**/
|
||||
private final float stretchX, stretchY;
|
||||
/**Multipliers for random pitch and yaw.**/
|
||||
private final float pitchFactor, yawFactor;
|
||||
/**Overrides for the sprite colors.**/
|
||||
private final int redOverride, greenOverride, blueOverride;
|
||||
/**Whether or not to override the default sprite color scheme.**/
|
||||
private final boolean overrideColor;
|
||||
/**The type of casing.**/
|
||||
private final CasingType casingType;
|
||||
/**Amount of casings to spawn per event. Default 1.**/
|
||||
private final int casingAmount;
|
||||
/**If the casing(s) should be spawned after reloading, instead of after firing.**/
|
||||
private final boolean afterReload;
|
||||
public SpentCasingConfig(
|
||||
double offsetX, double offsetY, double offsetZ, double motionX, double motionY, double motionZ,
|
||||
float stretchX, float stretchY, float pitchFactor, float yawFactor, int redOverride, int greenOverride,
|
||||
int blueOverride, boolean overrideColor, CasingType casingType, int casingAmount, boolean afterReload
|
||||
)
|
||||
{
|
||||
this.offsetX = offsetX;
|
||||
this.offsetY = offsetY;
|
||||
this.offsetZ = offsetZ;
|
||||
this.motionX = motionX;
|
||||
this.motionY = motionY;
|
||||
this.motionZ = motionZ;
|
||||
this.stretchX = stretchX;
|
||||
this.stretchY = stretchY;
|
||||
this.pitchFactor = pitchFactor;
|
||||
this.yawFactor = yawFactor;
|
||||
this.redOverride = redOverride;
|
||||
this.greenOverride = greenOverride;
|
||||
this.blueOverride = blueOverride;
|
||||
this.overrideColor = overrideColor;
|
||||
this.casingType = casingType;
|
||||
this.casingAmount = casingAmount;
|
||||
this.afterReload = afterReload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply these settings to an initialized casing entity
|
||||
* @param entity The entity to apply the settings defined by this object
|
||||
*/
|
||||
public void applyToEntity(ParticleSpentCasing entity)
|
||||
{
|
||||
entity.setPosition((entity.posX - Math.cos(entity.rotationYaw / 180 * Math.PI)) + offsetX,
|
||||
(entity.posY - 0.1) + offsetY,
|
||||
(entity.posZ - Math.sin(entity.rotationYaw / 180 * Math.PI) + offsetZ));
|
||||
|
||||
entity.setRBGColorF((float) redOverride / 255, (float) greenOverride / 255, (float) blueOverride / 255);
|
||||
}
|
||||
|
||||
public double getOffsetX()
|
||||
{
|
||||
return offsetX;
|
||||
}
|
||||
public double getOffsetY()
|
||||
{
|
||||
return offsetY;
|
||||
}
|
||||
public double getOffsetZ()
|
||||
{
|
||||
return offsetZ;
|
||||
}
|
||||
public double getMotionX()
|
||||
{
|
||||
return motionX;
|
||||
}
|
||||
public double getMotionY()
|
||||
{
|
||||
return motionY;
|
||||
}
|
||||
public double getMotionZ()
|
||||
{
|
||||
return motionZ;
|
||||
}
|
||||
public float getStretchX()
|
||||
{
|
||||
return stretchX;
|
||||
}
|
||||
public float getStretchY()
|
||||
{
|
||||
return stretchY;
|
||||
}
|
||||
public float getPitchFactor()
|
||||
{
|
||||
return pitchFactor;
|
||||
}
|
||||
public float getYawFactor()
|
||||
{
|
||||
return yawFactor;
|
||||
}
|
||||
public int getRedOverride()
|
||||
{
|
||||
return redOverride;
|
||||
}
|
||||
public int getGreenOverride()
|
||||
{
|
||||
return greenOverride;
|
||||
}
|
||||
public int getBlueOverride()
|
||||
{
|
||||
return blueOverride;
|
||||
}
|
||||
public boolean isOverrideColor()
|
||||
{
|
||||
return overrideColor;
|
||||
}
|
||||
public CasingType getCasingType()
|
||||
{
|
||||
return casingType;
|
||||
}
|
||||
public int getCasingAmount()
|
||||
{
|
||||
return casingAmount;
|
||||
}
|
||||
public boolean isAfterReload()
|
||||
{
|
||||
return afterReload;
|
||||
}
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(afterReload, blueOverride, casingAmount, casingType, greenOverride, motionX, motionY, motionZ,
|
||||
offsetX, offsetY, offsetZ, overrideColor, pitchFactor, redOverride, stretchX, stretchY, yawFactor);
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(obj instanceof SpentCasingConfig))
|
||||
return false;
|
||||
final SpentCasingConfig other = (SpentCasingConfig) obj;
|
||||
return afterReload == other.afterReload && blueOverride == other.blueOverride
|
||||
&& casingAmount == other.casingAmount && casingType == other.casingType
|
||||
&& greenOverride == other.greenOverride
|
||||
&& Double.doubleToLongBits(motionX) == Double.doubleToLongBits(other.motionX)
|
||||
&& Double.doubleToLongBits(motionY) == Double.doubleToLongBits(other.motionY)
|
||||
&& Double.doubleToLongBits(motionZ) == Double.doubleToLongBits(other.motionZ)
|
||||
&& Double.doubleToLongBits(offsetX) == Double.doubleToLongBits(other.offsetX)
|
||||
&& Double.doubleToLongBits(offsetY) == Double.doubleToLongBits(other.offsetY)
|
||||
&& Double.doubleToLongBits(offsetZ) == Double.doubleToLongBits(other.offsetZ)
|
||||
&& overrideColor == other.overrideColor
|
||||
&& Float.floatToIntBits(pitchFactor) == Float.floatToIntBits(other.pitchFactor)
|
||||
&& redOverride == other.redOverride
|
||||
&& Float.floatToIntBits(stretchX) == Float.floatToIntBits(other.stretchX)
|
||||
&& Float.floatToIntBits(stretchY) == Float.floatToIntBits(other.stretchY)
|
||||
&& Float.floatToIntBits(yawFactor) == Float.floatToIntBits(other.yawFactor);
|
||||
}
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("SpentCasingConfig [offsetX=").append(offsetX).append(", offsetY=").append(offsetY)
|
||||
.append(", offsetZ=").append(offsetZ).append(", motionX=").append(motionX).append(", motionY=")
|
||||
.append(motionY).append(", motionZ=").append(motionZ).append(", stretchX=").append(stretchX)
|
||||
.append(", stretchY=").append(stretchY).append(", pitchFactor=").append(pitchFactor)
|
||||
.append(", yawFactor=").append(yawFactor).append(", redOverride=").append(redOverride)
|
||||
.append(", greenOverride=").append(greenOverride).append(", blueOverride=").append(blueOverride)
|
||||
.append(", overrideColor=").append(overrideColor).append(", casingType=").append(casingType)
|
||||
.append(", casingAmount=").append(casingAmount).append(", afterReload=").append(afterReload)
|
||||
.append(']');
|
||||
return builder.toString();
|
||||
}
|
||||
@Override
|
||||
public SpentCasingConfig clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (SpentCasingConfig) super.clone();
|
||||
} catch (CloneNotSupportedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return new SpentCasingConfig(offsetX, offsetY, offsetZ, motionX, motionY, motionZ, stretchX, stretchY, pitchFactor, yawFactor, redOverride, greenOverride, blueOverride, overrideColor, casingType, casingAmount, afterReload);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
293
src/main/java/com/hbm/particle/SpentCasingConfigBuilder.java
Normal file
293
src/main/java/com/hbm/particle/SpentCasingConfigBuilder.java
Normal file
@ -0,0 +1,293 @@
|
||||
package com.hbm.particle;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.hbm.particle.SpentCasingConfig.CasingType;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class SpentCasingConfigBuilder implements Cloneable
|
||||
{
|
||||
/**Change position of the ejecting shell.**/
|
||||
private double offsetX, offsetY, offsetZ;
|
||||
/**Set initial motion after ejecting.**/
|
||||
private double motionX, motionY, motionZ;
|
||||
/**Rescale the sprite to match the approximate scale of the rounds.**/
|
||||
private float stretchX, stretchY;
|
||||
/**Multipliers for random pitch and yaw.**/
|
||||
private float pitchFactor = 1, yawFactor = 1;
|
||||
/**Overrides for the sprite colors.**/
|
||||
private int redOverride, greenOverride, blueOverride;
|
||||
/**Whether or not to override the default sprite color scheme.**/
|
||||
private boolean overrideColor;
|
||||
/**The type of casing.**/
|
||||
private CasingType casingType;
|
||||
/**Amount of casings to spawn per event. Default 1.**/
|
||||
private int casingAmount = 1;
|
||||
/**If the casing(s) should be spawned after reloading, instead of after firing.**/
|
||||
private boolean afterReload;
|
||||
public SpentCasingConfigBuilder(CasingType casingType, boolean overrideColor)
|
||||
{
|
||||
this.casingType = casingType;
|
||||
this.overrideColor = overrideColor;
|
||||
}
|
||||
|
||||
public double getOffsetX()
|
||||
{
|
||||
return offsetX;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setOffsetX(double offsetX)
|
||||
{
|
||||
this.offsetX = offsetX;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getOffsetY()
|
||||
{
|
||||
return offsetY;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setOffsetY(double offsetY)
|
||||
{
|
||||
this.offsetY = offsetY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getOffsetZ()
|
||||
{
|
||||
return offsetZ;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setOffsetZ(double offsetZ)
|
||||
{
|
||||
this.offsetZ = offsetZ;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getMotionX()
|
||||
{
|
||||
return motionX;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setMotionX(double motionX)
|
||||
{
|
||||
this.motionX = motionX;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getMotionY()
|
||||
{
|
||||
return motionY;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setMotionY(double motionY)
|
||||
{
|
||||
this.motionY = motionY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getMotionZ()
|
||||
{
|
||||
return motionZ;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setMotionZ(double motionZ)
|
||||
{
|
||||
this.motionZ = motionZ;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getStretchX()
|
||||
{
|
||||
return stretchX;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setStretchX(float stretchX)
|
||||
{
|
||||
this.stretchX = stretchX;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getStretchY()
|
||||
{
|
||||
return stretchY;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setStretchY(float stretchY)
|
||||
{
|
||||
this.stretchY = stretchY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getPitchFactor()
|
||||
{
|
||||
return pitchFactor;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setPitchFactor(float pitchFactor)
|
||||
{
|
||||
this.pitchFactor = pitchFactor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getYawFactor()
|
||||
{
|
||||
return yawFactor;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setYawFactor(float yawFactor)
|
||||
{
|
||||
this.yawFactor = yawFactor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getRedOverride()
|
||||
{
|
||||
return redOverride;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setRedOverride(int redOverride)
|
||||
{
|
||||
this.redOverride = MathHelper.clamp_int(redOverride, 0, 255);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getGreenOverride()
|
||||
{
|
||||
return greenOverride;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setGreenOverride(int greenOverride)
|
||||
{
|
||||
this.greenOverride = MathHelper.clamp_int(greenOverride, 0, 255);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getBlueOverride()
|
||||
{
|
||||
return blueOverride;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setBlueOverride(int blueOverride)
|
||||
{
|
||||
this.blueOverride = MathHelper.clamp_int(blueOverride, 0, 255);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isOverrideColor()
|
||||
{
|
||||
return overrideColor;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setOverrideColor(boolean overrideColor)
|
||||
{
|
||||
this.overrideColor = overrideColor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CasingType getCasingType()
|
||||
{
|
||||
return casingType;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setCasingType(CasingType casingType)
|
||||
{
|
||||
this.casingType = casingType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getCasingAmount()
|
||||
{
|
||||
return casingAmount;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setCasingAmount(int casingAmount)
|
||||
{
|
||||
this.casingAmount = casingAmount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAfterReload()
|
||||
{
|
||||
return afterReload;
|
||||
}
|
||||
|
||||
public SpentCasingConfigBuilder setAfterReload(boolean afterReload)
|
||||
{
|
||||
this.afterReload = afterReload;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpentCasingConfig build()
|
||||
{
|
||||
return new SpentCasingConfig(offsetX, offsetY, offsetZ, motionX, motionY, motionZ, stretchX, stretchY, pitchFactor, yawFactor, redOverride, greenOverride, blueOverride, overrideColor, casingType, casingAmount, afterReload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash(afterReload, blueOverride, casingAmount, casingType, greenOverride, motionX, motionY,
|
||||
motionZ, offsetX, offsetY, offsetZ, overrideColor, pitchFactor, redOverride, stretchX, stretchY,
|
||||
yawFactor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(obj instanceof SpentCasingConfigBuilder))
|
||||
return false;
|
||||
final SpentCasingConfigBuilder other = (SpentCasingConfigBuilder) obj;
|
||||
return afterReload == other.afterReload && blueOverride == other.blueOverride
|
||||
&& casingAmount == other.casingAmount && casingType == other.casingType
|
||||
&& greenOverride == other.greenOverride
|
||||
&& Double.doubleToLongBits(motionX) == Double.doubleToLongBits(other.motionX)
|
||||
&& Double.doubleToLongBits(motionY) == Double.doubleToLongBits(other.motionY)
|
||||
&& Double.doubleToLongBits(motionZ) == Double.doubleToLongBits(other.motionZ)
|
||||
&& Double.doubleToLongBits(offsetX) == Double.doubleToLongBits(other.offsetX)
|
||||
&& Double.doubleToLongBits(offsetY) == Double.doubleToLongBits(other.offsetY)
|
||||
&& Double.doubleToLongBits(offsetZ) == Double.doubleToLongBits(other.offsetZ)
|
||||
&& overrideColor == other.overrideColor
|
||||
&& Float.floatToIntBits(pitchFactor) == Float.floatToIntBits(other.pitchFactor)
|
||||
&& redOverride == other.redOverride
|
||||
&& Float.floatToIntBits(stretchX) == Float.floatToIntBits(other.stretchX)
|
||||
&& Float.floatToIntBits(stretchY) == Float.floatToIntBits(other.stretchY)
|
||||
&& Float.floatToIntBits(yawFactor) == Float.floatToIntBits(other.yawFactor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("SpentCasingConfigBuilder [offsetX=").append(offsetX).append(", offsetY=").append(offsetY)
|
||||
.append(", offsetZ=").append(offsetZ).append(", motionX=").append(motionX).append(", motionY=")
|
||||
.append(motionY).append(", motionZ=").append(motionZ).append(", stretchX=").append(stretchX)
|
||||
.append(", stretchY=").append(stretchY).append(", pitchFactor=").append(pitchFactor)
|
||||
.append(", yawFactor=").append(yawFactor).append(", redOverride=").append(redOverride)
|
||||
.append(", greenOverride=").append(greenOverride).append(", blueOverride=").append(blueOverride)
|
||||
.append(", overrideColor=").append(overrideColor).append(", casingType=").append(casingType)
|
||||
.append(", casingAmount=").append(casingAmount).append(", afterReload=").append(afterReload)
|
||||
.append(']');
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpentCasingConfigBuilder clone()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (SpentCasingConfigBuilder) super.clone();
|
||||
} catch (CloneNotSupportedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return new SpentCasingConfigBuilder(casingType, overrideColor).setBlueOverride(blueOverride)
|
||||
.setCasingAmount(casingAmount).setGreenOverride(greenOverride).setMotionX(motionX)
|
||||
.setMotionY(motionY).setMotionZ(motionZ).setOffsetX(offsetX).setOffsetY(offsetY)
|
||||
.setOffsetZ(offsetZ).setPitchFactor(pitchFactor).setRedOverride(redOverride)
|
||||
.setStretchX(stretchX).setStretchY(stretchY).setYawFactor(yawFactor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
BIN
src/main/resources/assets/hbm/textures/particle/casing_brass.png
Normal file
BIN
src/main/resources/assets/hbm/textures/particle/casing_brass.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 633 B |
Binary file not shown.
|
After Width: | Height: | Size: 628 B |
BIN
src/main/resources/assets/hbm/textures/particle/casings.png
Normal file
BIN
src/main/resources/assets/hbm/textures/particle/casings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 773 B |
Loading…
x
Reference in New Issue
Block a user