Finished handheld filler

Closes #316
This commit is contained in:
Ellpeck 2016-11-05 16:16:42 +01:00
parent 584f6bc034
commit add64ce9ea
8 changed files with 160 additions and 68 deletions

View file

@ -18,4 +18,5 @@ ftog_thorgal=actuallyadditions:itemCrystal
minetechniker=actuallyadditions:itemCrystalEmpowered@2
3pixel=actuallyadditions:itemMoreDamageLens
kirindave=actuallyadditions:itemCrystalEmpowered@3
theonewhohunts=actuallyadditions:itemCrystalEmpowered@4
theonewhohunts=actuallyadditions:itemCrystalEmpowered@4
garantiertnicht=actuallyadditions:itemFillingWand

View file

@ -193,7 +193,6 @@ public final class InitBooklet{
new BookletChapter("canola", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockFermentingBarrel), new PageTextOnly(1).setStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CANOLA.ordinal()), new ItemStack(InitItems.itemCanolaSeed)).addFluidToPage(InitFluids.fluidCanolaOil), new PageTextOnly(2).addFluidToPage(InitFluids.fluidOil).addFluidToPage(InitFluids.fluidCrystalOil).addFluidToPage(InitFluids.fluidEmpoweredOil), new PageCrafting(3, BlockCrafting.recipeCanolaPress).setNoText(), new PageCrafting(4, BlockCrafting.recipeFermentingBarrel).setNoText(), new PageCrafting(5, BlockCrafting.recipeOilGen), new PageReconstructor(6, LensRecipeHandler.recipeCrystallizedCanolaSeed).setNoText(), new PageEmpowerer(7, EmpowererHandler.recipeEmpoweredCanolaSeed).setNoText());
new BookletChapter("leafGen", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockLeafGenerator), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityLeafGenerator.ENERGY_PRODUCED).addTextReplacement("<range>", TileEntityLeafGenerator.RANGE), new PageCrafting(2, BlockCrafting.recipeLeafGen)).setImportant();
new BookletChapter("bioReactor", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockBioReactor), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBioReactor).setNoText()).setSpecial();
;
//No RF Using Items
new BookletChapter("bags", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemBag), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBag), new PageCrafting(3, ItemCrafting.recipeVoidBag).setNoText()).setImportant();
@ -221,6 +220,7 @@ public final class InitBooklet{
//RF Using Items
new BookletChapter("drill", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemDrill, 1, TheColoredLampColors.LIGHT_BLUE.ordinal()), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, ItemCrafting.recipeDrill).setNoText(), new PageCrafting(4, ItemCrafting.RECIPES_DRILL_COLORING), new PageCrafting(4, ItemCrafting.recipeDrillCore).setNoText(), new PageCrafting(5, ItemCrafting.recipeDrillSpeedI).setNoText(), new PageCrafting(6, ItemCrafting.recipeDrillSpeedII).setNoText(), new PageCrafting(7, ItemCrafting.recipeDrillSpeedIII).setNoText(), new PageCrafting(8, ItemCrafting.recipeDrillFortuneI).setNoText(), new PageCrafting(9, ItemCrafting.recipeDrillFortuneII).setNoText(), new PageCrafting(10, ItemCrafting.recipeDrillSilk).setNoText(), new PageCrafting(11, ItemCrafting.recipeDrillThree).setNoText(), new PageCrafting(12, ItemCrafting.recipeDrillFive).setNoText(), new PageCrafting(13, ItemCrafting.recipeDrillPlacing).setNoText()).setSpecial();
new BookletChapter("fillingWand", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemFillingWand), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeFillingWand).setNoText()).setSpecial();
new BookletChapter("staff", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemTeleStaff), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeStaff).setNoText()).setImportant();
new BookletChapter("magnetRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemMagnetRing), new PageCrafting(1, ItemCrafting.recipeMagnetRing));
new BookletChapter("growthRing", ActuallyAdditionsAPI.entryItemsRF, new ItemStack(InitItems.itemGrowthRing), new PageCrafting(1, ItemCrafting.recipeGrowthRing));

View file

@ -154,6 +154,7 @@ public enum ConfigCrafting{
CHARCOAL_BLOCK("Charcoal Block", ConfigCategories.BLOCKS_CRAFTING),
TINY_COAL("Tiny Coal", ConfigCategories.ITEMS_CRAFTING),
BAG("Bag", ConfigCategories.ITEMS_CRAFTING),
FILLING_WAND("Handheld Filler", ConfigCategories.ITEMS_CRAFTING),
VOID_BAG("Void Bag", ConfigCategories.ITEMS_CRAFTING),
EMPOWERER("Empowerer", ConfigCategories.BLOCKS_CRAFTING),
DISTRIBUTOR_ITEM("Item Distributor", ConfigCategories.BLOCKS_CRAFTING),

View file

@ -94,9 +94,22 @@ public final class ItemCrafting{
public static IRecipe recipeBag;
public static IRecipe recipeVoidBag;
public static IRecipe recipeLensMoreDeath;
public static IRecipe recipeFillingWand;
public static void init(){
//Filling Wand
if(ConfigCrafting.FILLING_WAND.isEnabled()){
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemFillingWand),
"IPI", "DCD", " B ",
'I', new ItemStack(InitItems.itemCrystalEmpowered, 1, TheCrystals.IRON.ordinal()),
'P', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()),
'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.COIL_ADVANCED.ordinal()),
'D', new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()),
'B', new ItemStack(InitItems.itemBatteryTriple)));
recipeFillingWand = RecipeUtil.lastIRecipe();
}
//Bag
if(ConfigCrafting.BAG.isEnabled()){
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitItems.itemBag),

View file

@ -19,6 +19,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumActionResult;
@ -29,15 +30,17 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import java.util.List;
public class ItemFillingWand extends ItemEnergy{
public ItemFillingWand(String name){
super(500000, 1000, name);
super(800000, 2000, name);
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
if(player.getItemInUseCount() <= 0){
if(!world.isRemote && player.getItemInUseCount() <= 0){
if(player.isSneaking()){
IBlockState state = world.getBlockState(pos);
saveBlock(state, stack);
@ -64,26 +67,28 @@ public class ItemFillingWand extends ItemEnergy{
@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entity, int timeLeft){
boolean clear = true;
if(entity instanceof EntityPlayer){
RayTraceResult result = WorldUtil.getNearestBlockWithDefaultReachDistance(world, (EntityPlayer)entity);
if(result != null && result.getBlockPos() != null){
if(!stack.hasTagCompound()){
stack.setTagCompound(new NBTTagCompound());
if(!world.isRemote){
boolean clear = true;
if(entity instanceof EntityPlayer){
RayTraceResult result = WorldUtil.getNearestBlockWithDefaultReachDistance(world, (EntityPlayer)entity);
if(result != null && result.getBlockPos() != null){
if(!stack.hasTagCompound()){
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound compound = stack.getTagCompound();
BlockPos pos = result.getBlockPos();
compound.setInteger("SecondX", pos.getX());
compound.setInteger("SecondY", pos.getY());
compound.setInteger("SecondZ", pos.getZ());
clear = false;
}
NBTTagCompound compound = stack.getTagCompound();
BlockPos pos = result.getBlockPos();
compound.setInteger("SecondX", pos.getX());
compound.setInteger("SecondY", pos.getY());
compound.setInteger("SecondZ", pos.getZ());
clear = false;
}
}
if(clear){
ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ");
if(clear){
ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ");
}
}
super.onPlayerStoppedUsing(stack, world, entity, timeLeft);
@ -93,72 +98,129 @@ public class ItemFillingWand extends ItemEnergy{
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected){
super.onUpdate(stack, world, entity, itemSlot, isSelected);
boolean shouldClear = false;
if(!world.isRemote){
boolean shouldClear = false;
if(isSelected){
if(entity instanceof EntityPlayer && stack.hasTagCompound()){
NBTTagCompound compound = stack.getTagCompound();
if(isSelected){
if(entity instanceof EntityPlayer && stack.hasTagCompound()){
EntityPlayer player = (EntityPlayer)entity;
boolean creative = player.capabilities.isCreativeMode;
BlockPos firstPos = new BlockPos(compound.getInteger("FirstX"), compound.getInteger("FirstY"), compound.getInteger("FirstZ"));
BlockPos secondPos = new BlockPos(compound.getInteger("SecondX"), compound.getInteger("SecondY"), compound.getInteger("SecondZ"));
NBTTagCompound compound = stack.getTagCompound();
if(!BlockPos.ORIGIN.equals(firstPos) && !BlockPos.ORIGIN.equals(secondPos)){
IBlockState replaceState = loadBlock(stack);
if(replaceState != null){
int lowestX = Math.min(firstPos.getX(), secondPos.getX());
int lowestY = Math.min(firstPos.getY(), secondPos.getY());
int lowestZ = Math.min(firstPos.getZ(), secondPos.getZ());
BlockPos firstPos = new BlockPos(compound.getInteger("FirstX"), compound.getInteger("FirstY"), compound.getInteger("FirstZ"));
BlockPos secondPos = new BlockPos(compound.getInteger("SecondX"), compound.getInteger("SecondY"), compound.getInteger("SecondZ"));
int currX = compound.getInteger("CurrX");
int currY = compound.getInteger("CurrY");
int currZ = compound.getInteger("CurrZ");
if(!BlockPos.ORIGIN.equals(firstPos) && !BlockPos.ORIGIN.equals(secondPos)){
int energyUse = 1500;
BlockPos pos = new BlockPos(lowestX+currX, lowestY+currY, lowestZ+currZ);
IBlockState state = world.getBlockState(pos);
IBlockState replaceState = loadBlock(stack);
if(replaceState != null && (creative || this.getEnergyStored(stack) >= energyUse)){
int lowestX = Math.min(firstPos.getX(), secondPos.getX());
int lowestY = Math.min(firstPos.getY(), secondPos.getY());
int lowestZ = Math.min(firstPos.getZ(), secondPos.getZ());
if(state.getBlock().isReplaceable(world, pos) && replaceState.getBlock().canPlaceBlockAt(world, pos)){
world.setBlockState(pos, replaceState, 2);
int currX = compound.getInteger("CurrX");
int currY = compound.getInteger("CurrY");
int currZ = compound.getInteger("CurrZ");
if(!ConfigBoolValues.LESS_SOUND.isEnabled()){
SoundType sound = replaceState.getBlock().getSoundType(replaceState, world, pos, entity);
world.playSound(null, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume()+1.0F)/2.0F, sound.getPitch()*0.8F);
}
}
BlockPos pos = new BlockPos(lowestX+currX, lowestY+currY, lowestZ+currZ);
IBlockState state = world.getBlockState(pos);
int distX = Math.abs(secondPos.getX()-firstPos.getX());
int distY = Math.abs(secondPos.getY()-firstPos.getY());
int distZ = Math.abs(secondPos.getZ()-firstPos.getZ());
if(state.getBlock().isReplaceable(world, pos) && replaceState.getBlock().canPlaceBlockAt(world, pos)){
if(creative || removeFittingItem(replaceState, player)){
world.setBlockState(pos, replaceState, 2);
currX++;
if(currX > distX){
currX = 0;
currY++;
if(currY > distY){
currY = 0;
currZ++;
if(currZ > distZ){
if(!ConfigBoolValues.LESS_SOUND.isEnabled()){
SoundType sound = replaceState.getBlock().getSoundType(replaceState, world, pos, player);
world.playSound(null, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume()+1.0F)/2.0F, sound.getPitch()*0.8F);
}
if(!creative){
this.extractEnergy(stack, energyUse, false);
}
}
else{
shouldClear = true;
}
}
}
compound.setInteger("CurrX", currX);
compound.setInteger("CurrY", currY);
compound.setInteger("CurrZ", currZ);
}
else{
shouldClear = true;
int distX = Math.abs(secondPos.getX()-firstPos.getX());
int distY = Math.abs(secondPos.getY()-firstPos.getY());
int distZ = Math.abs(secondPos.getZ()-firstPos.getZ());
currX++;
if(currX > distX){
currX = 0;
currY++;
if(currY > distY){
currY = 0;
currZ++;
if(currZ > distZ){
shouldClear = true;
}
}
}
if(!shouldClear){
compound.setInteger("CurrX", currX);
compound.setInteger("CurrY", currY);
compound.setInteger("CurrZ", currZ);
}
}
else{
shouldClear = true;
}
}
}
}
else{
shouldClear = true;
}
if(shouldClear){
ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ", "SecondX", "SecondY", "SecondZ", "CurrX", "CurrY", "CurrZ");
}
}
else{
shouldClear = true;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool){
super.addInformation(stack, player, list, bool);
String display = "None";
IBlockState state = loadBlock(stack);
if(state != null){
Block block = state.getBlock();
ItemStack blockStack = new ItemStack(block, 1, block.getMetaFromState(state));
if(blockStack.getItem() != null){
display = blockStack.getDisplayName();
}
}
if(shouldClear){
ItemPhantomConnector.clearStorage(stack, "FirstX", "FirstY", "FirstZ", "SecondX", "SecondY", "SecondZ", "CurrX", "CurrY", "CurrZ");
list.add("Selected Block: "+display);
}
private static boolean removeFittingItem(IBlockState state, EntityPlayer player){
Block block = state.getBlock();
ItemStack stack = new ItemStack(block, 1, block.getMetaFromState(state));
if(stack != null && stack.getItem() != null){
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
ItemStack slot = player.inventory.getStackInSlot(i);
if(slot != null && slot.isItemEqual(stack) && slot.stackSize > 0){
slot.stackSize--;
if(slot.stackSize <= 0){
player.inventory.setInventorySlotContents(i, null);
}
return true;
}
}
}
return false;
}
private static void saveBlock(IBlockState state, ItemStack stack){
@ -190,4 +252,9 @@ public class ItemFillingWand extends ItemEnergy{
public int getMaxItemUseDuration(ItemStack stack){
return Integer.MAX_VALUE;
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.EPIC;
}
}

View file

@ -513,6 +513,7 @@ item.actuallyadditions.itemMiscCrystallizedCanolaSeed.name=Crystallized Canola S
item.actuallyadditions.itemMiscEmpoweredCanolaSeed.name=Empowered Canola Seed
item.actuallyadditions.itemMiningLens.name=Lens of the Miner
item.actuallyadditions.itemMoreDamageLens.name=Lens of the Killer
item.actuallyadditions.itemFillingWand.name=Handheld Filler
#Tooltips
tooltip.actuallyadditions.onSuffix.desc=On
@ -1053,4 +1054,7 @@ booklet.actuallyadditions.chapter.reviews.name=What people think
booklet.actuallyadditions.chapter.reviews.text.1="Actually Additions, to me, is quite magical in a way." <n> -<item>Saphrym<r> <n><n>"Actually quite cool. Lots of nice little additions. Gonna be in the pack." <n> -<item>Direwolf20<r> <n><n>"Mod Dev quite rude and arrogant" <n> -<item>Bubb1e0seven<r> <n><n>"A whimsical breath of fresh air in a stuffy tech-mod world." <n> -<item>mezz<r>
booklet.actuallyadditions.chapter.lensMoreDeath.name=Lens of the Killer
booklet.actuallyadditions.chapter.lensMoreDeath.text.1=The <item>Lens of the Killer<r> works much like the <item>Lens of Certain Death<r>, however it will also <imp>drop experience<r> and <imp>player-kill loot<r>. <n>This means, however, that it will use <imp>a lot more power<r>. <n><n>To pick up the experience it drops, you might want to try an <item>Experience Solidifier<r>.
booklet.actuallyadditions.chapter.lensMoreDeath.text.1=The <item>Lens of the Killer<r> works much like the <item>Lens of Certain Death<r>, however it will also <imp>drop experience<r> and <imp>player-kill loot<r>. <n>This means, however, that it will use <imp>a lot more power<r>. <n><n>To pick up the experience it drops, you might want to try an <item>Experience Solidifier<r>.
booklet.actuallyadditions.chapter.fillingWand.name=Handheld Filler
booklet.actuallyadditions.chapter.fillingWand.text.1=The <item>Handheld Filler<r> is a great way to <imp>fill any area<r> with blocks. <n>To do this, first <imp>sneak-right-click<r> a block in the world that you want to <imp>fill an area with<r>. <n><n>To actually fill an area, look at the <imp>first corner<r> and <imp>hold right-click<r>. Let go of right-click at the <imp>second corner<r>. The area you mark can be a flat plane or a cube. <n>This process requires <imp>some RF<r> for placing the blocks and you need to <imp>have the blocks<r> in your inventory.

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B