mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
it's recoil!
This commit is contained in:
parent
56da81a7ae
commit
f7e804094c
@ -412,7 +412,6 @@ public class ModBlocks {
|
||||
public static Block steel_scaffold;
|
||||
public static Block steel_grate;
|
||||
public static Block steel_grate_wide;
|
||||
public static Block scaffold_dynamic;
|
||||
|
||||
public static Block deco_pipe;
|
||||
public static Block deco_pipe_rusted;
|
||||
@ -1586,7 +1585,6 @@ public class ModBlocks {
|
||||
steel_scaffold = new BlockScaffold().setBlockName("steel_scaffold").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(15.0F).setBlockTextureName(RefStrings.MODID + ":deco_steel_orig");
|
||||
steel_grate = new BlockGrate(Material.iron).setBlockName("steel_grate").setStepSound(ModSoundTypes.grate).setCreativeTab(MainRegistry.blockTab).setHardness(2.0F).setResistance(5.0F);
|
||||
steel_grate_wide = new BlockGrate(Material.iron).setBlockName("steel_grate_wide").setStepSound(ModSoundTypes.grate).setCreativeTab(MainRegistry.blockTab).setHardness(2.0F).setResistance(5.0F);
|
||||
scaffold_dynamic = new BlockScaffoldDynamic().setBlockName("scaffold_dynamic").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(15.0F).setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
|
||||
deco_pipe = new BlockPipe(Material.iron, RefStrings.MODID + ":pipe_side", 0).setBlockName("deco_pipe").setStepSound(ModSoundTypes.grate).setCreativeTab(MainRegistry.blockTab).setHardness(2.0F).setResistance(5.0F).setBlockTextureName(RefStrings.MODID + ":pipe_top");
|
||||
deco_pipe_rusted = new BlockPipe(Material.iron, RefStrings.MODID + ":pipe_side_rusty", 0).setBlockName("deco_pipe_rusted").setStepSound(ModSoundTypes.grate).setCreativeTab(MainRegistry.blockTab).setHardness(2.0F).setResistance(5.0F).setBlockTextureName(RefStrings.MODID + ":pipe_top_rusty");
|
||||
|
||||
@ -1,270 +0,0 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import static com.hbm.blocks.generic.BlockScaffoldDynamic.TileEntityScaffoldDynamic.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.tool.ItemBlowtorch;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
public class BlockScaffoldDynamic extends BlockContainer implements IToolable, ILookOverlay {
|
||||
|
||||
@SideOnly(Side.CLIENT) public IIcon iconPoleTop;
|
||||
@SideOnly(Side.CLIENT) public IIcon iconPoleSide;
|
||||
@SideOnly(Side.CLIENT) public IIcon iconGrateTop;
|
||||
@SideOnly(Side.CLIENT) public IIcon iconGrateSide;
|
||||
@SideOnly(Side.CLIENT) public IIcon iconBarTop;
|
||||
@SideOnly(Side.CLIENT) public IIcon iconBarSide;
|
||||
|
||||
public static int renderMode;
|
||||
|
||||
public BlockScaffoldDynamic() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
public static int renderIDScaffold = RenderingRegistry.getNextAvailableRenderId();
|
||||
@Override public int getRenderType(){ return renderIDScaffold; }
|
||||
@Override public boolean isOpaqueCube() { return false; }
|
||||
@Override public boolean renderAsNormalBlock() { return false; }
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityScaffoldDynamic();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
if(renderMode == 0) return side == 0 || side == 1 ? iconPoleTop : iconPoleSide;
|
||||
if(renderMode == 1) return side == 0 || side == 1 ? iconGrateTop : iconGrateSide;
|
||||
if(renderMode == 2) return side == 0 || side == 1 ? iconBarTop : iconBarSide;
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
super.registerBlockIcons(reg);
|
||||
this.iconPoleTop = reg.registerIcon(RefStrings.MODID + ":scaffold_pole_top");
|
||||
this.iconPoleSide = reg.registerIcon(RefStrings.MODID + ":scaffold_pole_side");
|
||||
this.iconGrateTop = reg.registerIcon(RefStrings.MODID + ":scaffold_grate_top");
|
||||
this.iconGrateSide = reg.registerIcon(RefStrings.MODID + ":scaffold_grate_side");
|
||||
this.iconBarTop = reg.registerIcon(RefStrings.MODID + ":scaffold_bar_top");
|
||||
this.iconBarSide = reg.registerIcon(RefStrings.MODID + ":scaffold_bar_side");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) {
|
||||
|
||||
TileEntityScaffoldDynamic tile = (TileEntityScaffoldDynamic) world.getTileEntity(x, y, z);
|
||||
if(tool == ToolType.SCREWDRIVER) {
|
||||
tile.locked = !tile.locked;
|
||||
tile.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(tool != ToolType.TORCH) return false;
|
||||
|
||||
|
||||
int part = getPartFromCoord(fX, fY, fZ);
|
||||
|
||||
if(part != 0 && tile.canToggle(part)) {
|
||||
tile.toggle(part);
|
||||
tile.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getPartFromCoord(float fX, float fY, float fZ) {
|
||||
if(fX < 0.25 && fZ < 0.25) return POLE_NX_NZ;
|
||||
if(fX > 0.75 && fZ < 0.25) return POLE_PX_NZ;
|
||||
if(fX > 0.75 && fZ > 0.75) return POLE_PX_PZ;
|
||||
if(fX < 0.25 && fZ > 0.75) return POLE_NX_PZ;
|
||||
|
||||
if(fY == 0 && fX < 0.25) return BAR_LOWER_NEG_X;
|
||||
if(fY == 0 && fX > 0.75) return BAR_LOWER_POS_X;
|
||||
if(fY == 0 && fZ < 0.25) return BAR_LOWER_NEG_Z;
|
||||
if(fY == 0 && fZ > 0.75) return BAR_LOWER_POS_Z;
|
||||
if(fY == 1 && fX < 0.25) return BAR_UPPER_NEG_X;
|
||||
if(fY == 1 && fX > 0.75) return BAR_UPPER_POS_X;
|
||||
if(fY == 1 && fZ < 0.25) return BAR_UPPER_NEG_Z;
|
||||
if(fY == 1 && fZ > 0.75) return BAR_UPPER_POS_Z;
|
||||
|
||||
if(fY < 0.125) return GRATE_LOWER;
|
||||
if(fY > 0.875) return GRATE_UPPER;
|
||||
|
||||
if(fX == 0 && fY < 0.5) return BAR_LOWER_NEG_X;
|
||||
if(fX == 1 && fY < 0.5) return BAR_LOWER_POS_X;
|
||||
if(fZ == 0 && fY < 0.5) return BAR_LOWER_NEG_Z;
|
||||
if(fZ == 1 && fY < 0.5) return BAR_LOWER_POS_Z;
|
||||
if(fX == 0 && fY > 0.5) return BAR_UPPER_NEG_X;
|
||||
if(fX == 1 && fY > 0.5) return BAR_UPPER_POS_X;
|
||||
if(fZ == 0 && fY > 0.5) return BAR_UPPER_NEG_Z;
|
||||
if(fZ == 1 && fY > 0.5) return BAR_UPPER_POS_Z;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//ttoo lazy to make an itemblock just to provide this in the one method that needs it
|
||||
public static float lastFX;
|
||||
public static float lastFY;
|
||||
public static float lastFZ;
|
||||
|
||||
@Override
|
||||
public int onBlockPlaced(World world, int x, int y, int z, int side, float fX, float fY, float fZ, int meta) {
|
||||
lastFX = fX;
|
||||
lastFY = fY;
|
||||
lastFZ = fZ;
|
||||
|
||||
if(side == Library.POS_X.ordinal()) lastFX = 0;
|
||||
if(side == Library.NEG_X.ordinal()) lastFX = 1;
|
||||
if(side == Library.POS_Z.ordinal()) lastFZ = 0;
|
||||
if(side == Library.NEG_Z.ordinal()) lastFZ = 1;
|
||||
|
||||
return side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
TileEntityScaffoldDynamic tile = (TileEntityScaffoldDynamic) world.getTileEntity(x, y, z);
|
||||
|
||||
// DEFAUL: POLES
|
||||
if(stack.getItemDamage() == 0) {
|
||||
if(lastFX < 0.5 && lastFZ < 0.5) tile.toggle(tile.POLE_NX_NZ);
|
||||
if(lastFX >= 0.5 && lastFZ < 0.5) tile.toggle(tile.POLE_PX_NZ);
|
||||
if(lastFX < 0.5 && lastFZ >= 0.5) tile.toggle(tile.POLE_NX_PZ);
|
||||
if(lastFX >= 0.5 && lastFZ >= 0.5) tile.toggle(tile.POLE_PX_PZ);
|
||||
}
|
||||
}
|
||||
|
||||
// Full class name needed because otherwise there's some conflict with the static import * from this class
|
||||
public static class TileEntityScaffoldDynamic extends net.minecraft.tileentity.TileEntity {
|
||||
|
||||
public int composite;
|
||||
public int prevComposite;
|
||||
public boolean locked;
|
||||
public static final int BAR_LOWER_POS_X = (1 << 0);
|
||||
public static final int BAR_LOWER_NEG_X = (1 << 1);
|
||||
public static final int BAR_LOWER_POS_Z = (1 << 2);
|
||||
public static final int BAR_LOWER_NEG_Z = (1 << 3);
|
||||
public static final int BAR_UPPER_POS_X = (1 << 4);
|
||||
public static final int BAR_UPPER_NEG_X = (1 << 5);
|
||||
public static final int BAR_UPPER_POS_Z = (1 << 6);
|
||||
public static final int BAR_UPPER_NEG_Z = (1 << 7);
|
||||
public static final int POLE_PX_PZ = (1 << 8);
|
||||
public static final int POLE_PX_NZ = (1 << 9);
|
||||
public static final int POLE_NX_PZ = (1 << 10);
|
||||
public static final int POLE_NX_NZ = (1 << 11);
|
||||
public static final int GRATE_LOWER = (1 << 12);
|
||||
public static final int GRATE_UPPER = (1 << 13);
|
||||
|
||||
public boolean canToggle(int part) { return !locked && (composite ^ part) != 0; }
|
||||
public void toggle(int part) { this.composite ^= part; System.out.println("" + this.composite); }
|
||||
public boolean has(int part) { return (this.composite & part) != 0; }
|
||||
|
||||
@Override
|
||||
public void updateEntity() { }
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
this.writeToNBT(nbt);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
this.readFromNBT(pkt.func_148857_g());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
this.composite = nbt.getInteger("c");
|
||||
this.prevComposite = nbt.getInteger("p");
|
||||
this.locked = nbt.getBoolean("l");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("c", composite);
|
||||
nbt.setInteger("p", prevComposite);
|
||||
nbt.setBoolean("l", locked);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
ItemStack held = player.getHeldItem();
|
||||
|
||||
boolean holdsBlowtorch = held != null && held.getItem() instanceof ItemBlowtorch;
|
||||
boolean holdScrewdriver = held != null && (held.getItem() == ModItems.screwdriver || held.getItem() == ModItems.screwdriver_desh);
|
||||
|
||||
MovingObjectPosition mop = mc.objectMouseOver;
|
||||
|
||||
if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK) {
|
||||
float fX = (float) (mop.hitVec.xCoord - x);
|
||||
float fY = (float) (mop.hitVec.yCoord - y);
|
||||
float fZ = (float) (mop.hitVec.zCoord - z);
|
||||
|
||||
TileEntityScaffoldDynamic tile = (TileEntityScaffoldDynamic) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null && tile.locked && (holdsBlowtorch || holdScrewdriver)) {
|
||||
List<String> text = new ArrayList();
|
||||
text.add(EnumChatFormatting.RED + "Locked!");
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(this.getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
return;
|
||||
}
|
||||
|
||||
if(holdsBlowtorch) {
|
||||
String name = null;
|
||||
int part = getPartFromCoord(fX, fY, fZ);
|
||||
if(part <= (1 << 3)) name = "Lower Vertical Bar";
|
||||
else if(part <= (1 << 7)) name = "Upper Vertical Bar";
|
||||
else if(part <= (1 << 10)) name = "Pole";
|
||||
else if(part <= (1 << 13)) name = "Grate";
|
||||
|
||||
if(name != null) {
|
||||
List<String> text = new ArrayList();
|
||||
text.add("Toggle:");
|
||||
text.add(name);
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(this.getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,6 +42,11 @@ public class ItemGunBaseNT extends Item implements IKeybindReceiver, IEquipRecei
|
||||
public double shotRand = 0D;
|
||||
public List<SmokeNode> smokeNodes = new ArrayList();
|
||||
|
||||
public static float recoilVertical = 0;
|
||||
public static float recoilHorizontal = 0;
|
||||
public static float offsetVertical = 0;
|
||||
public static float offsetHorizontal = 0;
|
||||
|
||||
public static final String O_GUNCONFIG = "O_GUNCONFIG";
|
||||
|
||||
public static final String KEY_DRAWN = "drawn";
|
||||
|
||||
@ -32,6 +32,7 @@ public class Receiver {
|
||||
public static final String O_MAGAZINE = "O_MAGAZINE";
|
||||
public static final String FUN_CANFIRE = "FUN_CANFIRE";
|
||||
public static final String CON_ONFIRE = "CON_ONFIRE";
|
||||
public static final String CON_ONRECOIL = "CON_ONRECOIL";
|
||||
|
||||
public Receiver(int index) {
|
||||
this.index = index;
|
||||
@ -53,6 +54,7 @@ public class Receiver {
|
||||
protected IMagazine magazine_DNA;
|
||||
protected BiFunction<ItemStack, LambdaContext, Boolean> canFire_DNA;
|
||||
protected BiConsumer<ItemStack, LambdaContext> onFire_DNA;
|
||||
protected BiConsumer<ItemStack, LambdaContext> onRecoil_DNA;
|
||||
|
||||
/* GETTERS */
|
||||
public float getBaseDamage(ItemStack stack) { return WeaponUpgradeManager.eval(this.baseDamage_DNA, stack, F_BASEDAMAGE, this); }
|
||||
@ -71,6 +73,7 @@ public class Receiver {
|
||||
|
||||
public BiFunction<ItemStack, LambdaContext, Boolean> getCanFire(ItemStack stack) { return WeaponUpgradeManager.eval(this.canFire_DNA, stack, FUN_CANFIRE, this); }
|
||||
public BiConsumer<ItemStack, LambdaContext> getOnFire(ItemStack stack) { return WeaponUpgradeManager.eval(this.onFire_DNA, stack, CON_ONFIRE, this); }
|
||||
public BiConsumer<ItemStack, LambdaContext> getRecoil(ItemStack stack) { return WeaponUpgradeManager.eval(this.onRecoil_DNA, stack, CON_ONRECOIL, this); }
|
||||
|
||||
/* SETTERS */
|
||||
public Receiver dmg(float dmg) { this.baseDamage_DNA = dmg; return this; }
|
||||
@ -86,6 +89,7 @@ public class Receiver {
|
||||
|
||||
public Receiver canFire(BiFunction<ItemStack, LambdaContext, Boolean> lambda) { this.canFire_DNA = lambda; return this; }
|
||||
public Receiver fire(BiConsumer<ItemStack, LambdaContext> lambda) { this.onFire_DNA = lambda; return this; }
|
||||
public Receiver recoil(BiConsumer<ItemStack, LambdaContext> lambda) { this.onRecoil_DNA = lambda; return this; }
|
||||
|
||||
public Receiver sound(String sound, float volume, float pitch) {
|
||||
this.fireSound_DNA = sound;
|
||||
|
||||
@ -86,6 +86,12 @@ public class Lego {
|
||||
}
|
||||
};
|
||||
|
||||
/** Toggles isAiming. Used by keybinds. */
|
||||
public static BiConsumer<ItemStack, LambdaContext> LAMBDA_STANDARD_RECOIL = (stack, ctx) -> {
|
||||
ItemGunBaseNT.recoilVertical += 10;
|
||||
ItemGunBaseNT.recoilHorizontal += ctx.player.getRNG().nextGaussian() * 1.5;
|
||||
};
|
||||
|
||||
/** Toggles isAiming. Used by keybinds. */
|
||||
public static BiConsumer<ItemStack, LambdaContext> LAMBDA_TOGGLE_AIM = (stack, ctx) -> { ItemGunBaseNT.setIsAiming(stack, !ItemGunBaseNT.getIsAiming(stack)); };
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ public class XFactoryBlackPowder {
|
||||
.rec(new Receiver(0)
|
||||
.dmg(5F).delay(27).reload(67).sound("hbm:weapon.fire.blackPowder", 1.0F, 1.0F)
|
||||
.mag(new MagazineFullReload(0, 6).addConfigs(stone, flint, iron, shot))
|
||||
.canFire(Lego.LAMBDA_STANDARD_CAN_FIRE).fire(Lego.LAMBDA_STANDARD_FIRE))
|
||||
.canFire(Lego.LAMBDA_STANDARD_CAN_FIRE).fire(Lego.LAMBDA_STANDARD_FIRE).recoil(Lego.LAMBDA_STANDARD_RECOIL))
|
||||
.pp(Lego.LAMBDA_STANDARD_CLICK_PRIMARY) .pr(Lego.LAMBDA_STANDARD_RELOAD) .pt(Lego.LAMBDA_TOGGLE_AIM)
|
||||
.decider(GunStateDecider.LAMBDA_STANDARD_DECIDER)
|
||||
.anim(LAMBDA_PEPPERBOX_ANIMS)
|
||||
|
||||
@ -32,7 +32,9 @@ public abstract class MagazineSingleTypeBase implements IMagazine<BulletConfig>
|
||||
public BulletConfig getType(ItemStack stack) {
|
||||
int type = getMagType(stack, index);
|
||||
if(type >= 0 && type < BulletConfig.configs.size()) {
|
||||
return BulletConfig.configs.get(type);
|
||||
BulletConfig cfg = BulletConfig.configs.get(type);
|
||||
if(acceptedBullets.contains(cfg)) return cfg;
|
||||
return acceptedBullets.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -840,7 +840,6 @@ public class ClientProxy extends ServerProxy {
|
||||
RenderingRegistry.registerBlockHandler(new RenderSteelBeam());
|
||||
RenderingRegistry.registerBlockHandler(new RenderSteelWall());
|
||||
RenderingRegistry.registerBlockHandler(new RenderSteelCorner());
|
||||
RenderingRegistry.registerBlockHandler(new RenderScaffoldDynamic());
|
||||
RenderingRegistry.registerBlockHandler(new RenderBarrel());
|
||||
RenderingRegistry.registerBlockHandler(new RenderFence());
|
||||
RenderingRegistry.registerBlockHandler(new RenderBarbedWire());
|
||||
|
||||
@ -149,11 +149,6 @@ public class ModEventHandlerClient {
|
||||
public static long flashTimestamp;
|
||||
public static final int shakeDuration = 1_500;
|
||||
public static long shakeTimestamp;
|
||||
|
||||
public static float recoilVertical = 0;
|
||||
public static float recoilHorizontal = 0;
|
||||
public static float offsetVertical = 0;
|
||||
public static float offsetHorizontal = 0;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onOverlayRender(RenderGameOverlayEvent.Pre event) {
|
||||
@ -1000,19 +995,20 @@ public class ModEventHandlerClient {
|
||||
|
||||
if(event.phase == Phase.END) {
|
||||
|
||||
this.offsetVertical += this.recoilVertical;
|
||||
this.offsetHorizontal += this.recoilHorizontal;
|
||||
player.rotationPitch += this.recoilVertical;
|
||||
player.rotationYaw += this.recoilHorizontal;
|
||||
ItemGunBaseNT.offsetVertical += ItemGunBaseNT.recoilVertical;
|
||||
ItemGunBaseNT.offsetHorizontal += ItemGunBaseNT.recoilHorizontal;
|
||||
player.rotationPitch -= ItemGunBaseNT.recoilVertical;
|
||||
player.rotationYaw -= ItemGunBaseNT.recoilHorizontal;
|
||||
|
||||
float decay = 0.75F;
|
||||
float rebound = 0.25F;
|
||||
ItemGunBaseNT.recoilVertical *= decay;
|
||||
ItemGunBaseNT.recoilHorizontal *= decay;
|
||||
float dV = ItemGunBaseNT.offsetVertical * rebound;
|
||||
float dH = ItemGunBaseNT.offsetHorizontal * rebound;
|
||||
|
||||
float decay = 0.8F;
|
||||
this.recoilVertical *= decay;
|
||||
this.offsetHorizontal *= decay;
|
||||
float dV = this.offsetVertical * 0.2F;
|
||||
float dH = this.offsetHorizontal * 0.2F;
|
||||
|
||||
this.offsetVertical -= dV;
|
||||
this.offsetHorizontal -= dH;
|
||||
ItemGunBaseNT.offsetVertical -= dV;
|
||||
ItemGunBaseNT.offsetHorizontal -= dH;
|
||||
player.rotationPitch += dV;
|
||||
player.rotationYaw += dH;
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
package com.hbm.packet.toclient;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import com.hbm.items.weapon.ItemGunBase;
|
||||
import com.hbm.items.weapon.sedna.GunConfig;
|
||||
import com.hbm.items.weapon.sedna.ItemGunBaseNT;
|
||||
import com.hbm.main.ModEventHandlerClient;
|
||||
import com.hbm.items.weapon.sedna.Receiver;
|
||||
import com.hbm.items.weapon.sedna.ItemGunBaseNT.LambdaContext;
|
||||
import com.hbm.render.anim.BusAnimation;
|
||||
import com.hbm.render.anim.HbmAnimations;
|
||||
import com.hbm.render.anim.HbmAnimations.AnimType;
|
||||
@ -23,22 +25,31 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class GunAnimationPacket implements IMessage {
|
||||
|
||||
int type;
|
||||
public short type;
|
||||
public int meta;
|
||||
|
||||
public GunAnimationPacket() { }
|
||||
|
||||
public GunAnimationPacket(int type) {
|
||||
this.type = type;
|
||||
this.type = (short) type;
|
||||
this.meta = 0;
|
||||
}
|
||||
|
||||
public GunAnimationPacket(int type, int meta) {
|
||||
this.type = (short) type;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
type = buf.readInt();
|
||||
type = buf.readShort();
|
||||
meta = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(type);
|
||||
buf.writeShort(type);
|
||||
buf.writeInt(meta);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<GunAnimationPacket, IMessage> {
|
||||
@ -57,7 +68,7 @@ public class GunAnimationPacket implements IMessage {
|
||||
return null;
|
||||
|
||||
if(stack.getItem() instanceof ItemGunBaseNT) {
|
||||
handleSedna(player, stack, slot, AnimType.values()[m.type]);
|
||||
handleSedna(player, stack, slot, AnimType.values()[m.type], m.meta);
|
||||
}
|
||||
|
||||
if(!(stack.getItem() instanceof ItemGunBase))
|
||||
@ -91,7 +102,7 @@ public class GunAnimationPacket implements IMessage {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void handleSedna(EntityPlayer player, ItemStack stack, int slot, AnimType type) {
|
||||
public static void handleSedna(EntityPlayer player, ItemStack stack, int slot, AnimType type, int meta) {
|
||||
ItemGunBaseNT gun = (ItemGunBaseNT) stack.getItem();
|
||||
GunConfig config = gun.getConfig(stack);
|
||||
|
||||
@ -99,8 +110,12 @@ public class GunAnimationPacket implements IMessage {
|
||||
gun.lastShot = System.currentTimeMillis();
|
||||
gun.shotRand = player.worldObj.rand.nextDouble();
|
||||
|
||||
ModEventHandlerClient.recoilVertical += 1;
|
||||
ModEventHandlerClient.recoilHorizontal += player.getRNG().nextGaussian();
|
||||
Receiver[] receivers = config.getReceivers(stack);
|
||||
if(meta >= 0 && meta < receivers.length) {
|
||||
Receiver rec = receivers[meta];
|
||||
BiConsumer<ItemStack, LambdaContext> onRecoil= rec.getRecoil(stack);
|
||||
if(onRecoil != null) onRecoil.accept(stack, new LambdaContext(config, player));
|
||||
}
|
||||
}
|
||||
|
||||
BiFunction<ItemStack, AnimType, BusAnimation> anims = config.getAnims(stack);
|
||||
|
||||
@ -1,111 +0,0 @@
|
||||
package com.hbm.render.block;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.generic.BlockScaffoldDynamic;
|
||||
import com.hbm.blocks.generic.BlockScaffoldDynamic.TileEntityScaffoldDynamic;
|
||||
import com.hbm.render.util.RenderBlocksNT;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class RenderScaffoldDynamic implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
|
||||
renderer.setRenderBounds(0D, 0D, 0.875D, 0.75D, 1D, 1D);
|
||||
tessellator.setNormal(0F, 1F, 0F); renderer.renderFaceYPos(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(0F, -1F, 0F); renderer.renderFaceYNeg(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(-1F, 0F, 0F); renderer.renderFaceXNeg(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(0F, 0F, 1F); renderer.renderFaceZPos(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(0F, 0F, -1F); renderer.renderFaceZNeg(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
|
||||
|
||||
renderer.setRenderBounds(0.75D, 0D, 0.75D, 1D, 1D, 1D);
|
||||
tessellator.setNormal(0F, 1F, 0F); renderer.renderFaceYPos(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(0F, -1F, 0F); renderer.renderFaceYNeg(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(1F, 0F, 0F); renderer.renderFaceXPos(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(-1F, 0F, 0F); renderer.renderFaceXNeg(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(0F, 0F, 1F); renderer.renderFaceZPos(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(0F, 0F, -1F); renderer.renderFaceZNeg(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
|
||||
renderer.setRenderBounds(0.875D, 0D, 0D, 1D, 1D, 0.75D);
|
||||
tessellator.setNormal(0F, 1F, 0F); renderer.renderFaceYPos(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(0F, -1F, 0F); renderer.renderFaceYNeg(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(1F, 0F, 0F); renderer.renderFaceXPos(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(-1F, 0F, 0F); renderer.renderFaceXNeg(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
tessellator.setNormal(0F, 0F, -1F); renderer.renderFaceZNeg(block, 0, 0, 0, block.getIcon(0, 0));
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||
|
||||
renderer = RenderBlocksNT.INSTANCE.setWorld(world);
|
||||
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(!(tile instanceof TileEntityScaffoldDynamic)) return false;
|
||||
TileEntityScaffoldDynamic scaffold = (TileEntityScaffoldDynamic) tile;
|
||||
|
||||
boolean lpx = scaffold.has(scaffold.BAR_LOWER_POS_X);
|
||||
boolean lnx = scaffold.has(scaffold.BAR_LOWER_NEG_X);
|
||||
boolean upx = scaffold.has(scaffold.BAR_UPPER_POS_X);
|
||||
boolean unx = scaffold.has(scaffold.BAR_UPPER_NEG_X);
|
||||
boolean lpz = scaffold.has(scaffold.BAR_LOWER_POS_Z);
|
||||
boolean lnz = scaffold.has(scaffold.BAR_LOWER_NEG_Z);
|
||||
boolean upz = scaffold.has(scaffold.BAR_UPPER_POS_Z);
|
||||
boolean unz = scaffold.has(scaffold.BAR_UPPER_NEG_Z);
|
||||
|
||||
boolean p_nx_nz = scaffold.has(scaffold.POLE_NX_NZ);
|
||||
boolean p_px_nz = scaffold.has(scaffold.POLE_PX_NZ);
|
||||
boolean p_px_pz = scaffold.has(scaffold.POLE_PX_PZ);
|
||||
boolean p_nx_pz = scaffold.has(scaffold.POLE_NX_PZ);
|
||||
|
||||
BlockScaffoldDynamic.renderMode = 0;
|
||||
if(p_nx_nz) { renderer.setRenderBounds(0D, 0D, 0D, 0.25D, 1D, 0.25D); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(p_px_nz) { renderer.setRenderBounds(0.75D, 0D, 0D, 1D, 1D, 0.25D); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(p_px_pz) { renderer.setRenderBounds(0.75D, 0D, 0.75D, 1D, 1D, 1D); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(p_nx_pz) { renderer.setRenderBounds(0D, 0D, 0.75D, 0.25D, 1D, 1D); renderer.renderStandardBlock(block, x, y, z); }
|
||||
|
||||
BlockScaffoldDynamic.renderMode = 1;
|
||||
if(scaffold.has(scaffold.GRATE_LOWER)) { renderer.setRenderBounds(0.000, 0.000, 0.000, 1.000, 0.125, 1.000); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(scaffold.has(scaffold.GRATE_UPPER)) { renderer.setRenderBounds(0.000, 0.875, 0.000, 1.000, 1.000, 1.000); renderer.renderStandardBlock(block, x, y, z); }
|
||||
|
||||
BlockScaffoldDynamic.renderMode = 2;
|
||||
|
||||
if(lpx) { renderer.setRenderBounds(0.75, 0.00, p_px_nz ? 0.25 : 0.00, 1.00, 0.25, p_px_pz ? 0.75 : 1.00); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(upx) { renderer.setRenderBounds(0.75, 0.75, p_px_nz ? 0.25 : 0.00, 1.00, 1.00, p_px_pz ? 0.75 : 1.00); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(lnx) { renderer.setRenderBounds(0.00, 0.00, p_nx_nz ? 0.25 : 0.00, 0.25, 0.25, p_nx_pz ? 0.75 : 1.00); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(unx) { renderer.setRenderBounds(0.00, 0.75, p_nx_nz ? 0.25 : 0.00, 0.25, 1.00, p_nx_pz ? 0.75 : 1.00); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(lpz) { renderer.setRenderBounds(p_nx_pz || lnx ? 0.25 : 0.00, 0.00, 0.75, p_px_pz || lpx ? 0.75 : 1.00, 0.25, 1.00); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(upz) { renderer.setRenderBounds(p_nx_pz || unx ? 0.25 : 0.00, 0.75, 0.75, p_px_pz || upx ? 0.75 : 1.00, 1.00, 1.00); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(lnz) { renderer.setRenderBounds(p_nx_nz || lnx ? 0.25 : 0.00, 0.00, 0.00, p_px_nz || lpx ? 0.75 : 1.00, 0.25, 0.25); renderer.renderStandardBlock(block, x, y, z); }
|
||||
if(unz) { renderer.setRenderBounds(p_nx_nz || unx ? 0.25 : 0.00, 0.75, 0.00, p_px_nz || upx ? 0.75 : 1.00, 1.00, 0.25); renderer.renderStandardBlock(block, x, y, z); }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return BlockScaffoldDynamic.renderIDScaffold;
|
||||
}
|
||||
}
|
||||
@ -14,7 +14,6 @@ import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
|
||||
import com.hbm.blocks.generic.BlockMotherOfAllOres.TileEntityRandomOre;
|
||||
import com.hbm.blocks.generic.BlockPedestal.TileEntityPedestal;
|
||||
import com.hbm.blocks.generic.BlockPlushie.TileEntityPlushie;
|
||||
import com.hbm.blocks.generic.BlockScaffoldDynamic.TileEntityScaffoldDynamic;
|
||||
import com.hbm.blocks.generic.BlockSnowglobe.TileEntitySnowglobe;
|
||||
import com.hbm.blocks.generic.PartEmitter.TileEntityPartEmitter;
|
||||
import com.hbm.blocks.machine.BlockICF.TileEntityBlockICF;
|
||||
@ -64,7 +63,6 @@ public class TileMappings {
|
||||
put(TileEntityDecoSteelPoles.class, "tileentity_steelpoles");
|
||||
put(TileEntityDecoPoleTop.class, "tileentity_poletop");
|
||||
put(TileEntityDecoPoleSatelliteReceiver.class, "tileentity_satellitereceicer");
|
||||
put(TileEntityScaffoldDynamic.class, "tileentity_scaffold_dynamic");
|
||||
put(TileEntityMachineBattery.class, "tileentity_battery");
|
||||
put(TileEntityCapacitor.class, "tileentity_capacitor");
|
||||
put(TileEntityMachineWoodBurner.class, "tileentity_wood_burner");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user