add rocket launcher + fixes
This commit is contained in:
parent
987c76d2c5
commit
eca1f242c4
54 changed files with 452 additions and 478 deletions
|
@ -770,6 +770,8 @@ public class Client implements IThreadListener {
|
|||
if (this.keyBindsHotbar[l].isPressed())
|
||||
{
|
||||
// if(!this.showDebugProfilerChart) {
|
||||
if(this.player.inventory.currentItem != l)
|
||||
this.controller.resetUseCooldown();
|
||||
this.player.inventory.currentItem = l;
|
||||
// }
|
||||
}
|
||||
|
@ -1127,7 +1129,7 @@ public class Client implements IThreadListener {
|
|||
ItemStack itemstack = this.player.inventory.mainInventory[index];
|
||||
if(itemstack != null) {
|
||||
GuiContainer.renderItemOverlay(itemstack,
|
||||
this.fb_x / 2 - 180 + 4 + 1 + index * 40, this.fb_y - 40 + 1, null);
|
||||
this.fb_x / 2 - 180 + 4 + 1 + index * 40, this.fb_y - 40 + 1, null, index == this.player.inventory.currentItem ? this.controller.getUseCooldown() : 0, this.controller.getUseCooldownMax());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1270,8 +1272,10 @@ public class Client implements IThreadListener {
|
|||
// }
|
||||
if(this.zooming)
|
||||
this.zoomLevel = ExtMath.clampf(this.zoomLevel + (dir < 0 ? -0.25f : 0.25f), 2.0f, 16.0f);
|
||||
else if(this.player != null)
|
||||
else if(this.player != null) {
|
||||
this.player.inventory.changeCurrentItem(dir);
|
||||
this.controller.resetUseCooldown();
|
||||
}
|
||||
}
|
||||
|
||||
// public void resize(int width, int height)
|
||||
|
@ -1558,7 +1562,8 @@ public class Client implements IThreadListener {
|
|||
|
||||
InventoryPlayer inventoryplayer = this.player.inventory;
|
||||
|
||||
inventoryplayer.setCurrentItem(item);
|
||||
if(inventoryplayer.setCurrentItem(item))
|
||||
this.controller.resetUseCooldown();
|
||||
if(this.itemCheat) {
|
||||
this.player.client.addToSendQueue(new CPacketCheat(item, -2 - inventoryplayer.currentItem, this.ctrl()));
|
||||
}
|
||||
|
|
|
@ -5,30 +5,27 @@ import common.inventory.IInventory;
|
|||
import common.inventory.InventoryPlayer;
|
||||
|
||||
public class GuiBrewing extends GuiContainer {
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final IInventory tileBrewingStand;
|
||||
private final InventoryPlayer playerInv;
|
||||
private final IInventory brewer;
|
||||
|
||||
public GuiBrewing(InventoryPlayer player, IInventory inc) {
|
||||
super(new ContainerBrewingStand(player, inc));
|
||||
this.playerInventory = player;
|
||||
this.tileBrewingStand = inc;
|
||||
public GuiBrewing(InventoryPlayer player, IInventory brewer) {
|
||||
super(new ContainerBrewingStand(player, brewer));
|
||||
this.playerInv = player;
|
||||
this.brewer = brewer;
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
super.draw();
|
||||
int k = this.tileBrewingStand.getField(0);
|
||||
|
||||
if(k > 0) {
|
||||
int l = (int)(28.0F * (1.0F - (float)k / 400.0F));
|
||||
|
||||
if(l > 0) {
|
||||
this.rect(97, 16, 9, l, 0xffff20);
|
||||
}
|
||||
int progress = this.brewer.getField(0);
|
||||
if(progress > 0) {
|
||||
int value = (int)(28.0F * (1.0F - (float)progress / 400.0F));
|
||||
if(value > 0)
|
||||
this.rect(97, 16, 9, value, 0xffff20);
|
||||
}
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.tileBrewingStand.getCommandName(), 8, 6);
|
||||
this.label(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
this.label(this.brewer.getCommandName(), 8, 6);
|
||||
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,22 +5,20 @@ import common.inventory.ContainerChest;
|
|||
import common.inventory.IInventory;
|
||||
|
||||
public class GuiChest extends GuiContainer {
|
||||
private final IInventory upperChestInventory;
|
||||
private final IInventory lowerChestInventory;
|
||||
private final int inventoryRows;
|
||||
private final IInventory upper;
|
||||
private final IInventory lower;
|
||||
|
||||
public GuiChest(IInventory upperInv, IInventory lowerInv) {
|
||||
super(new ContainerChest(upperInv, lowerInv, Client.CLIENT.player));
|
||||
this.upperChestInventory = upperInv;
|
||||
this.lowerChestInventory = lowerInv;
|
||||
public GuiChest(IInventory upper, IInventory lower) {
|
||||
super(new ContainerChest(upper, lower, Client.CLIENT.player));
|
||||
this.upper = upper;
|
||||
this.lower = lower;
|
||||
int i = 222;
|
||||
int j = i - 108;
|
||||
this.inventoryRows = lowerInv.getSizeInventory() / 9;
|
||||
this.ySize = j + this.inventoryRows * 18;
|
||||
this.ySize = j + (lower.getSizeInventory() / 9) * 18;
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.lowerChestInventory.getCommandName(), 8, 6);
|
||||
this.label(this.upperChestInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
this.label(this.lower.getCommandName(), 8, 6);
|
||||
this.label(this.upper.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -858,10 +858,10 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
public void renderItemOverlayIntoGUI(ItemStack stack, int xPosition, int yPosition, String text)
|
||||
{
|
||||
renderItemOverlay(stack, this.container_x + xPosition * 2, this.container_y + yPosition * 2, text);
|
||||
renderItemOverlay(stack, this.container_x + xPosition * 2, this.container_y + yPosition * 2, text, 0, 0);
|
||||
}
|
||||
|
||||
public static void renderItemOverlay(ItemStack stack, int xPosition, int yPosition, String text)
|
||||
public static void renderItemOverlay(ItemStack stack, int xPosition, int yPosition, String text, int bar2, int bar2max)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
|
@ -884,6 +884,15 @@ public abstract class GuiContainer extends Gui
|
|||
draw(xPosition + 2, yPosition + 26, 26, 2, (255 - i) / 4, 64, 0);
|
||||
draw(xPosition + 2, yPosition + 26, j, 2, 255 - i, i, 0);
|
||||
}
|
||||
|
||||
if (bar2 > 0)
|
||||
{
|
||||
int j = (int)Math.round(28.0D - (double)bar2 * 28.0D / (double)bar2max);
|
||||
int i = (int)Math.round(255.0D - (double)bar2 * 255.0D / (double)bar2max);
|
||||
draw(xPosition + 2, yPosition + 4, 28, 4, 0, 0, 0);
|
||||
draw(xPosition + 2, yPosition + 4, 26, 2, (255 - i) / 8, (255 - i) / 16, i / 4);
|
||||
draw(xPosition + 2 + 28 - j, yPosition + 4, j, 2, (255 - i) / 2, (255 - i) / 4, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ import common.world.World;
|
|||
public class GuiCrafting extends GuiContainer {
|
||||
private final BlockWorkbench type;
|
||||
|
||||
public GuiCrafting(InventoryPlayer playerInv, World world, BlockWorkbench type) {
|
||||
super(new ContainerWorkbench(playerInv, world, BlockPos.ORIGIN, type));
|
||||
public GuiCrafting(InventoryPlayer inv, World world, BlockWorkbench type) {
|
||||
super(new ContainerWorkbench(inv, world, BlockPos.ORIGIN, type));
|
||||
this.type = type;
|
||||
this.ySize = 112 + 18 * this.type.getSize();
|
||||
}
|
||||
|
|
|
@ -5,17 +5,17 @@ import common.inventory.IInventory;
|
|||
import common.inventory.InventoryPlayer;
|
||||
|
||||
public class GuiDispenser extends GuiContainer {
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final IInventory dispenserInventory;
|
||||
private final InventoryPlayer playerInv;
|
||||
private final IInventory dispenser;
|
||||
|
||||
public GuiDispenser(InventoryPlayer playerInv, IInventory dispenserInv) {
|
||||
super(new ContainerDispenser(playerInv, dispenserInv));
|
||||
this.playerInventory = playerInv;
|
||||
this.dispenserInventory = dispenserInv;
|
||||
public GuiDispenser(InventoryPlayer playerInv, IInventory dispenser) {
|
||||
super(new ContainerDispenser(playerInv, dispenser));
|
||||
this.playerInv = playerInv;
|
||||
this.dispenser = dispenser;
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.dispenserInventory.getCommandName(), 8, 6);
|
||||
this.label(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
this.label(this.dispenser.getCommandName(), 8, 6);
|
||||
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,10 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
|
|||
"the elder scrolls klaatu berata niktu xyzzy bless curse light darkness fire air earth water hot dry cold wet ignite snuff embiggen twist shorten stretch fiddle destroy imbue galvanize enchant free limited range of towards inside sphere cube self other ball mental physical grow shrink demon elemental spirit animal creature beast humanoid undead fresh stale "
|
||||
.split(" ");
|
||||
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final InventoryPlayer playerInv;
|
||||
private final Random nameRand = new Random();
|
||||
private final Random random = new Random();
|
||||
private final ContainerEnchantment container;
|
||||
private final ContainerEnchantment enchantment;
|
||||
private final String title;
|
||||
private final ActButton[] buttons = new ActButton[3];
|
||||
private final Label[] labels = new Label[3];
|
||||
|
@ -28,18 +28,18 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
|
|||
|
||||
public GuiEnchant(InventoryPlayer inv, World world, String title) {
|
||||
super(new ContainerEnchantment(inv, world));
|
||||
this.playerInventory = inv;
|
||||
this.container = (ContainerEnchantment)this.inventorySlots;
|
||||
this.playerInv = inv;
|
||||
this.enchantment = (ContainerEnchantment)this.inventorySlots;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
this.nameRand.setSeed((long)this.container.seed);
|
||||
this.nameRand.setSeed((long)this.enchantment.seed);
|
||||
|
||||
for(int l = 0; l < 3; ++l) {
|
||||
String name = this.getRandomName();
|
||||
int mana = this.container.mana[l];
|
||||
int mana = this.enchantment.mana[l];
|
||||
|
||||
if(mana == 0) {
|
||||
this.buttons[l].enabled = false;
|
||||
|
@ -63,7 +63,7 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
|
|||
|
||||
public void addElements() {
|
||||
this.label(this.title, 12, 5);
|
||||
this.label(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
for(int l = 0; l < 3; ++l) {
|
||||
int i1 = 60;
|
||||
int j1 = i1 + 2;
|
||||
|
@ -74,8 +74,8 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
|
|||
|
||||
public void use(ActButton btn, PressType type) {
|
||||
for(int k = 0; k < 3; ++k) {
|
||||
if(btn == this.buttons[k] && this.container.enchantItem(this.gm.player, k))
|
||||
this.gm.controller.sendEnchantPacket(this.container.windowId, k);
|
||||
if(btn == this.buttons[k] && this.enchantment.enchantItem(this.gm.player, k))
|
||||
this.gm.controller.sendEnchantPacket(this.enchantment.windowId, k);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,8 +90,8 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
|
|||
super.drawScreen(mouseX, mouseY);
|
||||
|
||||
for(int j = 0; j < 3; ++j) {
|
||||
int k = this.container.mana[j];
|
||||
Pair<Enchantment, Integer> l = this.container.ench[j];
|
||||
int k = this.enchantment.mana[j];
|
||||
Pair<Enchantment, Integer> l = this.enchantment.ench[j];
|
||||
int i1 = j + 1;
|
||||
|
||||
if(this.isPointInRegion(60, 14 + 19 * j, 108, 17, mouseX, mouseY) && k > 0 && l != null) {
|
||||
|
@ -101,7 +101,7 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
|
|||
sb.append(TextColor.WHITE + s + " . . . ?");
|
||||
|
||||
if(this.gm.player.getManaPoints() < k) {
|
||||
sb.append((sb.length() != 0 ? "\n" : "") + TextColor.RED + String.format("%d Mana erforderlich", this.container.mana[j]));
|
||||
sb.append((sb.length() != 0 ? "\n" : "") + TextColor.RED + String.format("%d Mana erforderlich", this.enchantment.mana[j]));
|
||||
}
|
||||
else {
|
||||
String s1 = "";
|
||||
|
|
|
@ -6,17 +6,17 @@ import common.inventory.ContainerEntityInventory;
|
|||
import common.inventory.IInventory;
|
||||
|
||||
public class GuiEntity extends GuiContainer {
|
||||
private final IInventory playerInventory;
|
||||
private final IInventory entityInventory;
|
||||
private final IInventory playerInv;
|
||||
private final IInventory entity;
|
||||
|
||||
public GuiEntity(IInventory playerInv, IInventory entityInv, Entity entity) {
|
||||
super(new ContainerEntityInventory(playerInv, entityInv, entity, Client.CLIENT.player));
|
||||
this.playerInventory = playerInv;
|
||||
this.entityInventory = entityInv;
|
||||
this.playerInv = playerInv;
|
||||
this.entity = entityInv;
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.entityInventory.getCommandName(), 8, 6);
|
||||
this.label(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
this.label(this.entity.getCommandName(), 8, 6);
|
||||
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,43 +6,43 @@ import common.inventory.InventoryPlayer;
|
|||
import common.tileentity.TileEntityFurnace;
|
||||
|
||||
public class GuiFurnace extends GuiContainer {
|
||||
private final InventoryPlayer playerInventory;
|
||||
private final IInventory tileFurnace;
|
||||
private final InventoryPlayer playerInv;
|
||||
private final IInventory furnace;
|
||||
|
||||
public GuiFurnace(InventoryPlayer playerInv, IInventory furnaceInv) {
|
||||
super(new ContainerFurnace(playerInv, furnaceInv));
|
||||
this.playerInventory = playerInv;
|
||||
this.tileFurnace = furnaceInv;
|
||||
this.playerInv = playerInv;
|
||||
this.furnace = furnaceInv;
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
super.draw();
|
||||
this.rect(58, 36, 12, 14, 0x202020);
|
||||
if(TileEntityFurnace.isBurning(this.tileFurnace)) {
|
||||
int k = this.getBurnLeftScaled(13);
|
||||
k = Math.min(k, 13);
|
||||
this.rect(58, 36 + 13 - k, 12, k + 1, 0xff7f00);
|
||||
if(TileEntityFurnace.isBurning(this.furnace)) {
|
||||
int burn = this.getBurnLeftScaled(13);
|
||||
burn = Math.min(burn, 13);
|
||||
this.rect(58, 36 + 13 - burn, 12, burn + 1, 0xff7f00);
|
||||
}
|
||||
|
||||
int l = this.getCookProgressScaled(24);
|
||||
int progress = this.getCookProgressScaled(24);
|
||||
this.rect(79, 39, 24, 8, 0x606060);
|
||||
if(l > 0)
|
||||
this.rect(79, 39, l + 1, 8, 0xffaf00);
|
||||
if(progress > 0)
|
||||
this.rect(79, 39, progress + 1, 8, 0xffaf00);
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.tileFurnace.getCommandName(), 8, 6);
|
||||
this.label(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
this.label(this.furnace.getCommandName(), 8, 6);
|
||||
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
private int getCookProgressScaled(int pixels) {
|
||||
int i = this.tileFurnace.getField(2);
|
||||
int j = this.tileFurnace.getField(3);
|
||||
return j != 0 && i != 0 ? i * pixels / j : 0;
|
||||
int progress = this.furnace.getField(2);
|
||||
int total = this.furnace.getField(3);
|
||||
return total != 0 && progress != 0 ? progress * pixels / total : 0;
|
||||
}
|
||||
|
||||
private int getBurnLeftScaled(int pixels) {
|
||||
int i = this.tileFurnace.getField(1);
|
||||
return this.tileFurnace.getField(0) * pixels / (i == 0 ? 200 : i);
|
||||
int total = this.furnace.getField(1);
|
||||
return this.furnace.getField(0) * pixels / (total == 0 ? 200 : total);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,18 +6,18 @@ import common.inventory.IInventory;
|
|||
import common.inventory.InventoryPlayer;
|
||||
|
||||
public class GuiHopper extends GuiContainer {
|
||||
private final IInventory playerInventory;
|
||||
private final IInventory hopperInventory;
|
||||
private final IInventory playerInv;
|
||||
private final IInventory hopper;
|
||||
|
||||
public GuiHopper(InventoryPlayer playerInv, IInventory hopperInv) {
|
||||
super(new ContainerHopper(playerInv, hopperInv, Client.CLIENT.player));
|
||||
this.playerInventory = playerInv;
|
||||
this.hopperInventory = hopperInv;
|
||||
public GuiHopper(InventoryPlayer playerInv, IInventory hopper) {
|
||||
super(new ContainerHopper(playerInv, hopper, Client.CLIENT.player));
|
||||
this.playerInv = playerInv;
|
||||
this.hopper = hopper;
|
||||
this.ySize = 133;
|
||||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.hopperInventory.getCommandName(), 8, 6);
|
||||
this.label(this.playerInventory.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
this.label(this.hopper.getCommandName(), 8, 6);
|
||||
this.label(this.playerInv.getCommandName(), 8, this.ySize - 96 + 2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import common.village.MerchantRecipeList;
|
|||
import common.world.World;
|
||||
|
||||
public class GuiMerchant extends GuiContainer implements ButtonCallback {
|
||||
private final String merchantName;
|
||||
private final String title;
|
||||
|
||||
private int recipe;
|
||||
private ActButton prevBtn;
|
||||
|
@ -24,7 +24,7 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
|
|||
|
||||
public GuiMerchant(InventoryPlayer inv, String name, World world) {
|
||||
super(new ContainerMerchant(inv, null, world));
|
||||
this.merchantName = name != null ? name : "NSC";
|
||||
this.title = name != null ? name : "NSC";
|
||||
}
|
||||
|
||||
public void addButtons() {
|
||||
|
@ -39,7 +39,7 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
|
|||
}
|
||||
|
||||
public void addElements() {
|
||||
this.label(this.merchantName, 8, 6);
|
||||
this.label(this.title, 8, 6);
|
||||
this.label("Inventar", 8, this.ySize - 96 + 2);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,11 +9,11 @@ import common.world.World;
|
|||
public class GuiRepair extends GuiContainer {
|
||||
private ContainerRepair anvil;
|
||||
private Label info;
|
||||
private InventoryPlayer playerInventory;
|
||||
private InventoryPlayer playerInv;
|
||||
|
||||
public GuiRepair(InventoryPlayer inv, World world) {
|
||||
super(new ContainerRepair(inv, world));
|
||||
this.playerInventory = inv;
|
||||
this.playerInv = inv;
|
||||
this.anvil = (ContainerRepair)this.inventorySlots;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class GuiRepair extends GuiContainer {
|
|||
this.info.setText(TextColor.DRED + "Zu teuer!");
|
||||
else if(this.anvil.maximumCost <= 0 || !this.anvil.getSlot(2).getHasStack())
|
||||
this.info.setText("");
|
||||
else if(!this.anvil.getSlot(2).canTakeStack(this.playerInventory.player))
|
||||
else if(!this.anvil.getSlot(2).canTakeStack(this.playerInv.player))
|
||||
this.info.setText(TextColor.RED + "Manakosten: " + this.anvil.maximumCost);
|
||||
else
|
||||
this.info.setText(TextColor.GREEN + "Manakosten: " + this.anvil.maximumCost);
|
||||
|
|
|
@ -30,6 +30,7 @@ import client.renderer.entity.RenderLeashKnot;
|
|||
import client.renderer.entity.RenderLightning;
|
||||
import client.renderer.entity.RenderManager;
|
||||
import client.renderer.entity.RenderMinecart;
|
||||
import client.renderer.entity.RenderMissile;
|
||||
import client.renderer.entity.RenderMooshroom;
|
||||
import client.renderer.entity.RenderMouse;
|
||||
import client.renderer.entity.RenderNpc;
|
||||
|
@ -85,7 +86,6 @@ import common.entity.item.EntityBoat;
|
|||
import common.entity.item.EntityCart;
|
||||
import common.entity.item.EntityCrystal;
|
||||
import common.entity.item.EntityFalling;
|
||||
import common.entity.item.EntityFireworks;
|
||||
import common.entity.item.EntityItem;
|
||||
import common.entity.item.EntityLeashKnot;
|
||||
import common.entity.item.EntityNuke;
|
||||
|
@ -104,6 +104,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.init.Blocks;
|
||||
|
@ -136,7 +137,6 @@ public abstract class RenderRegistry {
|
|||
map.put(EntityEgg.class, new RenderItemEntity(mgr, Items.egg, ritem));
|
||||
map.put(EntityPotion.class, new RenderPotion(mgr, ritem));
|
||||
map.put(EntityXpBottle.class, new RenderItemEntity(mgr, Items.experience_bottle, ritem));
|
||||
map.put(EntityFireworks.class, new RenderItemEntity(mgr, Items.fireworks, ritem));
|
||||
map.put(EntityFireball.class, new RenderFireball(mgr, 0.75F));
|
||||
map.put(EntityFireCharge.class, new RenderFireball(mgr, 0.5F));
|
||||
map.put(EntityBox.class, new RenderFlyingBox(mgr));
|
||||
|
@ -154,6 +154,7 @@ public abstract class RenderRegistry {
|
|||
map.put(EntityMouse.class, new RenderMouse(mgr, new ModelMouse()));
|
||||
map.put(EntityDie.class, new RenderDie(mgr));
|
||||
map.put(EntityBullet.class, new RenderBullet(mgr));
|
||||
map.put(EntityMissile.class, new RenderMissile(mgr));
|
||||
map.put(EntityLightning.class, new RenderLightning(mgr));
|
||||
models.put(ModelType.HUMANOID, new RenderHumanoid(mgr, 12, 12, "textures/entity/char.png"));
|
||||
models.put(ModelType.ARACHNOID, new RenderArachnoid(mgr));
|
||||
|
|
|
@ -576,6 +576,8 @@ public class ClientPlayer implements IClientPlayer
|
|||
|
||||
if (packetIn.getHeldItemHotbarIndex() >= 0 && packetIn.getHeldItemHotbarIndex() < InventoryPlayer.getHotbarSize())
|
||||
{
|
||||
if(this.gm.player.inventory.currentItem != packetIn.getHeldItemHotbarIndex())
|
||||
this.gm.controller.resetUseCooldown();
|
||||
this.gm.player.inventory.currentItem = packetIn.getHeldItemHotbarIndex();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package client.renderer.entity;
|
||||
|
||||
import common.entity.projectile.EntityBullet;
|
||||
|
||||
public class RenderMissile extends RenderBullet {
|
||||
private static final String MISSILE_TEXTURE = "textures/entity/missile.png";
|
||||
|
||||
public RenderMissile(RenderManager renderManagerIn) {
|
||||
super(renderManagerIn);
|
||||
}
|
||||
|
||||
protected String getEntityTexture(EntityBullet entity) {
|
||||
return MISSILE_TEXTURE;
|
||||
}
|
||||
}
|
|
@ -35,6 +35,8 @@ public class PlayerController {
|
|||
private boolean hitting;
|
||||
private int lastSelected;
|
||||
private boolean interacting;
|
||||
private int itemUseCooldown;
|
||||
private int itemUseCooldownMax;
|
||||
|
||||
public PlayerController(Client gm, ClientPlayer handler) {
|
||||
this.gm = gm;
|
||||
|
@ -174,6 +176,8 @@ public class PlayerController {
|
|||
|
||||
public void update() {
|
||||
this.syncItem();
|
||||
if(this.itemUseCooldown > 0)
|
||||
--this.itemUseCooldown;
|
||||
|
||||
if(this.handler.getConnection().isChannelOpen()) {
|
||||
this.handler.getConnection().processReceivedPackets();
|
||||
|
@ -254,8 +258,11 @@ public class PlayerController {
|
|||
|
||||
public boolean sendUseItem(EntityNPC player, World world, ItemStack stack) {
|
||||
this.syncItem();
|
||||
if(this.itemUseCooldown > 0)
|
||||
return false;
|
||||
this.handler.addToSendQueue(new CPacketPlace(player.inventory.getCurrentItem()));
|
||||
int size = stack.getSize();
|
||||
this.itemUseCooldown = this.itemUseCooldownMax = stack.getItem().getUseCooldown(stack, world, player);
|
||||
ItemStack changed = stack.getItem().onItemRightClick(stack, world, player);
|
||||
|
||||
if(changed != stack || changed != null && changed.getSize() != size) {
|
||||
|
@ -310,4 +317,16 @@ public class PlayerController {
|
|||
public boolean isHittingBlock() {
|
||||
return this.hitting;
|
||||
}
|
||||
|
||||
public int getUseCooldown() {
|
||||
return this.itemUseCooldown;
|
||||
}
|
||||
|
||||
public int getUseCooldownMax() {
|
||||
return this.itemUseCooldownMax;
|
||||
}
|
||||
|
||||
public void resetUseCooldown() {
|
||||
this.itemUseCooldown = 0;
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
client/src/main/resources/textures/entity/missile.png
Executable file
BIN
client/src/main/resources/textures/entity/missile.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 192 B |
BIN
client/src/main/resources/textures/items/rocket.png
Executable file
BIN
client/src/main/resources/textures/items/rocket.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
client/src/main/resources/textures/items/rocket_launcher.png
Executable file
BIN
client/src/main/resources/textures/items/rocket_launcher.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
79
common/src/main/java/common/entity/projectile/EntityMissile.java
Executable file
79
common/src/main/java/common/entity/projectile/EntityMissile.java
Executable 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;
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"),
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
5
common/src/main/java/common/inventory/ICfarsfadtfdwgfdgdvgs.java
Executable file
5
common/src/main/java/common/inventory/ICfarsfadtfdwgfdgdvgs.java
Executable file
|
@ -0,0 +1,5 @@
|
|||
package common.inventory;
|
||||
|
||||
public interface ICfarsfadtfdwgfdgdvgs
|
||||
{
|
||||
}
|
|
@ -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_);
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
32
common/src/main/java/common/item/tool/ItemLauncherBase.java
Normal file
32
common/src/main/java/common/item/tool/ItemLauncherBase.java
Normal 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);
|
||||
}
|
||||
}
|
33
common/src/main/java/common/item/tool/ItemRocketLauncher.java
Executable file
33
common/src/main/java/common/item/tool/ItemRocketLauncher.java
Executable 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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
|
|
|
@ -1016,7 +1016,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
}
|
||||
|
||||
public void syncPlayerInventory(EntityNPC player) {
|
||||
player.connection.sendContainerToPlayer(player.inventoryContainer);
|
||||
player.connection.sendContainer(player.inventoryContainer, player.inventoryContainer.getInventory());
|
||||
player.connection.setPlayerHealthUpdated();
|
||||
player.connection.sendPacket(new SPacketHeldItemChange(player.inventory.currentItem));
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import common.inventory.ContainerChest;
|
|||
import common.inventory.ContainerEnchantment;
|
||||
import common.inventory.ContainerEntityInventory;
|
||||
import common.inventory.ContainerMerchant;
|
||||
import common.inventory.ICrafting;
|
||||
import common.inventory.IInventory;
|
||||
import common.inventory.InventoryPlayer;
|
||||
import common.inventory.Slot;
|
||||
|
@ -133,7 +132,7 @@ import server.world.ChunkServer;
|
|||
import server.world.Region;
|
||||
import server.world.WorldServer;
|
||||
|
||||
public class Player extends User implements ICrafting, Executor, IPlayer
|
||||
public class Player extends User implements Executor, IPlayer
|
||||
{
|
||||
private static enum EditAction {
|
||||
SELECT("Auswahlmodus"), COPYPASTE("Kopiermodus"), TRANSFORM("Drehmodus");
|
||||
|
@ -196,6 +195,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
private int lastExperience = -99999999;
|
||||
private int currentWindowId;
|
||||
private int currentFormId;
|
||||
private int itemUseCooldown;
|
||||
|
||||
private int pointedEntity;
|
||||
private BlockPos pointedPosition;
|
||||
|
@ -235,6 +235,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.currentWindowId = 0;
|
||||
this.loadedChunks.clear();
|
||||
// this.destroyedItemsNetCache.clear();
|
||||
this.itemUseCooldown = 0;
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
|
@ -255,6 +256,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
this.respawnPlayer();
|
||||
}
|
||||
}
|
||||
if(this.itemUseCooldown > 0)
|
||||
--this.itemUseCooldown;
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
|
@ -834,38 +837,33 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
|
||||
|
||||
|
||||
public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack)
|
||||
public void sendSlot(Container container, int index, ItemStack stack)
|
||||
{
|
||||
if (!(containerToSend.getSlot(slotInd) instanceof SlotCrafting))
|
||||
if (!(container.getSlot(index) instanceof SlotCrafting))
|
||||
{
|
||||
if (!this.isChangingQuantityOnly)
|
||||
{
|
||||
this.sendPacket(new SPacketSetSlot(containerToSend.windowId, slotInd, stack));
|
||||
this.sendPacket(new SPacketSetSlot(container.windowId, index, stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendContainerToPlayer(Container container)
|
||||
{
|
||||
this.updateCraftingInventory(container, container.getInventory());
|
||||
}
|
||||
|
||||
public void updateCraftingInventory(Container containerToSend, List<ItemStack> itemsList)
|
||||
public void sendContainer(Container container, List<ItemStack> items)
|
||||
{
|
||||
this.sendPacket(new SPacketWindowItems(containerToSend.windowId, itemsList));
|
||||
this.sendPacket(new SPacketWindowItems(container.windowId, items));
|
||||
this.sendPacket(new SPacketSetSlot(-1, -1, this.entity.inventory.getItemStack()));
|
||||
}
|
||||
|
||||
public void sendProgressBarUpdate(Container containerIn, int varToUpdate, int newValue)
|
||||
public void sendProperty(Container container, int variable, int value)
|
||||
{
|
||||
this.sendPacket(new SPacketWindowProperty(containerIn.windowId, varToUpdate, newValue));
|
||||
this.sendPacket(new SPacketWindowProperty(container.windowId, variable, value));
|
||||
}
|
||||
|
||||
public void sendAllWindowProperties(Container p_175173_1_, IInventory p_175173_2_)
|
||||
public void sendProperties(Container container, IInventory inventory)
|
||||
{
|
||||
for (int i = 0; i < p_175173_2_.getFieldCount(); ++i)
|
||||
for (int z = 0; z < inventory.getFieldCount(); z++)
|
||||
{
|
||||
this.sendPacket(new SPacketWindowProperty(p_175173_1_.windowId, i, p_175173_2_.getField(i)));
|
||||
this.sendPacket(new SPacketWindowProperty(container.windowId, z, inventory.getField(z)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1249,29 +1247,19 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
// }
|
||||
}
|
||||
|
||||
public boolean tryUseItem(ItemStack stack)
|
||||
public void tryUseItem(ItemStack stack)
|
||||
{
|
||||
// if(this.onPlayerInteract(false, null)) {
|
||||
// return true;
|
||||
// }
|
||||
if(this.itemUseCooldown > 0)
|
||||
return;
|
||||
int i = stack.getSize();
|
||||
int j = stack.getItemDamage();
|
||||
this.itemUseCooldown = stack.getItem().getUseCooldown(stack, this.entity.worldObj, this.entity);
|
||||
ItemStack itemstack = stack.getItem().onItemRightClick(stack, this.entity.worldObj, this.entity);
|
||||
|
||||
if (itemstack != stack || itemstack != null && (itemstack.getSize() != i || itemstack.getMaxItemUseDuration() > 0 || itemstack.getItemDamage() != j))
|
||||
{
|
||||
this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = itemstack;
|
||||
|
||||
// if (this.creative)
|
||||
// {
|
||||
// itemstack.stackSize = i;
|
||||
//
|
||||
// if (itemstack.isItemStackDamageable())
|
||||
// {
|
||||
// itemstack.setItemDamage(j);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = null;
|
||||
|
@ -1279,14 +1267,8 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
|
||||
if (!this.entity.isUsingItem())
|
||||
{
|
||||
this.sendContainerToPlayer(this.entity.inventoryContainer);
|
||||
this.sendContainer(this.entity.inventoryContainer, this.entity.inventoryContainer.getInventory());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2637,8 +2619,11 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
break;
|
||||
|
||||
case SET_ITEMSLOT:
|
||||
if(packetIn.getAuxData() >= 0 && packetIn.getAuxData() < InventoryPlayer.getHotbarSize())
|
||||
if(packetIn.getAuxData() >= 0 && packetIn.getAuxData() < InventoryPlayer.getHotbarSize()) {
|
||||
if(packetIn.getAuxData() != this.entity.inventory.currentItem)
|
||||
this.itemUseCooldown = 0;
|
||||
this.entity.inventory.currentItem = packetIn.getAuxData();
|
||||
}
|
||||
// else
|
||||
// Log.warn(this.user + " versuchte, einen ungültigen Slot zu wählen");
|
||||
break;
|
||||
|
@ -2886,7 +2871,7 @@ public class Player extends User implements ICrafting, Executor, IPlayer
|
|||
list1.add(((Slot)this.entity.openContainer.inventorySlots.get(j)).getStack());
|
||||
}
|
||||
|
||||
this.updateCraftingInventory(this.entity.openContainer, list1);
|
||||
this.sendContainer(this.entity.openContainer, list1);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue