Firework Box Minecart!

This commit is contained in:
Ellpeck 2016-05-16 17:00:29 +02:00
parent 028accdf3e
commit e20a82a4ad
17 changed files with 337 additions and 49 deletions

View file

@ -18,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler;
import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
import de.ellpeck.actuallyadditions.mod.crafting.InitCrafting; import de.ellpeck.actuallyadditions.mod.crafting.InitCrafting;
import de.ellpeck.actuallyadditions.mod.crafting.ItemCrafting; import de.ellpeck.actuallyadditions.mod.crafting.ItemCrafting;
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
import de.ellpeck.actuallyadditions.mod.event.InitEvents; import de.ellpeck.actuallyadditions.mod.event.InitEvents;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.gen.InitVillager; import de.ellpeck.actuallyadditions.mod.gen.InitVillager;
@ -78,6 +79,7 @@ public class ActuallyAdditions{
PacketHandler.init(); PacketHandler.init();
InitToolMaterials.init(); InitToolMaterials.init();
InitArmorMaterials.init(); InitArmorMaterials.init();
InitEntities.init();
InitBlocks.init(); InitBlocks.init();
InitFluids.init(); InitFluids.init();
InitItems.init(); InitItems.init();
@ -129,8 +131,6 @@ public class ActuallyAdditions{
@EventHandler @EventHandler
public void serverStarting(FMLServerStartingEvent event){ public void serverStarting(FMLServerStartingEvent event){
Util.registerDispenserHandler(InitItems.itemFertilizer, new DispenserHandlerFertilize());
WorldData.init(event.getServer()); WorldData.init(event.getServer());
} }

View file

@ -154,6 +154,7 @@ public class CreativeTab extends CreativeTabs{
this.add(InitItems.itemBatteryQuadruple); this.add(InitItems.itemBatteryQuadruple);
this.add(InitItems.itemBatteryQuintuple); this.add(InitItems.itemBatteryQuintuple);
this.add(InitItems.itemTeleStaff); this.add(InitItems.itemTeleStaff);
this.add(InitItems.itemMinecartFireworkBox);
this.add(InitItems.itemGrowthRing); this.add(InitItems.itemGrowthRing);
this.add(InitItems.itemMagnetRing); this.add(InitItems.itemMagnetRing);

View file

@ -0,0 +1,64 @@
package de.ellpeck.actuallyadditions.mod.entity;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox;
import net.minecraft.block.state.IBlockState;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class EntityFireworkBoxMinecart extends EntityRFMinecart{
private int cooldownTimer;
private boolean isPowered;
public EntityFireworkBoxMinecart(World world){
super(world, 20000, 1000);
}
@Override
public void onActivatorRailPass(int x, int y, int z, boolean receivingPower){
if(receivingPower != this.isPowered){
this.isPowered = receivingPower;
}
}
@Override
public void onUpdate(){
super.onUpdate();
if(!this.worldObj.isRemote){
if(this.cooldownTimer > 0 && this.isPowered){
this.cooldownTimer--;
if(this.cooldownTimer <= 0){
//TODO Check for power level here + make charging possible
TileEntityFireworkBox.spawnFireworks(this.worldObj, this.posX, this.posY, this.posZ);
this.storage.extractEnergy(TileEntityFireworkBox.USE_PER_SHOT, false);
}
}
else{
this.cooldownTimer = 100;
}
}
}
@Override
public IBlockState getDisplayTile(){
return InitBlocks.blockFireworkBox.getDefaultState();
}
@Override
protected void writeEntityToNBT(NBTTagCompound compound){
super.writeEntityToNBT(compound);
compound.setInteger("Cooldown", this.cooldownTimer);
compound.setBoolean("Powered", this.isPowered);
}
@Override
protected void readEntityFromNBT(NBTTagCompound compound){
super.readEntityFromNBT(compound);
this.cooldownTimer = compound.getInteger("Cooldown");
this.isPowered = compound.getBoolean("Powered");
}
}

View file

@ -0,0 +1,36 @@
package de.ellpeck.actuallyadditions.mod.entity;
import cofh.api.energy.EnergyStorage;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class EntityRFMinecart extends EntityMinecart{
public EnergyStorage storage;
public EntityRFMinecart(World world, int rfCap, int maxTransfer){
super(world);
this.storage = new EnergyStorage(rfCap, maxTransfer);
}
@Override
protected void writeEntityToNBT(NBTTagCompound compound){
super.writeEntityToNBT(compound);
this.storage.writeToNBT(compound);
}
@Override
protected void readEntityFromNBT(NBTTagCompound compound){
super.readEntityFromNBT(compound);
this.storage.readFromNBT(compound);
}
@Override
public Type getType(){
return Type.CHEST;
}
}

View file

@ -0,0 +1,18 @@
package de.ellpeck.actuallyadditions.mod.entity;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import java.util.Locale;
public class InitEntities{
public static void init(){
ModUtil.LOGGER.info("Initializing Entities...");
EntityRegistry.registerModEntity(EntityFireworkBoxMinecart.class, ModUtil.MOD_ID+":minecartFireworkBox", 0, ActuallyAdditions.instance, 256, 1, true);
}
}

View file

@ -12,12 +12,8 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA; import de.ellpeck.actuallyadditions.mod.items.base.*;
import de.ellpeck.actuallyadditions.mod.items.base.ItemHoeAA;
import de.ellpeck.actuallyadditions.mod.items.base.ItemSeed;
import de.ellpeck.actuallyadditions.mod.items.base.ItemSwordAA;
import de.ellpeck.actuallyadditions.mod.items.lens.ItemLens; import de.ellpeck.actuallyadditions.mod.items.lens.ItemLens;
import de.ellpeck.actuallyadditions.mod.items.lens.Lenses;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
@ -210,9 +206,12 @@ public class InitItems{
public static Item itemRarmorModuleReconstructor; public static Item itemRarmorModuleReconstructor;
public static Item itemMinecartFireworkBox;
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Initializing Items..."); ModUtil.LOGGER.info("Initializing Items...");
itemMinecartFireworkBox = new ItemFireworkBoxMinecart("itemMinecartFireworkBox");
itemSpawnerChanger = new ItemSpawnerChanger("itemSpawnerChanger"); itemSpawnerChanger = new ItemSpawnerChanger("itemSpawnerChanger");
itemMisc = new ItemMisc("itemMisc"); itemMisc = new ItemMisc("itemMisc");
itemCrateKeeper = new ItemGeneric("itemCrateKeeper"); itemCrateKeeper = new ItemGeneric("itemCrateKeeper");

View file

@ -11,6 +11,8 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.misc.DispenserHandlerFertilize;
import net.minecraft.block.BlockDispenser;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemDye; import net.minecraft.item.ItemDye;
@ -25,6 +27,8 @@ public class ItemFertilizer extends ItemBase{
public ItemFertilizer(String name){ public ItemFertilizer(String name){
super(name); super(name);
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, new DispenserHandlerFertilize());
} }
@Override @Override

View file

@ -0,0 +1,20 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.entity.EntityFireworkBoxMinecart;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.world.World;
public class ItemFireworkBoxMinecart extends ItemMinecartAA{
public ItemFireworkBoxMinecart(String name){
super(name);
}
@Override
public EntityMinecart createCart(World world, double x, double y, double z){
EntityMinecart entity = new EntityFireworkBoxMinecart(world);
entity.setPosition(x, y, z);
return entity;
}
}

View file

@ -0,0 +1,116 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import net.minecraft.block.BlockDispenser;
import net.minecraft.block.BlockRailBase;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBehaviorDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public abstract class ItemMinecartAA extends ItemBase{
private static final IBehaviorDispenseItem MINECART_DISPENSER_BEHAVIOR = new BehaviorDefaultDispenseItem(){
private final BehaviorDefaultDispenseItem behaviourDefaultDispenseItem = new BehaviorDefaultDispenseItem();
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack){
EnumFacing facing = BlockDispenser.getFacing(source.getBlockMetadata());
World world = source.getWorld();
double d0 = source.getX()+(double)facing.getFrontOffsetX()*1.125D;
double d1 = Math.floor(source.getY())+(double)facing.getFrontOffsetY();
double d2 = source.getZ()+(double)facing.getFrontOffsetZ()*1.125D;
BlockPos pos = source.getBlockPos().offset(facing);
IBlockState state = world.getBlockState(pos);
BlockRailBase.EnumRailDirection direction = state.getBlock() instanceof BlockRailBase ? state.getValue(((BlockRailBase)state.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d3;
if(BlockRailBase.isRailBlock(state)){
if(direction.isAscending()){
d3 = 0.6D;
}
else{
d3 = 0.1D;
}
}
else{
if(state.getMaterial() != Material.AIR || !BlockRailBase.isRailBlock(world.getBlockState(pos.down()))){
return this.behaviourDefaultDispenseItem.dispense(source, stack);
}
IBlockState state1 = world.getBlockState(pos.down());
BlockRailBase.EnumRailDirection direction1 = state1.getBlock() instanceof BlockRailBase ? state1.getValue(((BlockRailBase)state1.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
if(facing != EnumFacing.DOWN && direction1.isAscending()){
d3 = -0.4D;
}
else{
d3 = -0.9D;
}
}
EntityMinecart cart = ((ItemMinecartAA)stack.getItem()).createCart(world, d0, d1+d3, d2);
if(stack.hasDisplayName()){
cart.setCustomNameTag(stack.getDisplayName());
}
world.spawnEntityInWorld(cart);
stack.splitStack(1);
return stack;
}
@Override
protected void playDispenseSound(IBlockSource source){
source.getWorld().playAuxSFX(1000, source.getBlockPos(), 0);
}
};
public ItemMinecartAA(String name){
super(name);
this.maxStackSize = 1;
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, MINECART_DISPENSER_BEHAVIOR);
}
public abstract EntityMinecart createCart(World world, double x, double y, double z);
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
IBlockState state = worldIn.getBlockState(pos);
if(!BlockRailBase.isRailBlock(state)){
return EnumActionResult.FAIL;
}
else{
if(!worldIn.isRemote){
BlockRailBase.EnumRailDirection direction = state.getBlock() instanceof BlockRailBase ? state.getValue(((BlockRailBase)state.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d0 = 0.0D;
if(direction.isAscending()){
d0 = 0.5D;
}
EntityMinecart cart = ((ItemMinecartAA)stack.getItem()).createCart(worldIn, (double)pos.getX()+0.5D, (double)pos.getY()+0.0625D+d0, (double)pos.getZ()+0.5D);
if(stack.hasDisplayName()){
cart.setCustomNameTag(stack.getDisplayName());
}
worldIn.spawnEntityInWorld(cart);
}
stack.stackSize--;
return EnumActionResult.SUCCESS;
}
}
}

View file

@ -11,10 +11,14 @@
package de.ellpeck.actuallyadditions.mod.material; package de.ellpeck.actuallyadditions.mod.material;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.common.util.EnumHelper;
import java.util.Locale;
public class InitArmorMaterials{ public class InitArmorMaterials{
public static ArmorMaterial armorMaterialEmerald; public static ArmorMaterial armorMaterialEmerald;
@ -31,15 +35,19 @@ public class InitArmorMaterials{
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Initializing Armor Materials..."); ModUtil.LOGGER.info("Initializing Armor Materials...");
armorMaterialEmerald = EnumHelper.addArmorMaterial("armorMaterialEmerald", ModUtil.MOD_ID+":armorEmerald", 50, new int[]{5, 9, 8, 5}, 15, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC); armorMaterialEmerald = addArmorMaterial("armorMaterialEmerald", ModUtil.MOD_ID+":armorEmerald", 50, new int[]{5, 9, 8, 5}, 15, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC);
armorMaterialObsidian = EnumHelper.addArmorMaterial("armorMaterialObsidian", ModUtil.MOD_ID+":armorObsidian", 120, new int[]{3, 4, 3, 1}, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC); armorMaterialObsidian = addArmorMaterial("armorMaterialObsidian", ModUtil.MOD_ID+":armorObsidian", 120, new int[]{3, 4, 3, 1}, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC);
armorMaterialQuartz = EnumHelper.addArmorMaterial("armorMaterialQuartz", ModUtil.MOD_ID+":armorQuartz", 20, new int[]{3, 6, 5, 3}, 8, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC); armorMaterialQuartz = addArmorMaterial("armorMaterialQuartz", ModUtil.MOD_ID+":armorQuartz", 20, new int[]{3, 6, 5, 3}, 8, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC);
armorMaterialCrystalRed = EnumHelper.addArmorMaterial("armorMaterialCrystalRed", ModUtil.MOD_ID+":armorCrystalRed", 18, new int[]{3, 7, 6, 3}, 9, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC); armorMaterialCrystalRed = addArmorMaterial("armorMaterialCrystalRed", ModUtil.MOD_ID+":armorCrystalRed", 18, new int[]{3, 7, 6, 3}, 9, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC);
armorMaterialCrystalBlue = EnumHelper.addArmorMaterial("armorMaterialCrystalBlue", ModUtil.MOD_ID+":armorCrystalBlue", 18, new int[]{3, 7, 6, 3}, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC); armorMaterialCrystalBlue = addArmorMaterial("armorMaterialCrystalBlue", ModUtil.MOD_ID+":armorCrystalBlue", 18, new int[]{3, 7, 6, 3}, 10, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC);
armorMaterialCrystalLightBlue = EnumHelper.addArmorMaterial("armorMaterialCrystalLightBlue", ModUtil.MOD_ID+":armorCrystalLightBlue", 35, new int[]{7, 9, 7, 5}, 12, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC); armorMaterialCrystalLightBlue = addArmorMaterial("armorMaterialCrystalLightBlue", ModUtil.MOD_ID+":armorCrystalLightBlue", 35, new int[]{7, 9, 7, 5}, 12, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC);
armorMaterialCrystalBlack = EnumHelper.addArmorMaterial("armorMaterialCrystalBlack", ModUtil.MOD_ID+":armorCrystalBlack", 12, new int[]{1, 4, 3, 1}, 13, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC); armorMaterialCrystalBlack = addArmorMaterial("armorMaterialCrystalBlack", ModUtil.MOD_ID+":armorCrystalBlack", 12, new int[]{1, 4, 3, 1}, 13, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC);
armorMaterialCrystalGreen = EnumHelper.addArmorMaterial("armorMaterialCrystalGreen", ModUtil.MOD_ID+":armorCrystalGreen", 60, new int[]{7, 10, 9, 6}, 18, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC); armorMaterialCrystalGreen = addArmorMaterial("armorMaterialCrystalGreen", ModUtil.MOD_ID+":armorCrystalGreen", 60, new int[]{7, 10, 9, 6}, 18, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC);
armorMaterialCrystalWhite = EnumHelper.addArmorMaterial("armorMaterialCrystalWhite", ModUtil.MOD_ID+":armorCrystalWhite", 18, new int[]{4, 7, 6, 4}, 11, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC); armorMaterialCrystalWhite = addArmorMaterial("armorMaterialCrystalWhite", ModUtil.MOD_ID+":armorCrystalWhite", 18, new int[]{4, 7, 6, 4}, 11, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC);
}
private static ArmorMaterial addArmorMaterial(String name, String textureName, int durability, int[] reductionAmounts, int enchantability, SoundEvent soundOnEquip){
return EnumHelper.addArmorMaterial((ModUtil.MOD_ID+"_"+name).toUpperCase(Locale.ROOT), textureName, durability, reductionAmounts, enchantability, soundOnEquip);
} }
} }

View file

@ -12,8 +12,12 @@ package de.ellpeck.actuallyadditions.mod.material;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.common.util.EnumHelper;
import java.util.Locale;
public class InitToolMaterials{ public class InitToolMaterials{
public static ToolMaterial toolMaterialEmerald; public static ToolMaterial toolMaterialEmerald;
@ -30,17 +34,21 @@ public class InitToolMaterials{
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Initializing Tool Materials..."); ModUtil.LOGGER.info("Initializing Tool Materials...");
toolMaterialEmerald = EnumHelper.addToolMaterial("toolMaterialEmerald", 3, 2000, 9.0F, 5.0F, 15); toolMaterialEmerald = addToolMaterial("toolMaterialEmerald", 3, 2000, 9.0F, 5.0F, 15);
toolMaterialObsidian = EnumHelper.addToolMaterial("toolMaterialObsidian", 3, 8000, 4.0F, 2.0F, 15); toolMaterialObsidian = addToolMaterial("toolMaterialObsidian", 3, 8000, 4.0F, 2.0F, 15);
toolMaterialQuartz = EnumHelper.addToolMaterial("toolMaterialQuartz", 2, 280, 6.5F, 2.0F, 10); toolMaterialQuartz = addToolMaterial("toolMaterialQuartz", 2, 280, 6.5F, 2.0F, 10);
toolMaterialCrystalRed = EnumHelper.addToolMaterial("toolMaterialCrystalRed", 2, 300, 7.0F, 2.25F, 12); toolMaterialCrystalRed = addToolMaterial("toolMaterialCrystalRed", 2, 300, 7.0F, 2.25F, 12);
toolMaterialCrystalBlue = EnumHelper.addToolMaterial("toolMaterialCrystalBlue", 2, 300, 7.0F, 2.25F, 12); toolMaterialCrystalBlue = addToolMaterial("toolMaterialCrystalBlue", 2, 300, 7.0F, 2.25F, 12);
toolMaterialCrystalLightBlue = EnumHelper.addToolMaterial("toolMaterialCrystalLightBlue", 3, 1600, 9.0F, 4.0F, 14); toolMaterialCrystalLightBlue = addToolMaterial("toolMaterialCrystalLightBlue", 3, 1600, 9.0F, 4.0F, 14);
toolMaterialCrystalBlack = EnumHelper.addToolMaterial("toolMaterialCrystalBlack", 2, 280, 6.0F, 2.0F, 8); toolMaterialCrystalBlack = addToolMaterial("toolMaterialCrystalBlack", 2, 280, 6.0F, 2.0F, 8);
toolMaterialCrystalGreen = EnumHelper.addToolMaterial("toolMaterialCrystalGreen", 4, 2200, 9.5F, 5.5F, 18); toolMaterialCrystalGreen = addToolMaterial("toolMaterialCrystalGreen", 4, 2200, 9.5F, 5.5F, 18);
toolMaterialCrystalWhite = EnumHelper.addToolMaterial("toolMaterialCrystalWhite", 2, 280, 6.25F, 2.5F, 15); toolMaterialCrystalWhite = addToolMaterial("toolMaterialCrystalWhite", 2, 280, 6.25F, 2.5F, 15);
} }
private static ToolMaterial addToolMaterial(String name, int harvestLevel, int maxUses, float efficiency, float damage, int enchantability){
return EnumHelper.addToolMaterial((ModUtil.MOD_ID+"_"+name).toUpperCase(Locale.ROOT), harvestLevel, maxUses, efficiency, damage, enchantability);
}
} }

View file

@ -39,7 +39,7 @@ public class BannerHelper{
public static EnumBannerPattern addCraftingPattern(String name, ItemStack craftingStack){ public static EnumBannerPattern addCraftingPattern(String name, ItemStack craftingStack){
Class<?>[] paramTypes = {String.class, String.class, ItemStack.class}; Class<?>[] paramTypes = {String.class, String.class, ItemStack.class};
Object[] paramValues = {ModUtil.MOD_ID+name, ModUtil.MOD_ID+name, craftingStack}; Object[] paramValues = {ModUtil.MOD_ID+name, ModUtil.MOD_ID+name, craftingStack};
return EnumHelper.addEnum(EnumBannerPattern.class, name.toUpperCase(Locale.ROOT), paramTypes, paramValues); return EnumHelper.addEnum(EnumBannerPattern.class, (ModUtil.MOD_ID+"_"+name).toUpperCase(Locale.ROOT), paramTypes, paramValues);
} }
} }

View file

@ -21,6 +21,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -71,26 +72,30 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
private void doWork(){ private void doWork(){
if(this.storage.getEnergyStored() >= USE_PER_SHOT){ if(this.storage.getEnergyStored() >= USE_PER_SHOT){
int range = 4; spawnFireworks(this.worldObj, this.pos.getX(), this.pos.getY(), this.pos.getZ());
int amount = Util.RANDOM.nextInt(5)+1;
for(int i = 0; i < amount; i++){
ItemStack firework = this.makeFirework();
double x = this.pos.getX()+MathHelper.getRandomDoubleInRange(Util.RANDOM, 0, range*2)-range;
double z = this.pos.getZ()+MathHelper.getRandomDoubleInRange(Util.RANDOM, 0, range*2)-range;
EntityFireworkRocket rocket = new EntityFireworkRocket(this.worldObj, x, this.pos.getY()+0.5, z, firework);
this.worldObj.spawnEntityInWorld(rocket);
}
this.storage.extractEnergy(USE_PER_SHOT, false); this.storage.extractEnergy(USE_PER_SHOT, false);
} }
} }
private ItemStack makeFirework(){ public static void spawnFireworks(World world, double x, double y, double z){
int range = 4;
int amount = Util.RANDOM.nextInt(5)+1;
for(int i = 0; i < amount; i++){
ItemStack firework = makeFirework();
double newX = x+MathHelper.getRandomDoubleInRange(Util.RANDOM, 0, range*2)-range;
double newZ = z+MathHelper.getRandomDoubleInRange(Util.RANDOM, 0, range*2)-range;
EntityFireworkRocket rocket = new EntityFireworkRocket(world, newX, y+0.5, newZ, firework);
world.spawnEntityInWorld(rocket);
}
}
private static ItemStack makeFirework(){
NBTTagList list = new NBTTagList(); NBTTagList list = new NBTTagList();
int chargesAmount = Util.RANDOM.nextInt(2)+1; int chargesAmount = Util.RANDOM.nextInt(2)+1;
for(int i = 0; i < chargesAmount; i++){ for(int i = 0; i < chargesAmount; i++){
list.appendTag(this.makeFireworkCharge()); list.appendTag(makeFireworkCharge());
} }
NBTTagCompound compound1 = new NBTTagCompound(); NBTTagCompound compound1 = new NBTTagCompound();
@ -106,7 +111,7 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece
return firework; return firework;
} }
private NBTTagCompound makeFireworkCharge(){ private static NBTTagCompound makeFireworkCharge(){
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
if(Util.RANDOM.nextFloat() >= 0.65F){ if(Util.RANDOM.nextFloat() >= 0.65F){

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.util;
import net.minecraft.block.BlockDispenser; import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
@ -20,6 +21,7 @@ import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import java.util.Locale;
import java.util.Random; import java.util.Random;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -29,12 +31,12 @@ public class Util{
public static final int WILDCARD = OreDictionary.WILDCARD_VALUE; public static final int WILDCARD = OreDictionary.WILDCARD_VALUE;
public static final int BUCKET = FluidContainerRegistry.BUCKET_VOLUME; public static final int BUCKET = FluidContainerRegistry.BUCKET_VOLUME;
public static final EnumRarity CRYSTAL_RED_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalRed", TextFormatting.DARK_RED, ModUtil.NAME+" Red Crystal"); public static final EnumRarity CRYSTAL_RED_RARITY = addRarity(ModUtil.MOD_ID+"crystalRed", TextFormatting.DARK_RED, ModUtil.NAME+" Red Crystal");
public static final EnumRarity CRYSTAL_BLUE_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalBlue", TextFormatting.DARK_BLUE, ModUtil.NAME+" Blue Crystal"); public static final EnumRarity CRYSTAL_BLUE_RARITY = addRarity(ModUtil.MOD_ID+"crystalBlue", TextFormatting.DARK_BLUE, ModUtil.NAME+" Blue Crystal");
public static final EnumRarity CRYSTAL_LIGHT_BLUE_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalLightBlue", TextFormatting.BLUE, ModUtil.NAME+" Light Blue Crystal"); public static final EnumRarity CRYSTAL_LIGHT_BLUE_RARITY = addRarity(ModUtil.MOD_ID+"crystalLightBlue", TextFormatting.BLUE, ModUtil.NAME+" Light Blue Crystal");
public static final EnumRarity CRYSTAL_BLACK_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalBlack", TextFormatting.DARK_GRAY, ModUtil.NAME+" Black Crystal"); public static final EnumRarity CRYSTAL_BLACK_RARITY = addRarity(ModUtil.MOD_ID+"crystalBlack", TextFormatting.DARK_GRAY, ModUtil.NAME+" Black Crystal");
public static final EnumRarity CRYSTAL_GREEN_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalGreen", TextFormatting.DARK_GREEN, ModUtil.NAME+" Green Crystal"); public static final EnumRarity CRYSTAL_GREEN_RARITY = addRarity(ModUtil.MOD_ID+"crystalGreen", TextFormatting.DARK_GREEN, ModUtil.NAME+" Green Crystal");
public static final EnumRarity CRYSTAL_WHITE_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalWhite", TextFormatting.GRAY, ModUtil.NAME+" White Crystal"); public static final EnumRarity CRYSTAL_WHITE_RARITY = addRarity(ModUtil.MOD_ID+"crystalWhite", TextFormatting.GRAY, ModUtil.NAME+" White Crystal");
public static final EnumRarity FALLBACK_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+".fallback", TextFormatting.STRIKETHROUGH, ModUtil.NAME+" Fallback"); public static final EnumRarity FALLBACK_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+".fallback", TextFormatting.STRIKETHROUGH, ModUtil.NAME+" Fallback");
@ -42,12 +44,12 @@ public class Util{
MinecraftForge.EVENT_BUS.register(o); MinecraftForge.EVENT_BUS.register(o);
} }
public static boolean isDevVersion(){ private static EnumRarity addRarity(String name, TextFormatting color, String displayName){
return ModUtil.VERSION.equals("@VERSION@"); return EnumHelper.addRarity((ModUtil.MOD_ID+"_"+name).toUpperCase(Locale.ROOT), color, displayName);
} }
public static void registerDispenserHandler(Item item, BehaviorDefaultDispenseItem handler){ public static boolean isDevVersion(){
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(item, handler); return ModUtil.VERSION.equals("@VERSION@");
} }
public static int arrayContains(Object[] array, Object obj){ public static int arrayContains(Object[] array, Object obj){

View file

@ -484,6 +484,7 @@ item.actuallyadditions.itemFoodBacon.name=Bacon
item.actuallyadditions.itemMiscEnderStar.name=Ender Star item.actuallyadditions.itemMiscEnderStar.name=Ender Star
item.actuallyadditions.itemSpawnerChanger.name=Spawner Changer item.actuallyadditions.itemSpawnerChanger.name=Spawner Changer
item.actuallyadditions.itemMiscSpawnerShard.name=Spawner Shards item.actuallyadditions.itemMiscSpawnerShard.name=Spawner Shards
item.actuallyadditions.itemMinecartFireworkBox.name=Firework Box Cart
#Tooltips #Tooltips
tooltip.actuallyadditions.onSuffix.desc=On tooltip.actuallyadditions.onSuffix.desc=On

View file

@ -0,0 +1,6 @@
{
"parent": "actuallyadditions:item/standardItem",
"textures": {
"layer0": "actuallyadditions:items/itemMinecartFireworkBox"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 597 B