mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-21 12:32:09 +00:00
- Init: Node Manipulator Multiblock
This commit is contained in:
1 parent
ff25c1dec6
commit
aa0d63e3c6
6 files changed
+233
-10
No files matched your search
@@ -4,15 +4,20 @@ import makeo.gadomancy.common.Gadomancy;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileNodeManipulator;
|
||||
import makeo.gadomancy.common.registration.RegisteredBlocks;
|
||||
import makeo.gadomancy.common.registration.RegisteredItems;
|
||||
import makeo.gadomancy.common.registration.RegisteredRecipes;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.common.blocks.BlockStoneDevice;
|
||||
import thaumcraft.common.tiles.TileWandPedestal;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
import thaumcraft.common.lib.utils.InventoryUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,7 +26,7 @@ import java.util.List;
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* for more read the LICENSE file
|
||||
*
|
||||
* <p/>
|
||||
* Created by HellFirePvP @ 26.10.2015 19:23
|
||||
*/
|
||||
public class BlockNodeManipulator extends BlockStoneDevice {
|
||||
@@ -52,7 +57,7 @@ public class BlockNodeManipulator extends BlockStoneDevice {
|
||||
//TC stuff...
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
if(metadata == 5)
|
||||
if (metadata == 5)
|
||||
return new TileNodeManipulator();
|
||||
return null;
|
||||
}
|
||||
@@ -62,7 +67,7 @@ public class BlockNodeManipulator extends BlockStoneDevice {
|
||||
int ret = super.getComparatorInputOverride(world, x, y, z, rs);
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te != null && te instanceof TileWandPedestal) return 0;
|
||||
if (te != null && te instanceof TileNodeManipulator) return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -71,12 +76,65 @@ public class BlockNodeManipulator extends BlockStoneDevice {
|
||||
par3List.add(new ItemStack(par1, 1, 5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
|
||||
return world.getBlock(x, y + 1, z) == Blocks.air && super.canPlaceBlockAt(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block par5) {
|
||||
if(world.getBlock(x, y + 1, z) != Blocks.air) {
|
||||
dropBlockAsItem(world, x, y, z, 5, 0);
|
||||
world.setBlockToAir(x, y, z);
|
||||
}
|
||||
super.onNeighborBlockChange(world, x, y, z, par5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float par7, float par8, float par9) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(world.isRemote) return true;
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
//TODO DO!
|
||||
return super.onBlockActivated(world, x, y, z, player, side, par7, par8, par9);
|
||||
if (te != null && te instanceof TileNodeManipulator && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemWandCasting) {
|
||||
TileNodeManipulator manipulator = (TileNodeManipulator) te;
|
||||
manipulator.checkMultiblock();
|
||||
if (manipulator.isMultiblockStructurePresent()) {
|
||||
if (manipulator.isInMultiblock()) {
|
||||
return tryAddWand(manipulator, x, y, z, player);
|
||||
} else if (ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsNodeManipulatorMultiblock, true)) {
|
||||
manipulator.formMultiblock();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean tryAddWand(TileNodeManipulator manipulator, int x, int y, int z, EntityPlayer player) {
|
||||
World world = manipulator.getWorldObj();
|
||||
if (manipulator.getStackInSlot(0) != null) {
|
||||
InventoryUtils.dropItemsAtEntity(world, x, y, z, player);
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
manipulator.markDirty();
|
||||
world.playSoundEffect(x, y, z, "random.pop", 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 1.5F);
|
||||
return true;
|
||||
}
|
||||
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemWandCasting) {
|
||||
ItemStack i = player.getCurrentEquippedItem().copy();
|
||||
i.stackSize = 1;
|
||||
manipulator.setInventorySlotContents(0, i);
|
||||
player.getCurrentEquippedItem().stackSize -= 1;
|
||||
if (player.getCurrentEquippedItem().stackSize == 0) {
|
||||
player.setCurrentItemOrArmor(0, null);
|
||||
}
|
||||
player.inventory.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
manipulator.markDirty();
|
||||
world.playSoundEffect(x, y, z, "random.pop", 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 1.6F);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user