- 1,057
- 50
- 234
Добрый день.
Сделал вот такую хрень:
Вроде все прекрасно, но никак не могу отрисовать партиклы.
P.s сильно за код не ругать. Знаю что быдлокод сплошь.
Дергал код из IC2 Ex
Сделал вот такую хрень:
Вроде все прекрасно, но никак не могу отрисовать партиклы.
Код:
package blessentumble.planets.SolarSystem.mercury.armor;
import java.util.Random;
import micdoodle8.mods.galacticraft.api.vector.Vector3;
import micdoodle8.mods.galacticraft.core.GalacticraftCore;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import blessentumble.BlesseAddon;
import blessentumble.CreativeTabsBlesse;
import blessentumble.core.items.ItemElectricArmor;
import blessentumble.core.items.ItemsAddon;
import blessentumble.planets.SolarSystem.kuiperbelt.models.ModelJetPack;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class JetPack extends ItemElectricArmor
{
public float transferMax;
private World world;
private Random rand;
private Entity entity;
private static boolean lastJetpackUsed = false;
public static Minecraft mc = FMLClientHandler.instance().getClient();
public JetPack(int armorIndex)
{
super(ItemsAddon.ARMOR_LEAD, BlesseAddon.proxy.getLeadArmorRenderIndex(), armorIndex);
this.setUnlocalizedName("JetPack");
//this.setTextureName(BlesseAddon.ASSET_PREFIX + ":" + "jetpack");
}
@Override
public CreativeTabs getCreativeTab()
{
return CreativeTabsBlesse.BlesseArmorTab;
}
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
{
if (this.getArmorMaterial() == ItemsAddon.ARMOR_LEAD)
{
return BlesseAddon.ASSET_PREFIX + ":" + "textures/model/armor/jetpack.png";
}
return null;
}
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
{
if(this == ItemsAddon.JetPack)
{
ModelBiped model = new ModelJetPack();
return model;
}
return null;
}
@Override
public float getMaxElectricityStored(ItemStack theItem) {
return 100000;
}
public void use(ItemStack itemStack, double amount) {
this.drainfromJetpack(itemStack, (int)amount);
this.discharge(itemStack, 5, true);
this.makeFlame(0, 0, 0);
}
private void makeFlame(double x, double y, double z)
{
BlesseAddon.proxy.spawnParticle(world, "largeflame", (double)x + 0.5D, (double)y + 1.0D, (double)z + 0.5D, 0.0D, 0.0D, 0.0D);
BlesseAddon.proxy.spawnParticle(world, "largeflame", (double)x - 0.5D, (double)y + 1.0D, (double)z + 0.5D, 0.05D, 0.5D, 0.0D);
BlesseAddon.proxy.spawnParticle(world, "largeflame", (double)x + 0.5D, (double)y + 1.0D, (double)z - 0.5D, 0.0D, 0.5D, 0.05D);
BlesseAddon.proxy.spawnParticle(world, "largeflame", (double)x + 1.5D, (double)y + 1.0D, (double)z + 0.5D, -0.05D, 0.5D, 0.0D);
BlesseAddon.proxy.spawnParticle(world, "largeflame", (double)x + 0.5D, (double)y + 1.0D, (double)z + 1.5D, 0.0D, 0.5D, -0.05D);
BlesseAddon.proxy.spawnParticle(world, "largewater", (double)x + 0.5D, (double)y + 1.0D, (double)z + 0.5D, 0.0D, 0.5D, 0.0D);
}
public boolean useJetpack(EntityPlayer player) {
ItemStack jetpack = player.inventory.armorInventory[2];
if(this.getElectricityStored(jetpack) <= 0.0D) {
return false;
} else {
boolean electric = jetpack.getItem() != ItemsAddon.JetPack;
float power = 1.0F;
float dropPercentage = 0.2F;
if(electric) {
power = 0.7F;
dropPercentage = 0.05F;
}
if(this.getElectricityStored(jetpack) / this.getMaxCharge(jetpack) <= (double)dropPercentage) {
power = (float)((double)power * (this.getElectricityStored(jetpack) / (this.getMaxCharge(jetpack) * (double)dropPercentage)));
}
if(mc.gameSettings.keyBindForward.getIsKeyPressed() && mc.currentScreen == null) {
float worldHeight = 0.15F;
if(electric) {
worldHeight += 0.15F;
}
float maxFlightHeight = power * worldHeight * 2.0F;
if(maxFlightHeight > 0.0F) {
player.moveFlying(0.0F, 0.4F * maxFlightHeight, 0.02F);
}
}
int worldHeight1 = BlesseAddon.proxy.getWorldHeight(player.worldObj);
int maxFlightHeight1 = electric?(int)((float)worldHeight1 / 1.28F):worldHeight1;
double y = player.posY;
if(y > (double)(maxFlightHeight1 - 25)) {
if(y > (double)maxFlightHeight1) {
y = (double)maxFlightHeight1;
}
power = (float)((double)power * (((double)maxFlightHeight1 - y) / 25.0D));
}
double prevmotion = player.motionY;
player.motionY = Math.min(player.motionY + (double)(power * 0.2F), 0.6000000238418579D);
if(electric) {
float consume = 0.0F;
if(mc.gameSettings.keyBindJump.getIsKeyPressed() && mc.currentScreen == null) {
if(electric) {
consume = 0.1F;
} else {
consume = 0.2F;
}
}
if(mc.gameSettings.keyBindSneak.getIsKeyPressed() && mc.currentScreen == null) {
if(electric) {
consume = -0.1F;
} else {
consume = -0.2F;
}
}
if(player.motionY > (double)consume) {
player.motionY = (double)consume;
if(prevmotion > player.motionY) {
player.motionY = prevmotion;
}
}
}
int consume1 = 2;
if(electric) {
consume1 += 6;
}
this.use(jetpack, (double)consume1);
player.fallDistance = 0.0F;
player.distanceWalkedModified = 0.0F;
BlesseAddon.proxy.resetPlayerInAirTime(player);
return true;
}
}
public boolean drainfromJetpack(ItemStack pack, int amount) {
if(this.isElectricItemEmpty(pack)) {
return false;
}
return true;
}
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
if(player.inventory.armorInventory[2] == itemStack) {
byte toggleTimer = 0;
boolean jetpackUsed = false;
int x = 0,y = 0,z = 0;
if(mc.gameSettings.keyBindJump.getIsKeyPressed() && mc.currentScreen == null) {
jetpackUsed = this.useJetpack(player);
}
if(jetpackUsed) {
player.inventoryContainer.detectAndSendChanges();
}
}
}
public static double map(double value, double srcMax, double dstMax) {
if(value < 0.0D || Double.isNaN(value)) {
value = 0.0D;
}
if(value > srcMax) {
value = srcMax;
}
return value / srcMax * dstMax;
}
}
P.s сильно за код не ругать. Знаю что быдлокод сплошь.
Дергал код из IC2 Ex