add explosive items

This commit is contained in:
Sen 2025-08-02 16:32:24 +02:00
parent ad83255833
commit 32d6f15c4a
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
30 changed files with 188 additions and 444 deletions

View file

@ -131,8 +131,14 @@ public abstract class GuiContainer extends Gui
list.add(Color.RED + "Admin-Gegenstand");
if(stack.getItem().isMagnetic())
list.add(Color.LIGHT_GRAY + "Magnetisch");
if(stack.getItem().isFragile())
list.add(Color.YELLOW + "Zerbrechlich");
if(stack.getItem().canBeDyed())
list.add("Farbe: #" + Integer.toHexString(stack.getDyeColor()).toUpperCase());
if(stack.getItem().getExplosive() > 0)
list.add(Color.RED + "Explosiv!" + Color.CRIMSON + " - " + Color.DARK_RED + stack.getItem().getExplosive() + "x");
if(stack.getItem().getFuelAmount() > 0)
list.add("Brennwert: " + stack.getItem().getFuelAmount());
if(stack.isItemEnchanted()) {
for(Entry<Enchantment, Integer> enc : stack.getEnchantments()) {

View file

@ -1191,7 +1191,7 @@ public class ClientPlayer implements IClientPlayer
// flag = true; // guicontainercreative.getSelectedTabIndex() != CheatTab.tabInventory.getIndex();
// }
if (packetIn.getWindowId() == 0 && packetIn.getSlot() >= 36 && packetIn.getSlot() < 45)
if (packetIn.getWindowId() == 0 && packetIn.getSlot() >= 5 + Equipment.ARMOR_SLOTS + 27 && packetIn.getSlot() < 5 + Equipment.ARMOR_SLOTS + 27 + 9)
{
ItemStack itemstack = entityplayer.inventoryContainer.getSlot(packetIn.getSlot()).getStack();

View file

@ -77,7 +77,7 @@ public class LayerArmor implements LayerRenderer<EntityNPC>
this.renderer.bindTexture(tex);
else
Client.CLIENT.getTextureManager().bindTexture(tex);
if (itemarmor.getArmorMaterial().canBeDyed())
if (itemarmor.canBeDyed())
{
int i = itemstack.getDyeColor();
float f = (float)(i >> 16 & 255) / 255.0F;

View file

@ -1025,6 +1025,10 @@ public class Block {
return null;
}
public int getFuelAmount() {
return this.material == Material.WOOD ? 300 : 0;
}
public void getModifiers(Map<Attribute, Float> map) {
}

View file

@ -173,4 +173,8 @@ public class BlockSlab extends Block implements Directional {
}
return false;
}
public int getFuelAmount() {
return this.material == Material.WOOD ? 150 : 0;
}
}

View file

@ -136,4 +136,8 @@ public class BlockSapling extends BlockBush implements IGrowable
public WoodType getWoodType() {
return this.type;
}
public int getFuelAmount() {
return 100;
}
}

View file

@ -0,0 +1,48 @@
package common.block.natural;
import java.util.List;
import common.block.Block;
import common.block.Material;
import common.block.SoundType;
import common.entity.npc.EntityNPC;
import common.item.CheatTab;
import common.item.ItemStack;
import common.util.BlockPos;
import common.util.Clientside;
import common.util.Color;
import common.world.State;
import common.world.World;
public class BlockCompressable extends Block {
private final int fuel;
private final int compLevel;
private final int density;
public BlockCompressable(int fuel, int density) {
super(Material.SOLID);
this.fuel = fuel;
this.compLevel = density;
density = 1;
for(int z = 0; z < this.compLevel; z++) {
density *= 9;
}
this.density = density;
this.setHardness(5.0F).setResistance(10.0F).setSound(SoundType.STONE).setTab(CheatTab.NATURE).setFlammable(5, 5);
}
public int getFuelAmount() {
return this.fuel * this.density;
}
@Clientside
public void getTooltips(ItemStack stack, EntityNPC player, List<String> tooltip) {
if(this.compLevel > 0)
tooltip.add(Color.YELLOW + "" + this.compLevel + "-Fach komprimiert");
}
@Clientside
public String getInfo(World world, BlockPos pos, State state, EntityNPC player) {
return this.compLevel > 0 ? Color.YELLOW + "" + this.compLevel + "-Fach komprimiert (x" + this.density + ")" : null;
}
}

View file

@ -65,13 +65,15 @@ public class EntityItem extends Entity
public void fall(float distance, float damageMultiplier)
{
if(!this.worldObj.client && Vars.itemFallDamage && distance >= 1.0f && this.getEntityItem().getItem().isFragile()) {
if(!this.worldObj.client && ((Vars.itemFallDamage && distance >= 1.0f && this.getEntityItem().getItem().isFragile()) || (Vars.itemExplosion && distance >= 2.0f && this.getEntityItem().getItem().getExplosive() > 0))) {
for(int z = 0; z < 8; z++) {
((AWorldServer)this.worldObj).spawnParticles(ParticleType.ITEM_CRACK, this.posX + this.rand.drange(-0.15, 0.15), this.posY + 0.15, this.posZ + this.rand.drange(-0.15, 0.15),
ItemRegistry.getId(this.getEntityItem().getItem()));
}
this.worldObj.playEffect(1023, this.getPosition(), 0);
this.setDead();
if(Vars.itemExplosion && distance >= 2.0f && this.getEntityItem().getItem().getExplosive() > 0 && !this.getEntityItem().isEmpty())
this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, (float)this.getEntityItem().getItem().getExplosive() * (1.0f + (float)(this.getEntityItem().getSize() - 1) / 24.0f), true, true, true);
this.setDead();
}
}

View file

@ -1290,65 +1290,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
}
}
// public boolean setSlot(int slot, ItemStack stack) {
// int i;
//
// if(slot == 99) {
// i = 0;
// }
// else {
// i = slot - 100 + 1;
//
// if(i < 0 || i >= this.equipment.length) {
//// return false;
// i = slot - 300;
//
// if (i >= 0 && i < this.extraInventory.getSizeInventory())
// {
// this.extraInventory.setInventorySlotContents(i, stack);
// return true;
// }
// else
// {
// return false;
// }
// }
// }
//
// if(stack != null && ItemArmor.getArmorPosition(stack) != i && (i != 4 || !(stack.getItem() instanceof ItemBlock))) {
// return false;
// }
// else {
// this.setItem(i, stack);
// return true;
// }
// }
// public boolean setSlot(int slot, ItemStack stack)
// {
// if (super.setSlot(slot, stack))
// {
// return true;
// }
// else
// {
// int i = slot - 300;
//
// if (i >= 0 && i < this.extraInventory.getSizeInventory())
// {
// this.extraInventory.setInventorySlotContents(i, stack);
// return true;
// }
// else
// {
// return false;
// }
// }
// }
protected void updateEquipmentIfNeeded(EntityItem itemEntity) {
ItemStack stack = itemEntity.getEntityItem();
if(stack.getItem().getRadiation(stack) > 0.0f)
@ -1356,73 +1297,61 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
Equipment[] slots = stack.getItem() instanceof ItemArmor armor ? armor.getArmorType().getPossibleSlots() : new Equipment[] {null};
for(Equipment slot : slots) {
boolean flag = true;
boolean accept = true;
ItemStack old = slot == null ? this.getHeldItem() : this.getArmor(slot);
if(old != null) {
if(slot == null) {
if(stack.getItem() instanceof ItemTool t1 && t1.getToolType().isWeapon() && !(old.getItem() instanceof ItemTool t2 && t2.getToolType().isWeapon())) {
flag = true;
accept = true;
}
else if(stack.getItem() instanceof ItemTool itemsword && itemsword.getToolType().isWeapon() && old.getItem() instanceof ItemTool itemsword1 && itemsword1.getToolType().isWeapon()) {
if(itemsword.getAttackDamageBonus(stack) != itemsword1.getAttackDamageBonus(old)) {
flag = itemsword.getAttackDamageBonus(stack) > itemsword1.getAttackDamageBonus(old);
accept = itemsword.getAttackDamageBonus(stack) > itemsword1.getAttackDamageBonus(old);
}
else {
flag = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted();
accept = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted();
}
}
else if(stack.getItem() instanceof ItemBow && old.getItem() instanceof ItemBow) {
flag = stack.isItemEnchanted() && !old.isItemEnchanted();
accept = stack.isItemEnchanted() && !old.isItemEnchanted();
}
else if(stack.getItem() instanceof ItemGunBase && !(old.getItem() instanceof ItemBow)) {
flag = true;
accept = true;
}
else if(stack.getItem() instanceof ItemBow && !(old.getItem() instanceof ItemBow) && !(old.getItem() instanceof ItemTool tool && tool.getToolType().isWeapon())) {
flag = true;
accept = true;
}
else {
flag = false;
accept = false;
}
}
else if(stack.getItem() instanceof ItemArmor && !(old.getItem() instanceof ItemArmor)) {
flag = true;
accept = true;
}
else if(stack.getItem() instanceof ItemArmor && old.getItem() instanceof ItemArmor) {
ItemArmor itemarmor = (ItemArmor)stack.getItem();
ItemArmor itemarmor1 = (ItemArmor)old.getItem();
if(itemarmor.getArmorValue() != itemarmor1.getArmorValue()) {
flag = itemarmor.getArmorValue() > itemarmor1.getArmorValue();
accept = itemarmor.getArmorValue() > itemarmor1.getArmorValue();
}
else {
flag = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted();
accept = stack.getItemDamage() > old.getItemDamage() || stack.isItemEnchanted() && !old.isItemEnchanted();
}
}
else {
flag = false;
accept = false;
}
}
if(flag) { // && this.canPickUpItem(stack)) {
if(old != null) { // && this.rand.floatv() - 0.1F < this.dropChances[slot]) {
if(accept) {
if(old != null)
this.entityDropItem(old, 0.0F);
}
// if(stack.getItem() == Items.diamond && itemEntity.getThrower() != null) {
// EntityNPC entityplayer = this.worldObj.getPlayer(itemEntity.getThrower());
//
// if(entityplayer != null) {
// entityplayer.triggerAchievement(AchievementList.diamondsToYou);
// }
// }
if(slot == null)
this.setHeldItem(stack);
else
this.setArmor(slot, stack);
// this.dropChances[slot] = 2.0F;
// this.noDespawn = true;
this.onItemPickup(itemEntity, 1);
itemEntity.setDead();
break;
@ -1449,218 +1378,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
}
}
// protected void dropEquipment(boolean wasRecentlyHit, int lootingModifier) {
// for(int i = 0; i < this.getInventory().length; ++i) {
// ItemStack itemstack = this.getItem(i);
// boolean flag = this.dropChances[i] > 1.0F;
//
// if(itemstack != null && (wasRecentlyHit || flag) && this.rand.floatv() - (float)lootingModifier * 0.01F < this.dropChances[i]) {
// if(!flag && itemstack.isItemStackDamageable()) {
// int j = Math.max(itemstack.getMaxDamage() - 25, 1);
// int k = itemstack.getMaxDamage() - this.rand.zrange(this.rand.roll(j));
//
// if(k > j) {
// k = j;
// }
//
// if(k < 1) {
// k = 1;
// }
//
// itemstack.setItemDamage(k);
// }
//
// this.entityDropItem(itemstack, 0.0F);
// }
// }
// }
// protected boolean canPickUpItem(ItemStack stack) {
// return true;
// }
//
// public boolean canPickUpLoot() {
// return this.canPickUpLoot;
// }
//
// public void setCanPickUpLoot(boolean canPickup) {
// this.canPickUpLoot = canPickup;
// }
// protected void dropFewItems(boolean wasRecentlyHit, int lootingModifier) {
// }
// public static Item getArmorItemForSlot(int armorSlot, int itemTier) {
// switch(armorSlot)
// {
// case 4:
// if(itemTier == 0) {
// return Items.leather_helmet;
// }
// else if(itemTier == 1) {
// return Items.gold_helmet;
// }
// else if(itemTier == 2) {
// return Items.chain_helmet;
// }
// else if(itemTier == 3) {
// return Items.iron_helmet;
// }
// else if(itemTier == 4) {
// return Items.diamond_helmet;
// }
//
// case 3:
// if(itemTier == 0) {
// return Items.leather_chestplate;
// }
// else if(itemTier == 1) {
// return Items.gold_chestplate;
// }
// else if(itemTier == 2) {
// return Items.chain_chestplate;
// }
// else if(itemTier == 3) {
// return Items.iron_chestplate;
// }
// else if(itemTier == 4) {
// return Items.diamond_chestplate;
// }
//
// case 2:
// if(itemTier == 0) {
// return Items.leather_leggings;
// }
// else if(itemTier == 1) {
// return Items.gold_leggings;
// }
// else if(itemTier == 2) {
// return Items.chain_leggings;
// }
// else if(itemTier == 3) {
// return Items.iron_leggings;
// }
// else if(itemTier == 4) {
// return Items.diamond_leggings;
// }
//
// case 1:
// if(itemTier == 0) {
// return Items.leather_boots;
// }
// else if(itemTier == 1) {
// return Items.gold_boots;
// }
// else if(itemTier == 2) {
// return Items.chain_boots;
// }
// else if(itemTier == 3) {
// return Items.iron_boots;
// }
// else if(itemTier == 4) {
// return Items.diamond_boots;
// }
//
// default:
// return null;
// }
// }
// public ItemStack getHeldItem() {
// return ;
// }
// public ItemStack getItem(int slot) {
// return ;
// }
// public ItemStack getArmor(int slot) {
// return ;
// }
// public void setItem(int slot, ItemStack stack) {
// this.equipment[slot] = stack;
// }
// public void setItem(int slot, ItemStack stack)
// {
//// super.setItem(slot, stack);
// }
// public void setItemNoUpdate(int slot, ItemStack stack)
// {
// }
// public ItemStack[] getInventory() {
// return ;
// }
// public int getTrackingRange() {
// return 80;
// }
// public int getUpdateFrequency() {
// return 3;
// }
// public boolean isSendingVeloUpdates() {
// return true;
// }
// protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) {
// if(this.rand.floatv() < 0.15F * difficulty.getDifficulty()) {
// int i = this.rand.zrange(2);
//// float f = this.worldObj.getDifficulty() == Difficulty.HARD ? 0.1F : 0.25F;
// float f = 0.1F;
//
// if(this.rand.floatv() < 0.095F) {
// ++i;
// }
//
// if(this.rand.floatv() < 0.095F) {
// ++i;
// }
//
// if(this.rand.floatv() < 0.095F) {
// ++i;
// }
//
// for(int j = 3; j >= 0; --j) {
// ItemStack itemstack = this.getArmor(j);
//
// if(j < 3 && this.rand.floatv() < f) {
// break;
// }
//
// if(itemstack == null) {
// Item item = getArmorItemForSlot(j + 1, i);
//
// if(item != null) {
// this.setItem(j + 1, new ItemStack(item));
// }
// }
// }
// }
// }
// protected void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty) {
// float f = difficulty.getDifficulty();
//
// if(this.getHeldItem() != null && this.rand.floatv() < 0.25F * f) {
// EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItem(), (int)(5.0F + f * (float)this.rand.zrange(18)));
// }
//
// for(int i = 0; i < 4; ++i) {
// ItemStack itemstack = this.getArmor(i);
//
// if(itemstack != null && this.rand.floatv() < 0.5F * f) {
// EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.zrange(18)));
// }
// }
// }
public boolean useMana(int pts) {
int mana = this.getManaPoints();
if(mana >= pts)
@ -1764,14 +1481,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
}
}
// protected void sendDeathMessage() {
// this.sendDeathMessage(false, true);
// }
// protected boolean canRegenerateHealth() {
// return false;
// }
protected boolean shouldHeal() {
return this.canRegenerateHealth() && Vars.healChance > 0 && this.getHealth() > 0 && this.getHealth() < this.getMaxHealth()
&& this.rand.chance(Vars.healChance);
@ -2667,17 +2376,6 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
this.client.addToSendQueue(new CPacketAction(CPacketAction.Action.PERFORM_RESPAWN));
}
// public void closeScreenAndDropStack()
// {
// this.inventory.setItemStack((ItemStack)null);
// this.openContainer = this.inventoryContainer;
//// super.closeScreen();
// this.gm.displayGuiScreen(null);
// }
/**
* Updates health locally.
*/
public void setPlayerSPHealth(int health)
{
if (this.hasValidHealth)
@ -3494,7 +3192,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
*/
public float getToolDigEfficiency(Block block)
{
float f = this.getHeldItem() != null && this.getHeldItem().getItem() instanceof ItemTool tool && block.getMiningTool() == tool.getToolType() ? tool.getToolMaterial().getEfficiency() : 1.0f;
float f = this.getHeldItem() != null && this.getHeldItem().getItem() instanceof ItemTool tool && block.getMiningTool() == tool.getToolType() ? tool.getToolEfficiency() : 1.0f;
if (f > 1.0F)
{
@ -3548,7 +3246,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
{
if(!block.getMaterial().isToolRequired())
return true;
return this.getHeldItem() != null && this.getHeldItem().getItem() instanceof ItemTool tool && block.getMiningTool() == tool.getToolType() && (!tool.getToolType().isLevelled() || tool.getToolMaterial().getHarvestLevel() >= block.getMiningLevel());
return this.getHeldItem() != null && this.getHeldItem().getItem() instanceof ItemTool tool && block.getMiningTool() == tool.getToolType() && (!tool.getToolType().isLevelled() || tool.getToolLevel() >= block.getMiningLevel());
}
public int getAttackDamage() {

View file

@ -70,6 +70,7 @@ import common.block.natural.BlockBedrock;
import common.block.natural.BlockBlackenedDirt;
import common.block.natural.BlockBlackenedStone;
import common.block.natural.BlockClay;
import common.block.natural.BlockCompressable;
import common.block.natural.BlockColoredClay;
import common.block.natural.BlockFire;
import common.block.natural.BlockGlowstone;
@ -270,8 +271,9 @@ public abstract class BlockRegistry {
register(color.getName() + "_clay", (new BlockColoredClay(color)).setHardness(1.25F).setResistance(7.0F)
.setSound(SoundType.STONE).setDisplay(color.getDisplay() + " gefärbter Ton"));
}
register("coal_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F)
.setSound(SoundType.STONE).setDisplay("Kohleblock").setTab(CheatTab.NATURE).setFlammable(5, 5));
register("coal_block", new BlockCompressable(16000, 0).setDisplay("Kohleblock"));
register("dense_coal_block", new BlockCompressable(16000, 1).setDisplay("Verdichteter Kohleblock"));
register("very_dense_coal_block", new BlockCompressable(16000, 2).setDisplay("Zweifach verdichteter Kohleblock"));
register("sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setSound(SoundType.SAND).setDisplay("Sand").setMiningTool(Equipment.SHOVEL).setTab(CheatTab.NATURE));
register("red_sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setSound(SoundType.SAND).setDisplay("Roter Sand").setMiningTool(Equipment.SHOVEL).setTab(CheatTab.NATURE));
register("gravel", (new BlockGravel()).setHardness(0.6F).setSound(SoundType.GRAVEL).setDisplay("Kies").setMiningTool(Equipment.SHOVEL));

View file

@ -153,7 +153,9 @@ public abstract class Blocks {
public static final Block cinnabar_block = get("cinnabar_block");
public static final BlockOre cinnabar_ore = get("cinnabar_ore");
public static final BlockClay clay = get("clay");
public static final Block coal_block = get("coal_block");
public static final BlockCompressable coal_block = get("coal_block");
public static final BlockCompressable dense_coal_block = get("dense_coal_block");
public static final BlockCompressable very_dense_coal_block = get("very_dense_coal_block");
public static final BlockOre coal_ore = get("coal_ore");
public static final Block coarse_dirt = get("coarse_dirt");
public static final BlockMetalBlock cobalt_block = get("cobalt_block");

View file

@ -159,7 +159,7 @@ public abstract class ItemRegistry {
"_bucket", new ItemBucket(liquid.second(), true));
}
register("boat", (new ItemBoat()).setDisplay("Boot"));
register("boat", (new ItemBoat()).setDisplay("Boot").setFuelAmount(800));
register("minecart", (new ItemMinecart()).setDisplay("Lore"));
for(EntityInfo egg : EntityRegistry.DNA.values()) {
register("dna_sample_" + egg.id().toLowerCase(), (new ItemMobTemplate(egg.id()))
@ -206,14 +206,14 @@ public abstract class ItemRegistry {
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("rocket", (new ItemAmmo(6, 6.0f, StackSize.L)).setDisplay("Rakete").setExplosive(4));
register("arrow", (new ItemArrow()).setDisplay("Pfeil").setTab(CheatTab.WEAPONS).setMaxAmount(StackSize.L));
Item coal = (new Item()).setDisplay("Kohle").setTab(CheatTab.METALS);
Item coal = (new Item()).setDisplay("Kohle").setTab(CheatTab.METALS).setFuelAmount(1600);
register("coal", coal);
register("charcoal", (new Item()).setDisplay("Holzkohle").setTab(CheatTab.METALS));
register("stick", (new Item()).setDisplay("Stock").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
register("charcoal", (new Item()).setDisplay("Holzkohle").setTab(CheatTab.METALS).setFuelAmount(1200));
register("stick", (new Item()).setDisplay("Stock").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setFuelAmount(100));
register("feather", (new Item()).setDisplay("Feder").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XXL));
register("gunpowder", (new Item()).setDisplay("Schwarzpulver").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
register("gunpowder", (new Item()).setDisplay("Schwarzpulver").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setExplosive(1));
register("wheat", (new Item()).setDisplay("Weizen").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.L));
register("bread", (new ItemFood(5, false)).setDisplay("Brot"));
register("flint", (new Item()).setDisplay("Feuerstein").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.L));
@ -222,21 +222,21 @@ public abstract class ItemRegistry {
register("golden_apple", (new ItemAppleGold(4, false)).setPotionEffect(Effect.REGENERATION, 5, 1, 1.0F)
.setDisplay("Goldener Apfel"));
register("charged_apple", (new ItemAppleGold(4, true)).setPotionEffect(Effect.REGENERATION, 5, 1, 1.0F)
.setDisplay("Geladener Apfel"));
.setDisplay("Geladener Apfel").setExplosive(3));
register("saddle", (new ItemSaddle()).setDisplay("Sattel"));
register("snowball", (new ItemSnowball()).setDisplay("Schneeball").setMaxAmount(StackSize.L));
register("leather", (new Item()).setDisplay("Leder").setTab(CheatTab.MATERIALS));
register("brick", (new Item()).setDisplay("Ziegel").setTab(CheatTab.MATERIALS));
register("clay_lump", (new Item()).setDisplay("Ton").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.L));
register("paper", (new Item()).setDisplay("Papier").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setDefaultColor(0xffffff));
register("book", (new ItemBook()).setDisplay("Buch").setTab(CheatTab.MATERIALS));
register("paper", (new Item()).setDisplay("Papier").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setDefaultColor(0xffffff).setFuelAmount(40));
register("book", (new ItemBook()).setDisplay("Buch").setTab(CheatTab.MATERIALS).setFuelAmount(60));
register("slime_blob", (new Item()).setDisplay("Schleim").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.L));
register("egg", (new ItemEgg()).setDisplay("Ei").setMaxAmount(StackSize.L));
register("navigator", (new ItemSpaceNavigator()).setDisplay("Elektronischer Navigator").setTab(CheatTab.TOOLS));
register("exterminator", (new ItemExterminator()).setDisplay("Weltenzerstörer"));
register("fishing_rod", (new ItemFishingRod()).setDisplay("Angel"));
register("glowing_powder", (new Item()).setDisplay("Glühender Staub")
.setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
.setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setFuelAmount(600));
for(ItemFishFood.FishType type : ItemFishFood.FishType.values()) {
register(type.getName(), (new ItemFishFood(false, type)));
register("cooked_" + type.getName(), (new ItemFishFood(true, type)));
@ -254,7 +254,7 @@ public abstract class ItemRegistry {
register("cooked_chicken", (new ItemFood(6, true)).setDisplay("Gebratenes Hühnchen"));
register("rotten_flesh", (new ItemFood(4, true)).setDisplay("Verrottetes Fleisch"));
register("orb", (new Item()).setDisplay("Kugel").setTab(CheatTab.MAGIC).setFragile());
register("demon_rod", (new Item()).setDisplay("Dämonenrute").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
register("demon_rod", (new Item()).setDisplay("Dämonenrute").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setFuelAmount(2400));
register("gold_coin", (new Item()).setDisplay("Goldmünze").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
register("gold_nugget", (new Item()).setDisplay("Goldnugget").setTab(CheatTab.METALS).setMaxAmount(StackSize.XL));
Item bottle;
@ -269,9 +269,9 @@ public abstract class ItemRegistry {
register("eye", (new ItemFood(2, false)).setPotionEffect(Effect.POISON, 5, 0, 1.0F).setDisplay("Auge")
.setMaxAmount(StackSize.L));
register("blazing_powder", (new Item()).setDisplay("Schillernder Staub")
.setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
.setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL).setFuelAmount(600));
register("charged_orb", (new ItemChargedOrb()).setDisplay("Geladene Kugel"));
register("fireball", (new ItemFireball()).setDisplay("Feuerkugel"));
register("fireball", (new ItemFireball()).setDisplay("Feuerkugel").setFuelAmount(1000));
Item emerald = (new Item()).setDisplay("Smaragd").setTab(CheatTab.METALS);
register("emerald", emerald);
register("cocoa_powder", new Item().setTab(CheatTab.MATERIALS).setDisplay("Gemahlene Kakaobohnen").setMaxAmount(StackSize.L));
@ -289,7 +289,7 @@ public abstract class ItemRegistry {
register("melon_seed", new ItemSeeds(Blocks.melon_stem, Blocks.farmland).setDisplay("Melonenkerne").setMaxAmount(StackSize.XL));
register("whip", (new ItemWhip()).setDisplay("Peitsche"));
register("charge_crystal", (new Item()).setDisplay("Energiekristall").setTab(CheatTab.MATERIALS).setColor(Color.DARK_MAGENTA).setGleaming());
register("charge_crystal", (new Item()).setDisplay("Energiekristall").setTab(CheatTab.MATERIALS).setColor(Color.DARK_MAGENTA).setGleaming().setFuelAmount(120000));
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();
@ -310,7 +310,7 @@ public abstract class ItemRegistry {
register("dynamite" + (z == 0 ? "" : ("_" + z)), (new ItemDynamite(z)).setDisplay("Dynamit" + Util.getTierSuffix(z)).setColor(Color.RED));
}
register("chain", (new Item()).setDisplay("Kette").setTab(CheatTab.MATERIALS).setMagnetic());
Item chargedPowder = (new Item()).setDisplay("Geladener Staub").setTab(CheatTab.METALS).setMagnetic();
Item chargedPowder = (new Item()).setDisplay("Geladener Staub").setTab(CheatTab.METALS).setMagnetic().setExplosive(2);
register("charged_powder", chargedPowder);
for(OreType ore : OreType.values()) {

View file

@ -252,6 +252,8 @@ public abstract class Items {
public static final ItemArmor cloth_leggings = get("cloth_leggings");
public static final Item coal = get("coal");
public static final Item coal_block = get("coal_block");
public static final Item dense_coal_block = get("dense_coal_block");
public static final Item very_dense_coal_block = get("very_dense_coal_block");
public static final Item coal_ore = get("coal_ore");
public static final Item coarse_dirt = get("coarse_dirt");
public static final Item cobalt_block = get("cobalt_block");

View file

@ -35,6 +35,8 @@ public class Item {
private CheatTab tab;
private Color color = null;
private int defColor = 0xffffffff;
private int fuelAmount = 0;
private int explosive = 0;
private boolean magnetic = false;
private boolean gleaming = false;
private boolean fragile = false;
@ -53,6 +55,8 @@ public class Item {
this.setMaxAmount(this.block.getMaxAmount());
if(this.block.getItemColor() != null)
this.setColor(this.block.getItemColor());
if(this.block.getFuelAmount() > 0)
this.setFuelAmount(this.block.getFuelAmount());
}
public final Item setUnstackable() {
@ -108,6 +112,17 @@ public class Item {
return this;
}
public final Item setFuelAmount(int amount) {
this.fuelAmount = amount;
return this;
}
public final Item setExplosive(int amount) {
this.fuelAmount = 1200 * amount;
this.explosive = amount;
return this;
}
public final Block getBlock() {
return this.block;
}
@ -124,6 +139,14 @@ public class Item {
return this.maxDamage > 0;
}
public final int getFuelAmount() {
return this.fuelAmount;
}
public final int getExplosive() {
return this.explosive;
}
public final String getDisplay() {
return this.display;
}

View file

@ -76,6 +76,7 @@ public class ItemPotion extends Item
this.setTab(CheatTab.POTIONS);
this.setColor(Color.ORK);
this.setDisplay(getDisplay(this));
this.setFragile();
if(this.effect != null)
this.setGleaming();
POTIONS.add(this);

View file

@ -31,10 +31,6 @@ public class ItemAnimalArmor extends Item {
return this.type;
}
public ToolMaterial getArmorMaterial() {
return this.material;
}
public int getArmorValue() {
return this.material.getDamageReduction(Equipment.CHESTPLATE);
}

View file

@ -52,10 +52,6 @@ public class ItemArmor extends Item {
return this.type;
}
public ToolMaterial getArmorMaterial() {
return this.material;
}
public int getArmorValue() {
return this.material.getDamageReduction(this.type);
}

View file

@ -125,6 +125,8 @@ public class ItemBucket extends Item
this.recursive = recursive;
this.setTab(liquid == null ? CheatTab.TOOLS : CheatTab.LIQUIDS);
this.setMagnetic();
if(this.liquid != null && this.liquid.getMaterial().isHotLiquid())
this.setFuelAmount(20000);
if(liquid != null && !recursive) {
MAPPING.put(liquid, this);
MAPPING.put(liquid.getStaticBlock(), this);

View file

@ -27,6 +27,7 @@ public class ItemEnchantedBook extends Item
public ItemEnchantedBook(Enchantment enchantment, int level) {
this.setColor(Color.YELLOW);
this.setGleaming();
this.setFuelAmount(80);
this.enchantment = enchantment;
this.level = level;
BOOKS.add(this);

View file

@ -16,8 +16,10 @@ public class ItemMetal extends Item {
public ItemMetal(MetalType metal) {
this.metal = metal;
if(this.metal.radioactivity > 0.0f)
if(this.metal.radioactivity > 0.0f) {
this.setColor(Color.GREEN);
this.setExplosive(1);
}
if(this.metal.isMagnetic())
this.setMagnetic();
}

View file

@ -7,6 +7,7 @@ import common.util.Clientside;
public class ItemRecord extends Item {
public ItemRecord() {
this.setTab(CheatTab.MISC);
this.setFuelAmount(40);
}
@Clientside

View file

@ -27,6 +27,7 @@ public class ItemDynamite extends Item {
public ItemDynamite(int power) {
this.power = power;
this.setTab(CheatTab.EXPLOSIVES);
this.setExplosive(this.power + 1);
DYNAMITE[power] = this;
}

View file

@ -7,6 +7,7 @@ import common.enchantment.EnchantmentHelper;
import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.ToolMaterial;
import common.init.ToolType;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemAction;
@ -29,13 +30,15 @@ public class ItemTool extends Item {
this.setTab(this.type.isWeapon() ? CheatTab.WEAPONS : CheatTab.TOOLS);
if(this.material.isMagnetic())
this.setMagnetic();
if(this.material == ToolType.WOOD.material)
this.setFuelAmount(200);
}
@Clientside
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
{
if(this.type.isLevelled())
tooltip.add(Color.VIOLET + "Level " + (this.getToolMaterial().getHarvestLevel() + 1));
tooltip.add(Color.VIOLET + "Level " + (this.material.getHarvestLevel() + 1));
tooltip.add(Color.DARK_GREEN + "+" + (this.material.getEfficiency() - 1) + " Abbaueffizienz");
int damage = this.getAttackDamageBonus(stack);
if(damage > 0)
@ -57,14 +60,18 @@ public class ItemTool extends Item {
return true;
}
public ToolMaterial getToolMaterial() {
return this.material;
}
public Equipment getToolType() {
return this.type;
}
public int getToolLevel() {
return this.material.getHarvestLevel();
}
public int getToolEfficiency() {
return this.material.getEfficiency();
}
public int getItemEnchantability() {
return this.material.getEnchantability();
}

View file

@ -200,6 +200,7 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
}
public void detonate() {
this.worldObj.setBlockToAir(getPos());
this.worldObj.newExplosion(null, this.getXPos(), this.getYPos(), this.getZPos(), 5.0f, true, true, false);
}
@ -286,18 +287,6 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
return true;
}
public double getXPos() {
return (double)this.pos.getX() + 0.5D;
}
public double getYPos() {
return (double)this.pos.getY() + 0.5D;
}
public double getZPos() {
return (double)this.pos.getZ() + 0.5D;
}
public int getField(int id) {
return 0;
}

View file

@ -112,11 +112,23 @@ public abstract class TileEntity
return 4096.0D;
}
public BlockPos getPos()
public final BlockPos getPos()
{
return this.pos;
}
public final double getXPos() {
return (double)this.pos.getX() + 0.5D;
}
public final double getYPos() {
return (double)this.pos.getY() + 0.5D;
}
public final double getZPos() {
return (double)this.pos.getZ() + 0.5D;
}
/**
* Gets the block type at the location of this entity (client-only).
*/

View file

@ -24,6 +24,7 @@ import common.tags.TagObject;
import java.util.List;
import common.util.ExtMath;
import common.util.Facing;
import common.vars.Vars;
public class TileEntityFurnace extends TileEntityInventory implements ITickable, ISidedInventory
{
@ -224,7 +225,13 @@ public class TileEntityFurnace extends TileEntityInventory implements ITickable,
if (this.furnaceItemStacks[1] != null)
{
if (this.furnaceItemStacks[1].decrSize())
if(Vars.itemExplosion && this.furnaceItemStacks[1].getItem().getExplosive() > 0 && !this.furnaceItemStacks[1].isEmpty()) {
this.worldObj.setBlockToAir(getPos());
this.worldObj.newExplosion(null, this.getXPos(), this.getYPos(), this.getZPos(), (float)this.furnaceItemStacks[1].getItem().getExplosive() * (1.0f + (float)(this.furnaceItemStacks[1].getSize() - 1) / 24.0f), true, true, true);
this.furnaceItemStacks[1] = null;
return;
}
else if (this.furnaceItemStacks[1].decrSize())
{
Item item = this.furnaceItemStacks[1].getItem().getContainerItem();
this.furnaceItemStacks[1] = item != null ? new ItemStack(item) : null;
@ -319,59 +326,14 @@ public class TileEntityFurnace extends TileEntityInventory implements ITickable,
}
}
/**
* Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
* fuel
*/
public static int getItemBurnTime(ItemStack p_145952_0_) // TODO: fuelreg!!
public static int getItemBurnTime(ItemStack stack)
{
if (p_145952_0_ == null)
{
return 0;
}
else
{
Item item = p_145952_0_.getItem();
if (item.getBlock() != null) // Blocks.air)
{
Block block = item.getBlock();
// if (block instanceof BlockVerticalSlab && )
// {
// return 150;
// }
if (block.getMaterial() == Material.WOOD)
{
return block instanceof BlockSlab ? 150 : 300;
}
else if (block == Blocks.coal_block)
{
return 16000;
}
else if (block instanceof BlockSapling)
{
return 100;
}
}
return item instanceof ItemTool && ((ItemTool)item).getToolMaterial() == ToolType.WOOD.material ? 200 :
(item == Items.hoe ? 200 :
(item == Items.stick ? 100 :
(item == Items.coal ? 1600 :
(item == Items.charcoal ? 1200 :
(item instanceof ItemBucket && ((ItemBucket)item).getLiquid() != null &&
((ItemBucket)item).getLiquid().getMaterial() == Material.LAVA ? 20000 :
(item == Items.demon_rod ? 2400 : 0))))));
}
return stack != null ? stack.getItem().getFuelAmount() : 0;
}
public static boolean isItemFuel(ItemStack p_145954_0_)
public static boolean isItemFuel(ItemStack stack)
{
return getItemBurnTime(p_145954_0_) > 0;
return getItemBurnTime(stack) > 0;
}
/**

View file

@ -662,30 +662,6 @@ public class TileEntityHopper extends TileEntityInventory implements ITickable
return stack1.getItem() != stack2.getItem() ? false : (stack1.isOverLimit() ? false : ItemStack.dataEquals(stack1, stack2));
}
/**
* Gets the world X position for this hopper entity.
*/
public double getXPos()
{
return (double)this.pos.getX() + 0.5D;
}
/**
* Gets the world Y position for this hopper entity.
*/
public double getYPos()
{
return (double)this.pos.getY() + 0.5D;
}
/**
* Gets the world Z position for this hopper entity.
*/
public double getZPos()
{
return (double)this.pos.getZ() + 0.5D;
}
public void setTransferCooldown(int ticks)
{
this.transferCooldown = ticks;

View file

@ -187,7 +187,7 @@ public enum Equipment implements Identifyable, Displayable {
}
public Equipment[] getPossibleSlots() {
return this.isRing() ? new Equipment[] {RING_LEFT_A, RING_LEFT_B, RING_RIGHT_A, RING_RIGHT_B} : new Equipment[] {this};
return this.isRing() ? new Equipment[] {RING_LEFT_A, RING_LEFT_B, RING_RIGHT_A, RING_RIGHT_B} : new Equipment[] {this.isArmor() ? this : null};
}
public boolean canUseInSlot(Equipment slot) {

View file

@ -189,6 +189,8 @@ public abstract class Vars {
public static boolean loaders = true;
@Var(name = "fragileItems")
public static boolean itemFallDamage = true;
@Var(name = "explosiveItems")
public static boolean itemExplosion = true;
@Var(name = "signEditing")
public static boolean editSigns = true;
@Var(name = "daylightCycle")

View file

@ -116,6 +116,7 @@ import common.util.IntHashMap;
import common.util.PortalType;
import common.util.Position;
import common.util.Color;
import common.util.Equipment;
import common.util.Vec3i;
import common.util.WorldPos;
import common.vars.Vars;
@ -1958,7 +1959,7 @@ public class Player extends User implements Executor, IPlayer
if(msg.length() > 30)
throw new IllegalArgumentException("Ungültiger Name");
if(packetIn.getArg() == -1)
this.entity.inventoryContainer.renameItem(36 + this.entity.getSelectedIndex(), msg);
this.entity.inventoryContainer.renameItem(5 + Equipment.ARMOR_SLOTS + 27 + this.entity.getSelectedIndex(), msg);
else
this.entity.openContainer.renameItem(packetIn.getArg(), msg);
this.entity.openContainer.detectAndSendChanges();
@ -2898,7 +2899,7 @@ public class Player extends User implements Executor, IPlayer
this.entity.dropItem(stack, false, true);
}
else {
Slot slot = packet.getSlot() < 0 ? this.entity.inventoryContainer.getSlot(36 + -2 - packet.getSlot()) : this.entity.openContainer.getSlot(packet.getSlot());
Slot slot = packet.getSlot() < 0 ? this.entity.inventoryContainer.getSlot(5 + Equipment.ARMOR_SLOTS + 27 + -2 - packet.getSlot()) : this.entity.openContainer.getSlot(packet.getSlot());
if(slot == null || !slot.canCheatItem())
return;
stack.setSize(Math.min(slot.getSlotStackLimit(), stack.getSize()));