Huge commit for the Pull-Request.

Added a lot of things:
- Blood Tank
- Teleposition Sigil
- Transposition Sigil
- Cobblestone/Netherrack/Obisidian generation Ritual
- Tree Cutter Ritual
- Pump Ritual
- Altar Builder Ritual
- Block Placing Ritual
- Portal Ritual
- Teleportation System and API Components
- Cross pattern Area Descriptor
- Two reagents and their textures for the sigils’ crafting

Fixed:
- Teleposer not teleporting entities correctly

And probably other things I forgot!
This commit is contained in:
Tombenpotter 2016-02-18 17:25:11 +01:00
parent d947f23696
commit 7e8aec8652
53 changed files with 3031 additions and 372 deletions

View file

@ -5,6 +5,10 @@ import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.BloodMagic;
@ -12,6 +16,7 @@ import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;

View file

@ -1,17 +1,17 @@
package WayofTime.bloodmagic.item;
import java.util.ArrayList;
import java.util.List;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.registry.ModItems;
import lombok.Getter;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.registry.ModItems;
import java.util.ArrayList;
import java.util.List;
public class ItemComponent extends Item
{
@ -35,6 +35,8 @@ public class ItemComponent extends Item
public static final String REAGENT_COMPRESSION = "reagentCompression";
public static final String REAGENT_BRIDGE = "reagentBridge";
public static final String REAGENT_SEVERANCE = "reagentSeverance";
public static final String REAGENT_TELEPOSITION = "reagentTeleposition";
public static final String REAGENT_TRANSPOSITION = "reagentTransposition";
public ItemComponent()
{
@ -67,6 +69,8 @@ public class ItemComponent extends Item
names.add(14, REAGENT_COMPRESSION);
names.add(15, REAGENT_BRIDGE);
names.add(16, REAGENT_SEVERANCE);
names.add(17, REAGENT_TELEPOSITION);
names.add(18, REAGENT_TRANSPOSITION);
}
@Override

View file

@ -1,16 +1,18 @@
package WayofTime.bloodmagic.item;
import com.google.common.base.Strings;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.IFuelHandler;
import net.minecraftforge.fml.relauncher.Side;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import com.google.common.base.Strings;
public class ItemLavaCrystal extends ItemBindable implements IFuelHandler
{
public ItemLavaCrystal()
@ -49,6 +51,8 @@ public class ItemLavaCrystal extends ItemBindable implements IFuelHandler
if (fuelItem instanceof ItemLavaCrystal)
{
System.out.println("Test get burn time: Side = " + FMLCommonHandler.instance().getSide());
//
// if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
// {
// return 200;

View file

@ -2,7 +2,6 @@ package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.creativetab.CreativeTabs;

View file

@ -0,0 +1,123 @@
package WayofTime.bloodmagic.item.block;
import WayofTime.bloodmagic.tile.TileBloodTank;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import java.util.List;
public class ItemBlockBloodTank extends ItemBlock implements IFluidContainerItem
{
public ItemBlockBloodTank(Block block)
{
super(block);
}
@Override
public String getItemStackDisplayName(ItemStack stack)
{
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("tank") && !stack.getTagCompound().getCompoundTag("tank").getString("FluidName").equals(""))
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag("tank");
return super.getItemStackDisplayName(stack) + " (" + tag.getString("FluidName") + ")";
} else
{
return super.getItemStackDisplayName(stack);
}
}
@Override
public void addInformation(ItemStack stack, EntityPlayer entityPlayer, List<String> tooltip, boolean advanced)
{
tooltip.add(StatCollector.translateToLocal("tooltip.BloodMagic.fluid.capacity") + ": " + String.valueOf(getCapacity(stack)) + "mB");
if (stack.hasTagCompound())
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag("tank");
if (!tag.getString("FluidName").equals(""))
{
tooltip.add(" ");
tooltip.add(StatCollector.translateToLocal("tooltip.BloodMagic.fluid.type") + ": " + tag.getString("FluidName"));
tooltip.add(StatCollector.translateToLocal("tooltip.BloodMagic.fluid.amount") + ": " + tag.getInteger("Amount") + "/" + getCapacity(stack) + "mB");
}
}
}
@Override
public FluidStack getFluid(ItemStack stack)
{
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("tank") && !stack.getTagCompound().getCompoundTag("tank").getString("FluidName").equals(""))
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag("tank");
return FluidStack.loadFluidStackFromNBT(tag);
}
return null;
}
@Override
public int getCapacity(ItemStack container)
{
return TileBloodTank.capacity;
}
@Override
public int fill(ItemStack stack, FluidStack resource, boolean doFill)
{
if (resource == null || stack.stackSize != 1) return 0;
int fillAmount = 0, capacity = getCapacity(stack);
NBTTagCompound tag = stack.getTagCompound(), fluidTag = null;
FluidStack fluid = null;
if (tag == null || !tag.hasKey("tank") || (fluidTag = tag.getCompoundTag("tank")) == null || (fluid = FluidStack.loadFluidStackFromNBT(fluidTag)) == null)
fillAmount = Math.min(capacity, resource.amount);
if (fluid == null)
{
if (doFill)
{
fluid = resource.copy();
fluid.amount = 0;
}
} else if (!fluid.isFluidEqual(resource))
return 0;
else
fillAmount = Math.min(capacity - fluid.amount, resource.amount);
fillAmount = Math.max(fillAmount, 0);
if (doFill)
{
if (tag == null)
stack.setTagCompound(new NBTTagCompound());
tag = stack.getTagCompound();
fluid.amount += fillAmount;
tag.setTag("tank", fluid.writeToNBT(fluidTag == null ? new NBTTagCompound() : fluidTag));
}
return fillAmount;
}
@Override
public FluidStack drain(ItemStack stack, int maxDrain, boolean doDrain)
{
NBTTagCompound tag = stack.getTagCompound(), fluidTag = null;
FluidStack fluid = null;
if (tag == null || !tag.hasKey("tank") || (fluidTag = tag.getCompoundTag("tank")) == null || (fluid = FluidStack.loadFluidStackFromNBT(fluidTag)) == null)
{
if (fluidTag != null)
tag.removeTag("tank");
return null;
}
int drainAmount = Math.min(maxDrain, fluid.amount);
if (doDrain)
{
tag.removeTag("tank");
fluid.amount -= drainAmount;
if (fluid.amount > 0)
fill(stack, fluid, true);
}
fluid.amount = drainAmount;
return fluid;
}
}

View file

@ -0,0 +1,85 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.teleport.TeleportQueue;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.ritual.portal.Teleports;
import WayofTime.bloodmagic.tile.TileTeleposer;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class ItemSigilTeleposition extends ItemSigilBase
{
public ItemSigilTeleposition()
{
super("teleposition");
setRegistryName(Constants.BloodMagicItem.SIGIL_TELEPOSITION.getRegName());
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
{
super.addInformation(stack, player, tooltip, advanced);
stack = NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
if (tag != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD))
{
tooltip.add(" ");
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.telepositionFocus.coords", getValue(tag, Constants.NBT.X_COORD), getValue(tag, Constants.NBT.Y_COORD), getValue(tag, Constants.NBT.Z_COORD)));
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.telepositionFocus.dimension", getValue(tag, Constants.NBT.DIMENSION_ID)));
}
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
if (!world.isRemote && NBTHelper.checkNBT(stack) != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD))
{
BlockPos blockPos = new BlockPos(getValue(stack.getTagCompound(), Constants.NBT.X_COORD), getValue(stack.getTagCompound(), Constants.NBT.Y_COORD), getValue(stack.getTagCompound(), Constants.NBT.Z_COORD)).up();
if (world.provider.getDimensionId() == getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID))
{
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(blockPos, player, getOwnerUUID(stack)));
} else
{
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(blockPos, player, getOwnerUUID(stack), world, getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID)));
}
}
return stack;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer entityPlayer, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (!world.isRemote && entityPlayer.isSneaking() && NBTHelper.checkNBT(stack) != null)
{
if (world.getTileEntity(blockPos) != null && world.getTileEntity(blockPos) instanceof TileTeleposer)
{
stack.getTagCompound().setInteger(Constants.NBT.DIMENSION_ID, world.provider.getDimensionId());
stack.getTagCompound().setInteger(Constants.NBT.X_COORD, blockPos.getX());
stack.getTagCompound().setInteger(Constants.NBT.Y_COORD, blockPos.getY());
stack.getTagCompound().setInteger(Constants.NBT.Z_COORD, blockPos.getZ());
return true;
}
}
return false;
}
public int getValue(NBTTagCompound tag, String key)
{
return tag.getInteger(key);
}
}

View file

@ -0,0 +1,150 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.ConfigHandler;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class ItemSigilTransposition extends ItemSigilBase
{
public ItemSigilTransposition()
{
super("transposition", 1000);
setRegistryName(Constants.BloodMagicItem.SIGIL_TRANSPOSITION.getRegName());
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
{
super.addInformation(stack, player, tooltip, advanced);
stack = NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META))
{
tooltip.add(" ");
BlockStack blockStack = new BlockStack(Block.getBlockFromName(tag.getString(Constants.NBT.CONTAINED_BLOCK_NAME)), tag.getByte(Constants.NBT.CONTAINED_BLOCK_META));
tooltip.add(blockStack.getItemStack().getDisplayName());
}
}
@Override
public String getItemStackDisplayName(ItemStack stack)
{
stack = NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META))
{
BlockStack blockStack = new BlockStack(Block.getBlockFromName(tag.getString(Constants.NBT.CONTAINED_BLOCK_NAME)), tag.getByte(Constants.NBT.CONTAINED_BLOCK_META));
return super.getItemStackDisplayName(stack) + " (" + blockStack.getItemStack().getDisplayName() + ")";
}
return super.getItemStackDisplayName(stack);
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
{
stack = NBTHelper.checkNBT(stack);
if (!world.isRemote)
{
BlockStack rightClickedBlock = BlockStack.getStackFromPos(world, blockPos);
if (!ConfigHandler.transpositionBlacklist.contains(rightClickedBlock) && player.isSneaking() && (!stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) || !stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META)))
{
if (rightClickedBlock.getBlock().getPlayerRelativeBlockHardness(player, world, blockPos) >= 0 && rightClickedBlock.getBlock().getBlockHardness(world, blockPos) >= 0)
{
int cost = getLPUsed();
NBTTagCompound tileNBTTag = new NBTTagCompound();
String blockName = rightClickedBlock.getBlock().getRegistryName();
byte metadata = (byte) stack.getMetadata();
if (world.getTileEntity(blockPos) != null)
{
cost *= 5;
world.getTileEntity(blockPos).writeToNBT(tileNBTTag);
if (world.getTileEntity(blockPos) instanceof TileEntityMobSpawner)
{
cost *= 6;
}
}
stack.getTagCompound().setString(Constants.NBT.CONTAINED_BLOCK_NAME, blockName);
stack.getTagCompound().setByte(Constants.NBT.CONTAINED_BLOCK_META, metadata);
stack.getTagCompound().setTag(Constants.NBT.CONTAINED_TILE_ENTITY, tileNBTTag);
syphonNetwork(stack, player, cost);
lightning(world, blockPos);
world.removeTileEntity(blockPos);
world.setBlockToAir(blockPos);
return true;
}
} else if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META))
{
IBlockState iblockstate = world.getBlockState(blockPos);
Block block = iblockstate.getBlock();
BlockStack blockToPlace = new BlockStack(Block.getBlockFromName(stack.getTagCompound().getString(Constants.NBT.CONTAINED_BLOCK_NAME)), stack.getTagCompound().getByte(Constants.NBT.CONTAINED_BLOCK_META));
if (!block.isReplaceable(world, blockPos))
{
blockPos = blockPos.offset(side);
}
if (stack.stackSize != 0 && player.canPlayerEdit(blockPos, side, stack) && world.canBlockBePlaced(blockToPlace.getBlock(), blockPos, false, side, player, stack))
{
if (world.setBlockState(blockPos, blockToPlace.getState(), 3))
{
blockToPlace.getBlock().onBlockPlacedBy(world, blockPos, blockToPlace.getState(), player, blockToPlace.getItemStack());
world.playSoundEffect((double) ((float) blockPos.getX() + 0.5F), (double) ((float) blockPos.getY() + 0.5F), (double) ((float) blockPos.getZ() + 0.5F), blockToPlace.getBlock().stepSound.getPlaceSound(), (blockToPlace.getBlock().stepSound.getVolume() + 1.0F) / 2.0F, blockToPlace.getBlock().stepSound.getFrequency() * 0.8F);
if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_TILE_ENTITY) && blockToPlace.getBlock().hasTileEntity(blockToPlace.getState()))
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(Constants.NBT.CONTAINED_TILE_ENTITY);
tag.setInteger("x", blockPos.getX());
tag.setInteger("y", blockPos.getY());
tag.setInteger("z", blockPos.getZ());
world.getTileEntity(blockPos).readFromNBT(tag);
}
world.markBlockForUpdate(blockPos);
stack.getTagCompound().removeTag(Constants.NBT.CONTAINED_BLOCK_NAME);
stack.getTagCompound().removeTag(Constants.NBT.CONTAINED_BLOCK_META);
stack.getTagCompound().removeTag(Constants.NBT.CONTAINED_TILE_ENTITY);
lightning(world, blockPos);
return true;
}
}
}
}
return false;
}
public void lightning(World world, BlockPos blockPos)
{
world.addWeatherEffect(new EntityLightningBolt(world, blockPos.getX(), blockPos.getY(), blockPos.getZ()));
}
}