add rocket launcher + fixes

This commit is contained in:
Sen 2025-07-08 01:51:47 +02:00
parent 987c76d2c5
commit eca1f242c4
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
54 changed files with 452 additions and 478 deletions

View file

@ -518,7 +518,7 @@ public class BlockCauldron extends Block
}
else
{
playerIn.connection.sendContainerToPlayer(playerIn.inventoryContainer);
playerIn.connection.sendContainer(playerIn.inventoryContainer, playerIn.inventoryContainer.getInventory());
}
// playerIn.triggerAchievement(StatRegistry.cauldronUsedStat);

View file

@ -1,155 +0,0 @@
package common.entity.item;
import common.entity.Entity;
import common.entity.EntityType;
import common.init.SoundEvent;
import common.model.ParticleType;
import common.tags.TagObject;
import common.util.ExtMath;
import common.world.World;
public class EntityFireworks extends Entity
{
private int fireworkAge;
private int lifetime;
public EntityFireworks(World worldIn)
{
super(worldIn);
this.setSize(0.25F, 0.25F);
}
protected void entityInit()
{
}
public boolean isInRangeToRenderDist(double distance)
{
return distance < 4096.0D;
}
public EntityFireworks(World worldIn, double x, double y, double z)
{
super(worldIn);
this.fireworkAge = 0;
this.setSize(0.25F, 0.25F);
this.setPosition(x, y, z);
this.motionX = this.rand.gaussian() * 0.001D;
this.motionZ = this.rand.gaussian() * 0.001D;
this.motionY = 0.05D;
this.lifetime = 25 + this.rand.zrange(6) + this.rand.zrange(7);
}
public void setVelocity(double x, double y, double z)
{
this.motionX = x;
this.motionY = y;
this.motionZ = z;
if (this.prevPitch == 0.0F && this.prevYaw == 0.0F)
{
float f = ExtMath.sqrtd(x * x + z * z);
this.prevYaw = this.rotYaw = (float)(ExtMath.atan2(x, z) * 180.0D / Math.PI);
this.prevPitch = this.rotPitch = (float)(ExtMath.atan2(y, (double)f) * 180.0D / Math.PI);
}
}
public void onUpdate()
{
this.lastTickPosX = this.posX;
this.lastTickPosY = this.posY;
this.lastTickPosZ = this.posZ;
super.onUpdate();
this.motionX *= 1.15D;
this.motionZ *= 1.15D;
this.motionY += 0.04D;
this.moveEntity(this.motionX, this.motionY, this.motionZ);
float f = ExtMath.sqrtd(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotYaw = (float)(ExtMath.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for (this.rotPitch = (float)(ExtMath.atan2(this.motionY, (double)f) * 180.0D / Math.PI); this.rotPitch - this.prevPitch < -180.0F; this.prevPitch -= 360.0F)
{
;
}
while (this.rotPitch - this.prevPitch >= 180.0F)
{
this.prevPitch += 360.0F;
}
while (this.rotYaw - this.prevYaw < -180.0F)
{
this.prevYaw -= 360.0F;
}
while (this.rotYaw - this.prevYaw >= 180.0F)
{
this.prevYaw += 360.0F;
}
this.rotPitch = this.prevPitch + (this.rotPitch - this.prevPitch) * 0.2F;
this.rotYaw = this.prevYaw + (this.rotYaw - this.prevYaw) * 0.2F;
if (this.fireworkAge == 0)
{
this.worldObj.playSoundAtEntity(this, SoundEvent.LAUNCH, 3.0F);
}
++this.fireworkAge;
if (this.worldObj.client && this.fireworkAge % 2 < 2)
{
this.worldObj.spawnParticle(ParticleType.FIREWORKS_SPARK, this.posX, this.posY - 0.3D, this.posZ, this.rand.gaussian() * 0.05D, -this.motionY * 0.5D, this.rand.gaussian() * 0.05D);
}
if (!this.worldObj.client && this.fireworkAge > this.lifetime)
{
this.setDead();
this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 3.0f, false, false, false);
}
}
public void writeEntity(TagObject tagCompound)
{
tagCompound.setInt("Life", this.fireworkAge);
tagCompound.setInt("LifeTime", this.lifetime);
}
public void readEntity(TagObject tagCompund)
{
this.fireworkAge = tagCompund.getInt("Life");
this.lifetime = tagCompund.getInt("LifeTime");
}
public float getBrightness(float partialTicks)
{
return super.getBrightness(partialTicks);
}
public int getBrightnessForRender(float partialTicks)
{
return super.getBrightnessForRender(partialTicks);
}
public boolean canAttackWithItem()
{
return false;
}
public int getTrackingRange() {
return 64;
}
public int getUpdateFrequency() {
return 10;
}
public boolean isSendingVeloUpdates() {
return true;
}
public EntityType getType() {
return EntityType.EXPLOSIVE;
}
}

View file

@ -739,10 +739,9 @@ public abstract class EntityNPC extends EntityLiving
this.playSound(SoundEvent.THROW, 1.0F);
this.worldObj.spawnEntityInWorld(entityarrow);
}
else if(stack.getItem() instanceof ItemGunBase) {
EntityBullet bullet = new EntityBullet(this.worldObj, this, target, ((ItemGunBase)stack.getItem()).getVelocity(), 0.75f);
else if(stack.getItem() instanceof ItemGunBase gun) {
EntityBullet bullet = gun.createBulletFor(this.worldObj, this, target);
int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.POWER, this.getHeldItem());
// int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
bullet.setDamage(((ItemGunBase)stack.getItem()).getAmmo().getDamage(stack));
if (i > 0)
@ -750,17 +749,7 @@ public abstract class EntityNPC extends EntityLiving
bullet.setDamage(bullet.getDamage() + i);
}
// if (j > 0)
// {
// entityarrow.setKnockbackStrength(j);
// }
// if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0)
// {
// entityarrow.setFire(100);
// }
this.playSound(SoundEvent.EXPLODE_ALT, 1.0f);
this.playSound(gun.getLaunchSound(), 1.0f);
this.worldObj.spawnEntityInWorld(bullet);
}
else if(stack.getItem() == Items.snowball) {

View file

@ -11,6 +11,7 @@ import common.entity.types.IObjectData;
import common.entity.types.IProjectile;
import common.init.SoundEvent;
import common.tags.TagObject;
import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.ExtMath;
import common.util.HitPosition;
@ -20,10 +21,10 @@ import common.world.State;
import common.world.World;
public class EntityBullet extends Entity implements IProjectile, IObjectData {
private Entity shooter;
protected Entity shooter;
private int ticksMoved;
private int age;
private int damage = 5;
protected int age;
protected int damage = 5;
public EntityBullet(World world) {
super(world);
@ -175,33 +176,10 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData {
if(hit != null) {
if(hit.entity != null) {
float velo = ExtMath.sqrtd(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
int damage = ExtMath.ceild((double)velo * (double)this.damage);
DamageSource source;
if(this.shooter == null) {
source = DamageSource.causeShotDamage(this, this);
}
else {
source = DamageSource.causeShotDamage(this, this.shooter);
}
if((this.worldObj.client || Vars.damageBullet) && hit.entity.attackEntityFrom(source, damage)) {
if(hit.entity instanceof EntityLiving living && this.shooter instanceof EntityLiving shooter) {
EnchantmentHelper.applyThornEnchantments(living, shooter);
EnchantmentHelper.applyArthropodEnchantments(shooter, living);
}
this.playSound(SoundEvent.METALHIT, 0.2F);
}
this.setDead();
this.onHitEntity(hit.entity);
}
else if(!this.worldObj.client) {
State state = hit.block != null ? this.worldObj.getState(hit.block) : null;
if(state == null || state.getBlock().onShot(this.worldObj, hit.block, state, this)) {
this.playSound(SoundEvent.METALHIT, 0.5F);
this.setDead();
}
else {
this.onHitBlock(hit.block);
}
}
@ -232,6 +210,39 @@ public class EntityBullet extends Entity implements IProjectile, IObjectData {
this.rotYaw = this.prevYaw + (this.rotYaw - this.prevYaw) * 0.2F;
this.setPosition(this.posX, this.posY, this.posZ);
}
protected void onHitBlock(BlockPos pos) {
if(!this.worldObj.client) {
State state = pos != null ? this.worldObj.getState(pos) : null;
if(state == null || state.getBlock().onShot(this.worldObj, pos, state, this)) {
this.playSound(SoundEvent.METALHIT, 0.5F);
this.setDead();
}
}
}
protected void onHitEntity(Entity entity) {
float velo = ExtMath.sqrtd(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
int damage = ExtMath.ceild((double)velo * (double)this.damage);
DamageSource source;
if(this.shooter == null) {
source = DamageSource.causeShotDamage(this, this);
}
else {
source = DamageSource.causeShotDamage(this, this.shooter);
}
if((this.worldObj.client || Vars.damageBullet) && entity.attackEntityFrom(source, damage)) {
if(entity instanceof EntityLiving living && this.shooter instanceof EntityLiving shooter) {
EnchantmentHelper.applyThornEnchantments(living, shooter);
EnchantmentHelper.applyArthropodEnchantments(shooter, living);
}
this.playSound(SoundEvent.METALHIT, 0.2F);
}
this.setDead();
}
public void writeEntity(TagObject tag) {
tag.setInt("damage", this.damage);

View file

@ -0,0 +1,79 @@
package common.entity.projectile;
import common.entity.Entity;
import common.entity.EntityType;
import common.entity.types.EntityLiving;
import common.init.SoundEvent;
import common.model.ParticleType;
import common.tags.TagObject;
import common.util.BlockPos;
import common.world.World;
public class EntityMissile extends EntityBullet {
private int fuse;
private boolean flames;
public EntityMissile(World world) {
super(world);
}
public EntityMissile(World world, double x, double y, double z) {
super(world, x, y, z);
}
public EntityMissile(World world, double x, double y, double z, int data) {
super(world, x, y, z, data);
}
public EntityMissile(World world, EntityLiving shooter, EntityLiving target, int fuse, boolean flames, float velocity, float innacuracy) {
super(world, shooter, target, velocity, innacuracy);
this.fuse = fuse;
this.flames = flames;
}
public EntityMissile(World world, EntityLiving shooter, int fuse, boolean flames, float velocity) {
super(world, shooter, velocity);
this.fuse = fuse;
this.flames = flames;
}
public void onUpdate() {
super.onUpdate();
if(this.worldObj.client && this.age % 2 < 2)
this.worldObj.spawnParticle(ParticleType.SMOKE_NORMAL, this.posX, this.posY, this.posZ, this.rand.gaussian() * 0.05D,
this.rand.gaussian() * 0.05D, this.rand.gaussian() * 0.05D);
if(!this.worldObj.client && this.age > this.fuse)
this.explode();
}
protected void explode() {
this.setDead();
this.worldObj.newExplosion(this.shooter == null ? this : this.shooter, this.posX, this.posY, this.posZ, (float)this.damage, this.flames, true, false);
}
protected void onHitBlock(BlockPos pos) {
if(!this.worldObj.client)
this.explode();
}
protected void onHitEntity(Entity entity) {
if(!this.worldObj.client)
this.explode();
}
public void writeEntity(TagObject tag) {
super.writeEntity(tag);
tag.setInt("fuse", this.fuse);
tag.setBool("flames", this.flames);
}
public void readEntity(TagObject tag) {
super.readEntity(tag);
this.fuse = tag.getInt("fuse");
this.flames = tag.getBool("flames");
}
public EntityType getType() {
return EntityType.EXPLOSIVE;
}
}

View file

@ -24,7 +24,6 @@ import common.entity.item.EntityChestCart;
import common.entity.item.EntityCrystal;
import common.entity.item.EntityExplosion;
import common.entity.item.EntityFalling;
import common.entity.item.EntityFireworks;
import common.entity.item.EntityHopperCart;
import common.entity.item.EntityItem;
import common.entity.item.EntityLeashKnot;
@ -45,6 +44,7 @@ import common.entity.projectile.EntityEgg;
import common.entity.projectile.EntityFireCharge;
import common.entity.projectile.EntityFireball;
import common.entity.projectile.EntityHook;
import common.entity.projectile.EntityMissile;
import common.entity.projectile.EntityPotion;
import common.entity.projectile.EntitySnowball;
import common.entity.types.EntityLiving;
@ -253,7 +253,7 @@ public abstract class EntityRegistry {
registerEntity("Box", EntityBox.class, "Eisenwürfel");
registerEntity("Tnt", EntityTnt.class, "TNT");
registerEntity("Falling", EntityFalling.class, "Fallender Block");
registerEntity("Fireworks", EntityFireworks.class, "Feuerwerk");
registerEntity("Fireworks", EntityMissile.class, "Feuerwerk");
registerEntity("Boat", EntityBoat.class, "Boot");
registerEntity("Minecart", EntityMinecart.class, "Lore");
registerEntity("ChestCart", EntityChestCart.class, "Güterlore");

View file

@ -62,7 +62,7 @@ import common.item.tool.ItemEgg;
import common.item.tool.ItemExpBottle;
import common.item.tool.ItemExterminator;
import common.item.tool.ItemFireball;
import common.item.tool.ItemFirework;
import common.item.tool.ItemRocketLauncher;
import common.item.tool.ItemFishFood;
import common.item.tool.ItemFishingRod;
import common.item.tool.ItemFlintAndSteel;
@ -229,6 +229,8 @@ public abstract class ItemRegistry {
register("bow", (new ItemBow()).setDisplay("Bogen"));
register("boltgun", (new ItemBoltgun()).setDisplay("Bolter"));
register("bolt", (new ItemAmmo(5, 1.0f, StackSize.L)).setDisplay("Bolter-Munition"));
register("rocket_launcher", (new ItemRocketLauncher()).setDisplay("Raketenwerfer"));
register("rocket", (new ItemAmmo(6, 6.0f, StackSize.L)).setDisplay("Rakete"));
register("arrow", (new ItemArrow()).setDisplay("Pfeil").setTab(CheatTab.WEAPONS).setMaxAmount(StackSize.L));
Item coal = (new Item()).setDisplay("Kohle").setTab(CheatTab.METALS);
register("coal", coal);
@ -314,7 +316,6 @@ public abstract class ItemRegistry {
register("carrot_on_a_stick", (new ItemCarrotOnAStick()).setDisplay("Karottenrute"));
register("charge_crystal", (new ItemEffect()).setDisplay("Energiekristall").setTab(CheatTab.MISC).setColor(TextColor.DMAGENTA));
register("pumpkin_pie", (new ItemFood(8, false)).setDisplay("Kürbiskuchen").setTab(CheatTab.FOOD));
register("fireworks", (new ItemFirework()).setDisplay("Feuerwerksrakete").setTab(CheatTab.EXPLOSIVES));
for(Enchantment ench : Enchantment.values()) {
register("enchanted_book_" + ench.getName(), (new ItemEnchantedBook(ench, 1)).setUnstackable().setDisplay("Verzaubertes Buch mit " + ench.getFormattedName(1)).setTab(CheatTab.ENCHANTMENTS));
int max = ench.getMaxLevel();

View file

@ -60,7 +60,7 @@ import common.item.tool.ItemEgg;
import common.item.tool.ItemExpBottle;
import common.item.tool.ItemExterminator;
import common.item.tool.ItemFireball;
import common.item.tool.ItemFirework;
import common.item.tool.ItemRocketLauncher;
import common.item.tool.ItemFishFood;
import common.item.tool.ItemFishingRod;
import common.item.tool.ItemFlintAndSteel;
@ -373,7 +373,6 @@ public abstract class Items {
public static final Item fermented_spider_eye = get("fermented_spider_eye");
public static final ItemColored fern = get("fern");
public static final ItemFireball fireball = get("fireball");
public static final ItemFirework fireworks = get("fireworks");
public static final ItemFishingRod fishing_rod = get("fishing_rod");
public static final Item flint = get("flint");
public static final ItemFlintAndSteel flint_and_steel = get("flint_and_steel");
@ -1018,6 +1017,8 @@ public abstract class Items {
public static final ItemEnchantedBook enchanted_book_thorns_3 = get("enchanted_book_thorns_3");
public static final ItemEnchantedBook enchanted_book_unbreaking = get("enchanted_book_unbreaking");
public static final ItemEnchantedBook enchanted_book_unbreaking_3 = get("enchanted_book_unbreaking_3");
public static final ItemRocketLauncher rocket_launcher = get("rocket_launcher");
public static final ItemAmmo rocket = get("rocket");
private static <T extends Item> T get(String id) {
T item = (T)ItemRegistry.byName(id);

View file

@ -53,13 +53,6 @@ public enum SoundEvent {
LAVA_POP("lavapop"),
WATER("water"),
NOTE("note"),
BLAST_SMALL("blast"),
BLAST_SMALL_FAR("blast_far"),
BLAST_LARGE("large_blast"),
BLAST_LARGE_FAR("large_blast_far"),
LAUNCH("launch"),
TWINKLE("twinkle"),
TWINKLE_FAR("twinkle_far"),
PLOP("plop"),
CUT("cut"),

View file

@ -8,6 +8,7 @@ import common.collect.Sets;
import common.entity.npc.EntityNPC;
import common.item.Item;
import common.item.ItemStack;
import common.network.IPlayer;
import common.tileentity.TileEntity;
import common.util.ExtMath;
@ -26,7 +27,7 @@ public abstract class Container
/** The current drag event (0 : start, 1 : add slot : 2 : end) */
private int dragEvent;
private final Set<Slot> dragSlots = Sets.<Slot>newHashSet();
protected List<ICrafting> crafters = Lists.<ICrafting>newArrayList();
protected List<IPlayer> crafters = Lists.<IPlayer>newArrayList();
private Set<EntityNPC> playerList = Sets.<EntityNPC>newHashSet();
/**
@ -40,7 +41,7 @@ public abstract class Container
return slotIn;
}
public void onCraftGuiOpened(ICrafting listener)
public void onCraftGuiOpened(IPlayer listener)
{
if (this.crafters.contains(listener))
{
@ -49,7 +50,7 @@ public abstract class Container
else
{
this.crafters.add(listener);
listener.updateCraftingInventory(this, this.getInventory());
listener.sendContainer(this, this.getInventory());
this.detectAndSendChanges();
}
}
@ -57,7 +58,7 @@ public abstract class Container
/**
* Remove the given Listener. Method name is for legacy.
*/
public void removeCraftingFromCrafters(ICrafting listeners)
public void removeCraftingFromCrafters(IPlayer listeners)
{
this.crafters.remove(listeners);
}
@ -91,7 +92,7 @@ public abstract class Container
for (int j = 0; j < this.crafters.size(); ++j)
{
((ICrafting)this.crafters.get(j)).sendSlotContents(this, i, last);
((IPlayer)this.crafters.get(j)).sendSlot(this, i, last);
}
}
}

View file

@ -3,6 +3,7 @@ package common.inventory;
import common.entity.npc.EntityNPC;
import common.init.Items;
import common.item.ItemStack;
import common.network.IPlayer;
public class ContainerBrewingStand extends Container
{
@ -34,10 +35,10 @@ public class ContainerBrewingStand extends Container
}
}
public void onCraftGuiOpened(ICrafting listener)
public void onCraftGuiOpened(IPlayer listener)
{
super.onCraftGuiOpened(listener);
listener.sendAllWindowProperties(this, this.tileBrewingStand);
listener.sendProperties(this, this.tileBrewingStand);
}
/**
@ -49,11 +50,11 @@ public class ContainerBrewingStand extends Container
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting)this.crafters.get(i);
IPlayer icrafting = (IPlayer)this.crafters.get(i);
if (this.brewTime != this.tileBrewingStand.getField(0))
{
icrafting.sendProgressBarUpdate(this, 0, this.tileBrewingStand.getField(0));
icrafting.sendProperty(this, 0, this.tileBrewingStand.getField(0));
}
}

View file

@ -10,6 +10,7 @@ import common.init.Blocks;
import common.init.Items;
import common.item.ItemStack;
import common.item.material.ItemEnchantedBook;
import common.network.IPlayer;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Pair;
@ -88,16 +89,16 @@ public class ContainerEnchantment extends Container
return data < 0 ? null : new Pair<Enchantment, Integer>(Enchantment.values()[(data & 0xff) % Enchantment.values().length], data >> 8);
}
public void onCraftGuiOpened(ICrafting listener)
public void onCraftGuiOpened(IPlayer listener)
{
super.onCraftGuiOpened(listener);
listener.sendProgressBarUpdate(this, 0, this.mana[0]);
listener.sendProgressBarUpdate(this, 1, this.mana[1]);
listener.sendProgressBarUpdate(this, 2, this.mana[2]);
listener.sendProgressBarUpdate(this, 3, this.seed & -16);
listener.sendProgressBarUpdate(this, 4, encodeData(this.ench[0]));
listener.sendProgressBarUpdate(this, 5, encodeData(this.ench[1]));
listener.sendProgressBarUpdate(this, 6, encodeData(this.ench[2]));
listener.sendProperty(this, 0, this.mana[0]);
listener.sendProperty(this, 1, this.mana[1]);
listener.sendProperty(this, 2, this.mana[2]);
listener.sendProperty(this, 3, this.seed & -16);
listener.sendProperty(this, 4, encodeData(this.ench[0]));
listener.sendProperty(this, 5, encodeData(this.ench[1]));
listener.sendProperty(this, 6, encodeData(this.ench[2]));
}
public void detectAndSendChanges()
@ -106,14 +107,14 @@ public class ContainerEnchantment extends Container
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting)this.crafters.get(i);
icrafting.sendProgressBarUpdate(this, 0, this.mana[0]);
icrafting.sendProgressBarUpdate(this, 1, this.mana[1]);
icrafting.sendProgressBarUpdate(this, 2, this.mana[2]);
icrafting.sendProgressBarUpdate(this, 3, this.seed & -16);
icrafting.sendProgressBarUpdate(this, 4, encodeData(this.ench[0]));
icrafting.sendProgressBarUpdate(this, 5, encodeData(this.ench[1]));
icrafting.sendProgressBarUpdate(this, 6, encodeData(this.ench[2]));
IPlayer icrafting = (IPlayer)this.crafters.get(i);
icrafting.sendProperty(this, 0, this.mana[0]);
icrafting.sendProperty(this, 1, this.mana[1]);
icrafting.sendProperty(this, 2, this.mana[2]);
icrafting.sendProperty(this, 3, this.seed & -16);
icrafting.sendProperty(this, 4, encodeData(this.ench[0]));
icrafting.sendProperty(this, 5, encodeData(this.ench[1]));
icrafting.sendProperty(this, 6, encodeData(this.ench[2]));
}
}

View file

@ -3,6 +3,7 @@ package common.inventory;
import common.entity.npc.EntityNPC;
import common.init.SmeltingRegistry;
import common.item.ItemStack;
import common.network.IPlayer;
import common.tileentity.TileEntityFurnace;
public class ContainerFurnace extends Container
@ -34,10 +35,10 @@ public class ContainerFurnace extends Container
}
}
public void onCraftGuiOpened(ICrafting listener)
public void onCraftGuiOpened(IPlayer listener)
{
super.onCraftGuiOpened(listener);
listener.sendAllWindowProperties(this, this.tileFurnace);
listener.sendProperties(this, this.tileFurnace);
}
/**
@ -49,26 +50,26 @@ public class ContainerFurnace extends Container
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting icrafting = (ICrafting)this.crafters.get(i);
IPlayer icrafting = (IPlayer)this.crafters.get(i);
if (this.cookTime != this.tileFurnace.getField(2))
{
icrafting.sendProgressBarUpdate(this, 2, this.tileFurnace.getField(2));
icrafting.sendProperty(this, 2, this.tileFurnace.getField(2));
}
if (this.furnaceBurnTime != this.tileFurnace.getField(0))
{
icrafting.sendProgressBarUpdate(this, 0, this.tileFurnace.getField(0));
icrafting.sendProperty(this, 0, this.tileFurnace.getField(0));
}
if (this.currentItemBurnTime != this.tileFurnace.getField(1))
{
icrafting.sendProgressBarUpdate(this, 1, this.tileFurnace.getField(1));
icrafting.sendProperty(this, 1, this.tileFurnace.getField(1));
}
if (this.totalCookTime != this.tileFurnace.getField(3))
{
icrafting.sendProgressBarUpdate(this, 3, this.tileFurnace.getField(3));
icrafting.sendProperty(this, 3, this.tileFurnace.getField(3));
}
}

View file

@ -2,6 +2,7 @@ package common.inventory;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
import common.network.IPlayer;
import common.world.World;
public class ContainerMerchant extends Container
@ -46,7 +47,7 @@ public class ContainerMerchant extends Container
return this.merchantInventory;
}
public void onCraftGuiOpened(ICrafting listener)
public void onCraftGuiOpened(IPlayer listener)
{
super.onCraftGuiOpened(listener);
}

View file

@ -9,6 +9,7 @@ import common.enchantment.EnchantmentHelper;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
import common.item.material.ItemEnchantedBook;
import common.network.IPlayer;
import common.util.BlockPos;
import common.vars.Vars;
import common.world.State;
@ -381,10 +382,10 @@ public class ContainerRepair extends Container
}
}
public void onCraftGuiOpened(ICrafting listener)
public void onCraftGuiOpened(IPlayer listener)
{
super.onCraftGuiOpened(listener);
listener.sendProgressBarUpdate(this, 0, this.maximumCost);
listener.sendProperty(this, 0, this.maximumCost);
}
public void updateProgressBar(int id, int data)

View file

@ -2,6 +2,7 @@ package common.inventory;
import common.entity.npc.EntityNPC;
import common.item.ItemStack;
import common.network.IPlayer;
import common.tileentity.TileEntityDevice;
import common.tileentity.TileEntityDevice.Status;
@ -96,13 +97,13 @@ public class ContainerTile extends Container
this.tileInv.closeInventory(playerIn);
}
public void onCraftGuiOpened(ICrafting listener)
public void onCraftGuiOpened(IPlayer listener)
{
super.onCraftGuiOpened(listener);
listener.sendProgressBarUpdate(this, this.resources.length, this.tile.getTemperature());
listener.sendProgressBarUpdate(this, this.resources.length + 1, this.tile.getStatus().ordinal());
listener.sendProperty(this, this.resources.length, this.tile.getTemperature());
listener.sendProperty(this, this.resources.length + 1, this.tile.getStatus().ordinal());
for(int z = 0; z < this.resources.length; z++) {
listener.sendProgressBarUpdate(this, z, this.tile.getResource(z).getValue());
listener.sendProperty(this, z, this.tile.getResource(z).getValue());
}
}
@ -122,14 +123,14 @@ public class ContainerTile extends Container
for (int i = 0; i < this.crafters.size(); ++i)
{
ICrafting listener = this.crafters.get(i);
IPlayer listener = this.crafters.get(i);
if(this.temperature != this.tile.getTemperature())
listener.sendProgressBarUpdate(this, this.resources.length, this.tile.getTemperature());
listener.sendProperty(this, this.resources.length, this.tile.getTemperature());
if(this.status != this.tile.getStatus())
listener.sendProgressBarUpdate(this, this.resources.length + 1, this.tile.getStatus().ordinal());
listener.sendProperty(this, this.resources.length + 1, this.tile.getStatus().ordinal());
for(int z = 0; z < this.resources.length; z++) {
if(this.resources[z] != this.tile.getResource(z).getValue())
listener.sendProgressBarUpdate(this, z, this.tile.getResource(z).getValue());
listener.sendProperty(this, z, this.tile.getResource(z).getValue());
}
}

View file

@ -0,0 +1,5 @@
package common.inventory;
public interface ICfarsfadtfdwgfdgdvgs
{
}

View file

@ -1,13 +0,0 @@
package common.inventory;
import java.util.List;
import common.item.ItemStack;
public interface ICrafting
{
void updateCraftingInventory(Container containerToSend, List<ItemStack> itemsList);
void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack);
void sendProgressBarUpdate(Container containerIn, int varToUpdate, int newValue);
void sendAllWindowProperties(Container p_175173_1_, IInventory p_175173_2_);
}

View file

@ -160,6 +160,10 @@ public class Item {
public float getStrVsBlock(ItemStack stack, Block state) {
return 1.0F;
}
public int getUseCooldown(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) {
return 0;
}
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) {
return itemStackIn;

View file

@ -1,6 +1,7 @@
package common.item.tool;
import common.init.Items;
import common.rng.Random;
public class ItemBoltgun extends ItemGunBase {
public ItemBoltgun() {
@ -11,7 +12,7 @@ public class ItemBoltgun extends ItemGunBase {
return Items.bolt;
}
public float getVelocity() {
public float getVelocity(Random rand) {
return 8.0f;
}
}

View file

@ -1,48 +0,0 @@
package common.item.tool;
import common.entity.item.EntityFireworks;
import common.entity.npc.EntityNPC;
import common.item.Item;
import common.item.ItemStack;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.util.Facing;
import common.util.Vec3;
import common.world.World;
public class ItemFirework extends Item
{
public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ)
{
if (!worldIn.client)
{
EntityFireworks entityfireworkrocket = new EntityFireworks(worldIn, (double)((float)pos.getX() + hitX), (double)((float)pos.getY() + hitY), (double)((float)pos.getZ() + hitZ));
worldIn.spawnEntityInWorld(entityfireworkrocket);
// if (!playerIn.creative)
// {
stack.decrSize();
// }
return true;
}
else
{
return false;
}
}
public ItemStack dispenseStack(World world, TileEntity source, Vec3 position, BlockPos blockpos, Facing facing, ItemStack stack) {
double d0 = blockpos.getX() + 0.5 + (double)facing.getFrontOffsetX();
double d1 = (double)blockpos.getY() + 0.2;
double d2 = blockpos.getZ() + 0.5 + (double)facing.getFrontOffsetZ();
EntityFireworks entityfireworkrocket = new EntityFireworks(world, d0, d1, d2);
world.spawnEntityInWorld(entityfireworkrocket);
stack.split(1);
return stack;
}
public int getDispenseSoundId() {
return 1002;
}
}

View file

@ -4,18 +4,20 @@ import common.enchantment.Enchantment;
import common.enchantment.EnchantmentHelper;
import common.entity.npc.EntityNPC;
import common.entity.projectile.EntityBullet;
import common.entity.types.EntityLiving;
import common.init.SoundEvent;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemAction;
import common.item.ItemStack;
import common.model.Transforms;
import common.rng.Random;
import common.world.World;
public abstract class ItemGunBase extends Item
{
public abstract ItemAmmo getAmmo();
public abstract float getVelocity();
public abstract float getVelocity(Random rand);
public ItemGunBase(int durability)
{
@ -28,15 +30,14 @@ public abstract class ItemGunBase extends Item
return ItemAction.AIM;
}
public ItemStack onItemRightClick(ItemStack stack, World worldIn, EntityNPC playerIn)
public ItemStack onItemRightClick(ItemStack stack, World world, EntityNPC player)
{
if(stack.getItemDamage() >= this.getMaxDamage())
return stack;
boolean flag = // playerIn.creative ||
EnchantmentHelper.getEnchantmentLevel(Enchantment.INFINITY, stack) > 0;
if (flag || playerIn.inventory.hasItem(this.getAmmo()))
boolean flag = EnchantmentHelper.getEnchantmentLevel(Enchantment.INFINITY, stack) > 0;
if (flag || player.inventory.hasItem(this.getAmmo()))
{
EntityBullet bullet = new EntityBullet(worldIn, playerIn, this.getVelocity());
EntityBullet bullet = this.createBullet(world, player);
bullet.setDamage(this.getAmmo().getDamage(stack));
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.POWER, stack);
@ -46,34 +47,32 @@ public abstract class ItemGunBase extends Item
bullet.setDamage(bullet.getDamage() + j);
}
// int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
//
// if (k > 0)
// {
// entityarrow.setKnockbackStrength(k);
// }
// if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
// {
// entityarrow.setFire(100);
// }
stack.damage(1, playerIn);
worldIn.playSoundAtEntity(playerIn, SoundEvent.EXPLODE_ALT, 1.0F);
stack.damage(1, player);
world.playSoundAtEntity(player, this.getLaunchSound(), 1.0F);
if(!flag)
playerIn.inventory.consumeInventoryItem(this.getAmmo());
player.inventory.consumeInventoryItem(this.getAmmo());
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
if (!worldIn.client)
if (!world.client)
{
worldIn.spawnEntityInWorld(bullet);
world.spawnEntityInWorld(bullet);
}
}
return stack;
}
public SoundEvent getLaunchSound() {
return SoundEvent.EXPLODE_ALT;
}
protected EntityBullet createBullet(World world, EntityNPC player) {
return new EntityBullet(world, player, this.getVelocity(player.getRNG()));
}
public EntityBullet createBulletFor(World world, EntityLiving shooter, EntityLiving target) {
return new EntityBullet(world, shooter, target, this.getVelocity(shooter.getRNG()), 0.75f);
}
public int getItemEnchantability()
{
return 1;

View file

@ -0,0 +1,32 @@
package common.item.tool;
import common.entity.npc.EntityNPC;
import common.entity.projectile.EntityBullet;
import common.entity.projectile.EntityMissile;
import common.entity.types.EntityLiving;
import common.init.SoundEvent;
import common.rng.Random;
import common.world.World;
public abstract class ItemLauncherBase extends ItemGunBase
{
public abstract int getFuse(Random rand);
public abstract boolean hasFlames();
public ItemLauncherBase(int durability)
{
super(durability);
}
public SoundEvent getLaunchSound() {
return SoundEvent.FIREBALL;
}
protected EntityBullet createBullet(World world, EntityNPC player) {
return new EntityMissile(world, player, this.getFuse(player.getRNG()), this.hasFlames(), this.getVelocity(player.getRNG()));
}
public EntityBullet createBulletFor(World world, EntityLiving shooter, EntityLiving target) {
return new EntityMissile(world, shooter, target, this.getFuse(shooter.getRNG()), this.hasFlames(), this.getVelocity(shooter.getRNG()), 0.75f);
}
}

View file

@ -0,0 +1,33 @@
package common.item.tool;
import common.entity.npc.EntityNPC;
import common.init.Items;
import common.item.ItemStack;
import common.rng.Random;
import common.world.World;
public class ItemRocketLauncher extends ItemLauncherBase {
public ItemRocketLauncher() {
super(2560);
}
public int getFuse(Random rand) {
return rand.range(25, 40);
}
public boolean hasFlames() {
return false;
}
public ItemAmmo getAmmo() {
return Items.rocket;
}
public float getVelocity(Random rand) {
return 4.0f;
}
public int getUseCooldown(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) {
return 20;
}
}

View file

@ -95,7 +95,6 @@ public interface IPlayer extends NetHandler {
void onEnchantmentCritical(Entity entity);
void updateEffectMeta();
void playSound(SoundEvent name, float volume);
void sendContainerToPlayer(Container container);
void updateEntity();
void setSelection(boolean primary, BlockPos pos);
void setSelectMode();
@ -106,6 +105,11 @@ public interface IPlayer extends NetHandler {
double getManagedZ();
void setManagedPos(double x, double z);
void sendContainer(Container container, List<ItemStack> items);
void sendSlot(Container container, int index, ItemStack stack);
void sendProperty(Container container, int variable, int value);
void sendProperties(Container container, IInventory inventory);
void processKeepAlive(CPacketKeepAlive packet);
void processMessage(CPacketMessage packet);
void processComplete(CPacketComplete packet);