mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-25 22:34:28 +00:00
- AuraPylon: reinit + fixes
This commit is contained in:
1 parent
3fe4d94ebd
commit
327057f82f
16 files changed
+492
-191
No files matched your search
@@ -25,6 +25,7 @@ import makeo.gadomancy.client.renderers.item.ItemRenderTileEntityMulti;
|
||||
import makeo.gadomancy.client.renderers.tile.*;
|
||||
import makeo.gadomancy.common.CommonProxy;
|
||||
import makeo.gadomancy.common.blocks.tiles.*;
|
||||
import makeo.gadomancy.common.entities.fake.EntityPermNoClipItem;
|
||||
import makeo.gadomancy.common.registration.RegisteredBlocks;
|
||||
import makeo.gadomancy.common.registration.RegisteredItems;
|
||||
import makeo.gadomancy.common.utils.Injector;
|
||||
@@ -42,6 +43,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.client.gui.GuiGolem;
|
||||
import thaumcraft.client.renderers.entity.RenderGolemBase;
|
||||
import thaumcraft.client.renderers.entity.RenderSpecialItem;
|
||||
import thaumcraft.client.renderers.tile.TileEldritchPortalRenderer;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.entities.golems.EntityGolemBase;
|
||||
@@ -117,9 +119,9 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ConfigBlocks.blockAiry), new ItemExNodeRenderer());
|
||||
|
||||
//ItemRenderTileEntityMulti multi = new ItemRenderTileEntityMulti(new ItemRenderTileEntityMulti.RenderSet(renderTileAuraPylon, new TileAuraPylon(), 0),
|
||||
// new ItemRenderTileEntityMulti.RenderSet(renderTileAuraPylon, new TileAuraPylonTop(), 1));
|
||||
//MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RegisteredBlocks.blockAuraPylon), multi);
|
||||
ItemRenderTileEntityMulti multi = new ItemRenderTileEntityMulti(new ItemRenderTileEntityMulti.RenderSet(renderTileAuraPylon, new TileAuraPylon(), 0),
|
||||
new ItemRenderTileEntityMulti.RenderSet(renderTileAuraPylon, new TileAuraPylonTop(), 1));
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RegisteredBlocks.blockAuraPylon), multi);
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(RegisteredItems.itemExtendedNodeJar, new ItemJarExtendedNodeRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RegisteredBlocks.blockRemoteJar), new ItemRenderRemoteJar(renderTileRemoteJar));
|
||||
@@ -137,6 +139,8 @@ public class ClientProxy extends CommonProxy {
|
||||
MinecraftForgeClient.registerItemRenderer(RegisteredItems.itemFamiliar, new ItemRenderFamiliar());
|
||||
MinecraftForgeClient.registerItemRenderer(RegisteredItems.itemCreativeNode, new ItemCreativeNodeRenderer());
|
||||
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityPermNoClipItem.class, new RenderSpecialItem());
|
||||
|
||||
//Blocks
|
||||
RegisteredBlocks.rendererTransparentBlock = registerBlockRenderer(new RenderBlockTransparent());
|
||||
RegisteredBlocks.rendererExtendedNodeJarBlock = registerBlockRenderer(new BlockExtendedNodeJarRenderer());
|
||||
|
||||
@@ -68,21 +68,36 @@ public class RenderTileAuraPylon extends TileEntitySpecialRenderer {
|
||||
Aspect a = ((TileAuraPylonTop) tile).getAspect();
|
||||
if(a == null) a = Aspect.WEATHER;
|
||||
Color c = new Color(a.getColor());
|
||||
if(tile.getWorldObj().rand.nextInt(9) == 0) spawnWispParticles((TileAuraPylonTop) tile, c, 0.5F, false);
|
||||
if(tile.getWorldObj().rand.nextInt(9) == 0) {
|
||||
if(a == Aspect.ENTROPY || a == Aspect.DARKNESS || a == Aspect.UNDEAD) {
|
||||
spawnWispParticles((TileAuraPylonTop) tile, 5, 0.5F, false);
|
||||
} else {
|
||||
spawnWispParticles((TileAuraPylonTop) tile, c, 0.5F, false);
|
||||
}
|
||||
}
|
||||
c = c.darker().darker();
|
||||
if(tile.getWorldObj().rand.nextInt(15) == 0) spawnWispParticles((TileAuraPylonTop) tile, c, 0.25F, true);
|
||||
if(tile.getWorldObj().rand.nextInt(15) == 0) {
|
||||
if(a == Aspect.ENTROPY || a == Aspect.DARKNESS || a == Aspect.UNDEAD) {
|
||||
spawnWispParticles((TileAuraPylonTop) tile, 5, 0.25F, false);
|
||||
} else {
|
||||
spawnWispParticles((TileAuraPylonTop) tile, c, 0.25F, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tile instanceof TileAuraPylon && ((TileAuraPylon) tile).isInputTile() && ((TileAuraPylon) tile).isPartOfMultiblock() && ((TileAuraPylon) tile).getAspectType() != null) {
|
||||
Aspect a = ((TileAuraPylon) tile).getAspectType();
|
||||
TileAuraPylon master = ((TileAuraPylon) tile).getMasterTile();
|
||||
if(master == null) return;
|
||||
if(a == null) return;
|
||||
FXEssentiaTrail essentiaTrail = new FXEssentiaTrail(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, master.xCoord, master.yCoord, master.zCoord, 1, a.getColor(), 0.2F);
|
||||
essentiaTrail.noClip = true;
|
||||
ParticleEngine.instance.addEffect(tile.getWorldObj(), essentiaTrail);
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnWispParticles(TileAuraPylonTop tile, int type, float size, boolean inner) {
|
||||
World worldObj = tile.getWorldObj();
|
||||
int xCoord = tile.xCoord;
|
||||
int yCoord = tile.yCoord;
|
||||
int zCoord = tile.zCoord;
|
||||
float offset1 = inner ? 0.4F : 0.3F;
|
||||
float offset2 = inner ? 0.2F : 0.4F;
|
||||
FXWisp ef = new FXWisp(worldObj, xCoord + 0.55F, yCoord + 0.7F, zCoord + 0.55F, xCoord + offset1 + worldObj.rand.nextFloat() * offset2, yCoord + 0.7F, zCoord + offset1 + worldObj.rand.nextFloat() * offset2, size, type);
|
||||
ef.setGravity(-0.04F);
|
||||
ef.shrink = true;
|
||||
ParticleEngine.instance.addEffect(worldObj, ef);
|
||||
}
|
||||
|
||||
private void spawnWispParticles(TileAuraPylonTop tile, Color c, float size, boolean inner) {
|
||||
@@ -92,7 +107,10 @@ public class RenderTileAuraPylon extends TileEntitySpecialRenderer {
|
||||
int zCoord = tile.zCoord;
|
||||
float offset1 = inner ? 0.4F : 0.3F;
|
||||
float offset2 = inner ? 0.2F : 0.4F;
|
||||
FXWisp ef = new FXWisp(worldObj, xCoord + 0.55F, yCoord + 0.7F, zCoord + 0.55F, xCoord + offset1 + worldObj.rand.nextFloat() * offset2, yCoord + 0.7F, zCoord + offset1 + worldObj.rand.nextFloat() * offset2, size, c.getRed(), c.getGreen(), c.getBlue());
|
||||
float red = c.getRed() / 255F;
|
||||
float green = c.getGreen() / 255F;
|
||||
float blue = c.getBlue() / 255F;
|
||||
FXWisp ef = new FXWisp(worldObj, xCoord + 0.55F, yCoord + 0.7F, zCoord + 0.55F, xCoord + offset1 + worldObj.rand.nextFloat() * offset2, yCoord + 0.7F, zCoord + offset1 + worldObj.rand.nextFloat() * offset2, size, red, green, blue);
|
||||
ef.setGravity(-0.04F);
|
||||
ef.shrink = true;
|
||||
ParticleEngine.instance.addEffect(worldObj, ef);
|
||||
|
||||
@@ -3,11 +3,13 @@ package makeo.gadomancy.common;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import makeo.gadomancy.client.ClientProxy;
|
||||
import makeo.gadomancy.common.containers.ContainerArcanePackager;
|
||||
import makeo.gadomancy.common.containers.ContainerInfusionClaw;
|
||||
import makeo.gadomancy.common.data.ModConfig;
|
||||
import makeo.gadomancy.common.entities.fake.EntityPermNoClipItem;
|
||||
import makeo.gadomancy.common.events.EventHandlerEntity;
|
||||
import makeo.gadomancy.common.events.EventHandlerGolem;
|
||||
import makeo.gadomancy.common.events.EventHandlerNetwork;
|
||||
@@ -84,6 +86,8 @@ public class CommonProxy implements IGuiHandler {
|
||||
|
||||
DimensionManager.registerProviderType(ModConfig.dimOuterId, WorldProviderTCEldrich.class, true);
|
||||
DimensionManager.registerDimension(ModConfig.dimOuterId, ModConfig.dimOuterId);
|
||||
|
||||
EntityRegistry.registerModEntity(EntityPermNoClipItem.class, "EntityPermItem", EntityRegistry.findGlobalUniqueEntityId(), Gadomancy.instance, 32, 10, true);
|
||||
}
|
||||
|
||||
public void postInitalize() {
|
||||
|
||||
@@ -22,8 +22,7 @@ import thaumcraft.common.Thaumcraft;
|
||||
* Created by makeo @ 29.11.2014 14:07
|
||||
*/
|
||||
@Mod(modid = Gadomancy.MODID, name = Gadomancy.NAME, version = Gadomancy.VERSION, dependencies="required-after:Thaumcraft@[4.1.1.11,);after:Waila;after:Automagy")
|
||||
public class Gadomancy
|
||||
{
|
||||
public class Gadomancy {
|
||||
public static final String MODID = "gadomancy";
|
||||
public static final String NAME = "Gadomancy";
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
@@ -63,6 +64,15 @@ public class BlockAuraPylon extends BlockContainer implements IBlockTransparent
|
||||
list.add(new ItemStack(item, 1, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta == 1) {
|
||||
return 10;
|
||||
}
|
||||
return super.getLightValue(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return meta;
|
||||
@@ -96,7 +106,7 @@ public class BlockAuraPylon extends BlockContainer implements IBlockTransparent
|
||||
ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsAuraPylonMultiblock, true)) {
|
||||
TileAuraPylon ta = (TileAuraPylon) world.getTileEntity(x, y - 1, z);
|
||||
ta.setTileInformation(true, false);
|
||||
ta = (TileAuraPylon) world.getTileEntity(x, y - 4, z);
|
||||
ta = (TileAuraPylon) world.getTileEntity(x, y - 3, z);
|
||||
ta.setTileInformation(false, true);
|
||||
int count = 1;
|
||||
TileEntity iter = world.getTileEntity(x, y - count, z);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package makeo.gadomancy.common.blocks.tiles;
|
||||
|
||||
import makeo.gadomancy.common.blocks.BlockAuraPylon;
|
||||
import makeo.gadomancy.common.entities.fake.EntityPermNoClipItem;
|
||||
import makeo.gadomancy.common.utils.ItemUtils;
|
||||
import makeo.gadomancy.common.utils.NBTHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -11,12 +13,15 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.aspects.IAspectContainer;
|
||||
import thaumcraft.api.aspects.IEssentiaTransport;
|
||||
import thaumcraft.client.fx.ParticleEngine;
|
||||
import thaumcraft.client.fx.particles.FXEssentiaTrail;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.entities.EntityPermanentItem;
|
||||
import thaumcraft.common.entities.EntitySpecialItem;
|
||||
@@ -47,9 +52,8 @@ public class TileAuraPylon extends SynchronizedTileEntity implements IAspectCont
|
||||
//Master tile updates effects all 8 ticks if there is an internal aspect present.
|
||||
//Input tile handles Essentia IO all 8 ticks and thus provides needed amount information.
|
||||
|
||||
private EntityPermanentItem tcPermItem;
|
||||
private ItemStack crystalEssentiaStack = null;
|
||||
private boolean isPartOfMultiblock = false;
|
||||
private boolean searchingForItem = false;
|
||||
|
||||
private int ticksExisted = 0;
|
||||
private Aspect holdingAspect;
|
||||
@@ -63,7 +67,7 @@ public class TileAuraPylon extends SynchronizedTileEntity implements IAspectCont
|
||||
public void updateEntity() {
|
||||
ticksExisted++;
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
if (!worldObj.isRemote) {
|
||||
if ((ticksExisted & 7) == 0) {
|
||||
if (checkComponents()) return;
|
||||
}
|
||||
@@ -71,27 +75,65 @@ public class TileAuraPylon extends SynchronizedTileEntity implements IAspectCont
|
||||
if (isInputTile()) {
|
||||
handleIO();
|
||||
}
|
||||
|
||||
if (isMasterTile()) {
|
||||
boolean hasChanged = handleCrystal();
|
||||
if (hasChanged) {
|
||||
if(holdingAspect != null) {
|
||||
handleEffectDistribution();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(isMasterTile() && searchingForItem) {
|
||||
tryVortexPossibleItemsClient();
|
||||
}
|
||||
|
||||
if(isInputTile() && holdingAspect != null) {
|
||||
if( isInputTile() && holdingAspect != null) {
|
||||
doEssentiaTrail();
|
||||
}
|
||||
}
|
||||
|
||||
if (isMasterTile()) {
|
||||
if (crystalEssentiaStack == null) {
|
||||
tryVortexPossibleItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tryVortexPossibleItemsClient() {
|
||||
//Client-Side input tile only!
|
||||
private void doEssentiaTrail() {
|
||||
if((ticksExisted & 1) == 0) return;
|
||||
TileAuraPylon tile = getMasterTile();
|
||||
if(tile == null) return;
|
||||
TileAuraPylon inputTile = getInputTile();
|
||||
if(inputTile == null) return;
|
||||
Aspect a = getAspectType();
|
||||
if(a == null) return;
|
||||
|
||||
int count = 5;
|
||||
FXEssentiaTrail essentiaTrail = new FXEssentiaTrail(tile.getWorldObj(), inputTile.xCoord + 0.5, inputTile.yCoord + 0.2, inputTile.zCoord + 0.5, tile.xCoord + 0.5, tile.yCoord + 1.7, tile.zCoord + 0.5, count, a.getColor(), 1);
|
||||
essentiaTrail.noClip = true;
|
||||
essentiaTrail.motionY = (0.1F + MathHelper.sin(count / 3.0F) * 0.01F);
|
||||
essentiaTrail.motionX = (MathHelper.sin(count / 10.0F) * 0.001F + worldObj.rand.nextGaussian() * 0.002000000094994903D);
|
||||
essentiaTrail.motionX = (MathHelper.sin(count / 10.0F) * 0.001F + worldObj.rand.nextGaussian() * 0.002000000094994903D);
|
||||
ParticleEngine.instance.addEffect(tile.getWorldObj(), essentiaTrail);
|
||||
}
|
||||
|
||||
//Special to masterTile only!
|
||||
private void handleEffectDistribution() {
|
||||
int count = 1;
|
||||
TileEntity iter = worldObj.getTileEntity(xCoord, yCoord - count, zCoord);
|
||||
while(iter != null && iter instanceof TileAuraPylon) {
|
||||
((TileAuraPylon) iter).holdingAspect = holdingAspect;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord - count, zCoord);
|
||||
iter.markDirty();
|
||||
count++;
|
||||
iter = worldObj.getTileEntity(xCoord, yCoord - count, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
//Special to masterTile only!
|
||||
private void tryVortexPossibleItems() {
|
||||
TileAuraPylon io = getInputTile();
|
||||
if (io == null) return;
|
||||
ChunkCoordinates rel = new ChunkCoordinates(xCoord, yCoord - (yCoord - io.yCoord), zCoord);
|
||||
int masterY = yCoord + 1;
|
||||
int dst = (masterY - io.yCoord) / 2;
|
||||
ChunkCoordinates rel = new ChunkCoordinates(xCoord, masterY - dst, zCoord);
|
||||
List entityItems = worldObj.selectEntitiesWithinAABB(EntityItem.class,
|
||||
AxisAlignedBB.getBoundingBox(rel.posX - 0.5, rel.posY - 0.5, rel.posZ - 0.5, rel.posX + 0.5, rel.posY + 0.5, rel.posZ + 0.5).expand(8, 8, 8), new IEntitySelector() {
|
||||
@Override
|
||||
@@ -120,132 +162,25 @@ public class TileAuraPylon extends SynchronizedTileEntity implements IAspectCont
|
||||
}
|
||||
}
|
||||
if(entity == null) return;
|
||||
if(dummy.getDistanceSqToEntity(entity) >= 4) {
|
||||
entity.noClip = true;
|
||||
applyMovementVectors(entity);
|
||||
}
|
||||
}
|
||||
if(dummy.getDistanceToEntity(entity) < 3 && !worldObj.isRemote) {
|
||||
this.crystalEssentiaStack = entity.getEntityItem();
|
||||
|
||||
//Client-Side input tile only!
|
||||
private void doEssentiaTrail() {
|
||||
if((ticksExisted & 1) == 0) return;
|
||||
TileAuraPylon masterTile = getMasterTile();
|
||||
if(masterTile == null) return;
|
||||
Thaumcraft.proxy.essentiaTrailFx(worldObj, xCoord, yCoord, zCoord, masterTile.xCoord, masterTile.yCoord, masterTile.zCoord, 10, holdingAspect.getColor(), 1);
|
||||
}
|
||||
|
||||
//Special to masterTile only!
|
||||
private void handleEffectDistribution() {
|
||||
int count = 1;
|
||||
TileEntity iter = worldObj.getTileEntity(xCoord, yCoord - count, zCoord);
|
||||
while(iter != null && iter instanceof TileAuraPylon) {
|
||||
((TileAuraPylon) iter).holdingAspect = holdingAspect;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord - count, zCoord);
|
||||
iter.markDirty();
|
||||
count++;
|
||||
iter = worldObj.getTileEntity(xCoord, yCoord - count, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
//Special to masterTile only!
|
||||
private boolean handleCrystal() {
|
||||
if ((ticksExisted & 3) != 0) return false;
|
||||
|
||||
boolean hasAspect = holdingAspect != null;
|
||||
boolean hasItem = tcPermItem != null;
|
||||
boolean isSearching = searchingForItem;
|
||||
|
||||
tcPermItem = searchForPermItem();
|
||||
|
||||
if (holdingAspect == null) {
|
||||
if(tcPermItem != null) {
|
||||
holdingAspect = ((ItemCrystalEssence) tcPermItem.getEntityItem().getItem()).getAspects(tcPermItem.getEntityItem()).getAspects()[0];
|
||||
}
|
||||
} else {
|
||||
if(tcPermItem == null) {
|
||||
holdingAspect = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(tcPermItem == null) {
|
||||
if(!searchingForItem) {
|
||||
searchingForItem = true;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
} else {
|
||||
if(searchingForItem) {
|
||||
searchingForItem = false;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
if((holdingAspect == null) != hasAspect) {
|
||||
return true;
|
||||
} else if((tcPermItem == null) != hasItem) {
|
||||
return true;
|
||||
} else if(searchingForItem != isSearching) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Special to masterTile only!
|
||||
private EntityPermanentItem searchForPermItem() {
|
||||
if(tcPermItem != null) return tcPermItem;
|
||||
EntityPermanentItem tcPermItem = tryFindPermItem();
|
||||
if (tcPermItem == null) {
|
||||
tcPermItem = tryVortexPossibleItems();
|
||||
}
|
||||
return tcPermItem;
|
||||
}
|
||||
|
||||
//Special to masterTile only!
|
||||
private EntityPermanentItem tryVortexPossibleItems() {
|
||||
TileAuraPylon io = getInputTile();
|
||||
if (io == null) return null;
|
||||
ChunkCoordinates rel = new ChunkCoordinates(xCoord, yCoord - (yCoord - io.yCoord), zCoord);
|
||||
List entityItems = worldObj.selectEntitiesWithinAABB(EntityItem.class,
|
||||
AxisAlignedBB.getBoundingBox(rel.posX - 0.5, rel.posY - 0.5, rel.posZ - 0.5, rel.posX + 0.5, rel.posY + 0.5, rel.posZ + 0.5).expand(8, 8, 8), new IEntitySelector() {
|
||||
@Override
|
||||
public boolean isEntityApplicable(Entity e) {
|
||||
return !(e instanceof EntityPermanentItem) && !(e instanceof EntitySpecialItem) &&
|
||||
e instanceof EntityItem && ((EntityItem) e).getEntityItem() != null &&
|
||||
((EntityItem) e).getEntityItem().getItem() instanceof ItemCrystalEssence;
|
||||
}
|
||||
});
|
||||
Entity dummy = new EntityItem(worldObj);
|
||||
dummy.posX = rel.posX + 0.5;
|
||||
dummy.posY = rel.posY + 0.5;
|
||||
dummy.posZ = rel.posZ + 0.5;
|
||||
|
||||
//MC code.
|
||||
EntityItem entity = null;
|
||||
double d0 = Double.MAX_VALUE;
|
||||
for (Object entityItem : entityItems) {
|
||||
EntityItem entityIt = (EntityItem) entityItem;
|
||||
if (entityIt != dummy) {
|
||||
double d1 = dummy.getDistanceSqToEntity(entityIt);
|
||||
if (d1 <= d0) {
|
||||
entity = entityIt;
|
||||
d0 = d1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(entity == null) return null;
|
||||
if(dummy.getDistanceToEntity(entity) < 4) {
|
||||
EntityPermanentItem item = new EntityPermanentItem(entity.worldObj, entity.posX, entity.posY, entity.posZ, entity.getEntityItem());
|
||||
EntityPermNoClipItem item = new EntityPermNoClipItem(entity.worldObj, rel.posX + 0.5F, rel.posY + 0.5F, rel.posZ + 0.5F, crystalEssentiaStack, xCoord, yCoord, zCoord);
|
||||
entity.worldObj.spawnEntityInWorld(item);
|
||||
item.setVelocity(0, 0, 0);
|
||||
item.hoverStart = entity.hoverStart;
|
||||
item.age = entity.age;
|
||||
item.noClip = true;
|
||||
|
||||
holdingAspect = ((ItemCrystalEssence) crystalEssentiaStack.getItem()).getAspects(crystalEssentiaStack).getAspects()[0];
|
||||
|
||||
entity.setDead();
|
||||
return item;
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
markDirty();
|
||||
} else {
|
||||
entity.noClip = true;
|
||||
applyMovementVectors(entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Special to masterTile only!
|
||||
@@ -263,24 +198,6 @@ public class TileAuraPylon extends SynchronizedTileEntity implements IAspectCont
|
||||
}
|
||||
}
|
||||
|
||||
//Special to masterTile only!
|
||||
private EntityPermanentItem tryFindPermItem() {
|
||||
TileAuraPylon io = getInputTile();
|
||||
if (io == null) return null;
|
||||
ChunkCoordinates rel = new ChunkCoordinates(xCoord, yCoord - (yCoord - io.yCoord), zCoord);
|
||||
Entity dummy = new EntityItem(worldObj);
|
||||
dummy.posX = rel.posX + 0.5;
|
||||
dummy.posY = rel.posY + 0.5;
|
||||
dummy.posZ = rel.posZ + 0.5;
|
||||
Entity permItem = worldObj.findNearestEntityWithinAABB(EntityPermanentItem.class,
|
||||
AxisAlignedBB.getBoundingBox(rel.posX - 0.5, rel.posY - 0.5, rel.posZ - 0.5, rel.posX + 0.5, rel.posY + 0.5, rel.posZ + 0.5), dummy);
|
||||
if (permItem == null) return null;
|
||||
if (((EntityPermanentItem) permItem).getEntityItem() != null && ((EntityPermanentItem) permItem).getEntityItem().getItem() instanceof ItemCrystalEssence) {
|
||||
return (EntityPermanentItem) permItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Special to inputTile only!
|
||||
private void handleIO() {
|
||||
if ((!worldObj.isRemote) && ((ticksExisted & 7) == 0) && (getEssentiaAmount() < getMaxAmount())) {
|
||||
@@ -298,6 +215,13 @@ public class TileAuraPylon extends SynchronizedTileEntity implements IAspectCont
|
||||
}
|
||||
}
|
||||
|
||||
public void informItemPickup() {
|
||||
if(!isMasterTile()) return;
|
||||
this.crystalEssentiaStack = null;
|
||||
this.holdingAspect = null;
|
||||
handleEffectDistribution();
|
||||
}
|
||||
|
||||
//Individual.
|
||||
//Returns true, if state has changed, false if still complete state.
|
||||
private boolean checkComponents() {
|
||||
@@ -334,8 +258,8 @@ public class TileAuraPylon extends SynchronizedTileEntity implements IAspectCont
|
||||
if(pylon != null) {
|
||||
ArrayList<ItemStack> stacks = pylon.getDrops(worldObj, xCoord, yCoord, zCoord, meta, 0);
|
||||
for(ItemStack i : stacks) {
|
||||
EntityItem item = new EntityItem(worldObj, xCoord, yCoord, zCoord, i);
|
||||
ItemUtils.applyRandomDropOffset(item, worldObj.rand);
|
||||
EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, i);
|
||||
//ItemUtils.applyRandomDropOffset(item, worldObj.rand);
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
}
|
||||
}
|
||||
@@ -435,7 +359,7 @@ public class TileAuraPylon extends SynchronizedTileEntity implements IAspectCont
|
||||
this.amount = compound.getInteger("amount");
|
||||
this.maxAmount = compound.getInteger("maxAmount");
|
||||
this.isPartOfMultiblock = compound.getBoolean("partOfMultiblock");
|
||||
this.searchingForItem = compound.getBoolean("searchingItem");
|
||||
this.crystalEssentiaStack = NBTHelper.getStack(compound, "crystalStack");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -448,7 +372,8 @@ public class TileAuraPylon extends SynchronizedTileEntity implements IAspectCont
|
||||
compound.setInteger("amount", amount);
|
||||
compound.setInteger("maxAmount", maxAmount);
|
||||
compound.setBoolean("partOfMultiblock", isPartOfMultiblock);
|
||||
compound.setBoolean("searchingItem", searchingForItem);
|
||||
if(crystalEssentiaStack != null)
|
||||
NBTHelper.setStack(compound, "crystalStack", crystalEssentiaStack);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -16,6 +16,15 @@ public class ModConfig {
|
||||
|
||||
private static Configuration config;
|
||||
|
||||
@Sync
|
||||
public static int entityNoClipItemDatawatcherMasterId = 19;
|
||||
@Sync
|
||||
public static int entityNoClipItemDatawatcherFixedXId = 20;
|
||||
@Sync
|
||||
public static int entityNoClipItemDatawatcherFixedYId = 21;
|
||||
@Sync
|
||||
public static int entityNoClipItemDatawatcherFixedZId = 22;
|
||||
|
||||
@Sync
|
||||
public static int golemDatawatcherId = 29;
|
||||
@Sync
|
||||
@@ -40,6 +49,11 @@ public class ModConfig {
|
||||
}
|
||||
|
||||
private static void loadFromConfig() {
|
||||
entityNoClipItemDatawatcherMasterId = config.getInt("itemNoClipDatawatcherMasterId", "entities", 19, 0, 31, "Do not edit unless you know what are you doing! - Datawatcher ID of the Master-Coordinates for EntityNoClipItem");
|
||||
entityNoClipItemDatawatcherFixedXId = config.getInt("itemNoClipDatawatchetFixXId", "entities", 20, 0, 31, "Do not edit unless you know what are you doing! - Datawatcher ID of the X-Coordinates for EntityNoClipItem");
|
||||
entityNoClipItemDatawatcherFixedYId = config.getInt("itemNoClipDatawatchetFixYId", "entities", 21, 0, 31, "Do not edit unless you know what are you doing! - Datawatcher ID of the Y-Coordinates for EntityNoClipItem");
|
||||
entityNoClipItemDatawatcherFixedZId = config.getInt("itemNoClipDatawatchetFixZId", "entities", 22, 0, 31, "Do not edit unless you know what are you doing! - Datawatcher ID of the Z-Coordinates for EntityNoClipItem");
|
||||
|
||||
golemDatawatcherId = config.getInt("datawatcherId", "golem", 29, 0, 31, "Do not edit unless you know what are you doing!");
|
||||
dimOuterId = config.getInt("dimOuterId", "dimension", -73, Integer.MIN_VALUE, Integer.MAX_VALUE, "Dimension Id for the eldrich mazes accessed via Node Manipulator");
|
||||
doLightCalculations = config.getBoolean("calculateEldritchLight", "dimension", true, "TRUE = Calculating Light values for the Gadomancy-Eldritch Mazes; FALSE = No calculation, but some Light Bugs - Calculating the Light takes ~2 seconds -> Can be measured when trying to enter the eldritch mazed via Gadomancy Eldritch portal.");
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package makeo.gadomancy.common.entities.fake;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.entities.EntitySpecialItem;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* for more read the LICENSE file
|
||||
*
|
||||
* Created by HellFirePvP @ 16.11.2015 14:42
|
||||
*/
|
||||
public class EntityAuraCore extends EntitySpecialItem {
|
||||
|
||||
private int ticksExisted = 0;
|
||||
private AspectList internalAuraList = new AspectList();
|
||||
|
||||
public EntityAuraCore(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound compound) {
|
||||
super.readEntityFromNBT(compound);
|
||||
|
||||
ticksExisted = compound.getInteger("ticksExisted");
|
||||
NBTTagList list = compound.getTagList("auraList", compound.getId());
|
||||
for (int i = 0; i < list.tagCount(); i++) {
|
||||
NBTTagCompound cmp = list.getCompoundTagAt(i);
|
||||
if(cmp.hasKey("tag") && cmp.hasKey("amt")) {
|
||||
internalAuraList.add(Aspect.getAspect(cmp.getString("tag")), cmp.getInteger("amt"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound compound) {
|
||||
super.writeEntityToNBT(compound);
|
||||
|
||||
compound.setInteger("ticksExisted", ticksExisted);
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(Aspect a : internalAuraList.getAspects()) {
|
||||
NBTTagCompound aspectCompound = new NBTTagCompound();
|
||||
aspectCompound.setString("tag", a.getTag());
|
||||
aspectCompound.setInteger("amt", internalAuraList.getAmount(a));
|
||||
list.appendTag(aspectCompound);
|
||||
}
|
||||
compound.setTag("auraList", list);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package makeo.gadomancy.common.entities.fake;
|
||||
|
||||
import makeo.gadomancy.common.blocks.tiles.TileAuraPylon;
|
||||
import makeo.gadomancy.common.data.ModConfig;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.common.entities.EntityPermanentItem;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* for more read the LICENSE file
|
||||
*
|
||||
* Created by HellFirePvP @ 16.11.2015 19:59
|
||||
*/
|
||||
public class EntityPermNoClipItem extends EntityPermanentItem {
|
||||
|
||||
private float fixPosX = -1, fixPosY = -1, fixPosZ = -1; //Can never actually get those values since pylon coords are never .0
|
||||
|
||||
private int masterX, masterY, masterZ; //Coords of its master tile.
|
||||
|
||||
public EntityPermNoClipItem(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityPermNoClipItem(World world, float x, float y, float z, ItemStack stack, int masterX, int masterY, int masterZ) {
|
||||
super(world, x, y, z, stack);
|
||||
this.fixPosX = x;
|
||||
this.fixPosY = y;
|
||||
this.fixPosZ = z;
|
||||
this.masterX = masterX;
|
||||
this.masterY = masterY;
|
||||
this.masterZ = masterZ;
|
||||
|
||||
ChunkCoordinates masterCoords = new ChunkCoordinates(this.masterX, this.masterY, this.masterZ);
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherMasterId, masterCoords);
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedXId, x);
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedYId, y);
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedZId, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
super.entityInit();
|
||||
|
||||
getDataWatcher().addObjectByDataType(ModConfig.entityNoClipItemDatawatcherMasterId, 6);
|
||||
getDataWatcher().addObjectByDataType(ModConfig.entityNoClipItemDatawatcherFixedXId, 3);
|
||||
getDataWatcher().addObjectByDataType(ModConfig.entityNoClipItemDatawatcherFixedYId, 3);
|
||||
getDataWatcher().addObjectByDataType(ModConfig.entityNoClipItemDatawatcherFixedZId, 3);
|
||||
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherMasterId, new ChunkCoordinates(0, 0, 0));
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedXId, -1F);
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedYId, -1F);
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedZId, -1F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
noClip = true;
|
||||
super.onUpdate();
|
||||
setVelocity(0, 0, 0);
|
||||
if(getDataWatcher().getWatchedObject(ModConfig.entityNoClipItemDatawatcherFixedXId).getObject() == null) return;
|
||||
|
||||
float fX = getDataWatcher().getWatchableObjectFloat(ModConfig.entityNoClipItemDatawatcherFixedXId);
|
||||
float fY = getDataWatcher().getWatchableObjectFloat(ModConfig.entityNoClipItemDatawatcherFixedYId);
|
||||
float fZ = getDataWatcher().getWatchableObjectFloat(ModConfig.entityNoClipItemDatawatcherFixedZId);
|
||||
setPositionAndRotation(fX, fY, fZ, 0, 0);
|
||||
|
||||
if((ticksExisted & 7) == 0 && !worldObj.isRemote) {
|
||||
ChunkCoordinates masterCoords = (ChunkCoordinates) getDataWatcher().getWatchedObject(ModConfig.entityNoClipItemDatawatcherMasterId).getObject();
|
||||
TileEntity te = worldObj.getTileEntity(masterCoords.posX, masterCoords.posY, masterCoords.posZ);
|
||||
if(te == null || !(te instanceof TileAuraPylon) || !((TileAuraPylon) te).isMasterTile()) {
|
||||
EntityItem item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem());
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound com) {
|
||||
super.readEntityFromNBT(com);
|
||||
|
||||
this.fixPosX = com.getFloat("fX");
|
||||
this.fixPosY = com.getFloat("fY");
|
||||
this.fixPosZ = com.getFloat("fZ");
|
||||
|
||||
this.masterX = com.getInteger("mX");
|
||||
this.masterY = com.getInteger("mY");
|
||||
this.masterZ = com.getInteger("mZ");
|
||||
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherMasterId, new ChunkCoordinates(masterX, masterY, masterZ));
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedXId, fixPosX);
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedYId, fixPosY);
|
||||
getDataWatcher().updateObject(ModConfig.entityNoClipItemDatawatcherFixedZId, fixPosZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound com) {
|
||||
super.writeEntityToNBT(com);
|
||||
|
||||
com.setFloat("fX", fixPosX);
|
||||
com.setFloat("fY", fixPosY);
|
||||
com.setFloat("fZ", fixPosZ);
|
||||
|
||||
com.setInteger("mX", masterX);
|
||||
com.setInteger("mY", masterY);
|
||||
com.setInteger("mZ", masterZ);
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,18 @@ package makeo.gadomancy.common.events;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileAuraPylon;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileBlockProtector;
|
||||
import makeo.gadomancy.common.data.ModConfig;
|
||||
import makeo.gadomancy.common.entities.fake.EntityPermNoClipItem;
|
||||
import makeo.gadomancy.common.familiar.FamiliarAIController;
|
||||
import makeo.gadomancy.common.utils.world.TCMazeHandler;
|
||||
import net.minecraft.entity.boss.IBossDisplayData;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
@@ -69,8 +73,12 @@ public class EventHandlerEntity {
|
||||
@SubscribeEvent
|
||||
public void on(EntityItemPickupEvent event) {
|
||||
if(!event.entityPlayer.worldObj.isRemote) {
|
||||
if(event.item != null && event.item instanceof EntityPermanentItem) {
|
||||
//TODO inform TileAuraPylon...
|
||||
if(event.item != null && event.item instanceof EntityPermNoClipItem) {
|
||||
EntityPermNoClipItem item = (EntityPermNoClipItem) event.item;
|
||||
ChunkCoordinates master = (ChunkCoordinates) item.getDataWatcher().getWatchedObject(ModConfig.entityNoClipItemDatawatcherMasterId).getObject();
|
||||
TileEntity te = event.entityPlayer.worldObj.getTileEntity(master.posX, master.posY, master.posZ);
|
||||
if(te == null || !(te instanceof TileAuraPylon)) return;
|
||||
((TileAuraPylon) te).informItemPickup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import makeo.gadomancy.common.data.ModConfig;
|
||||
import makeo.gadomancy.common.registration.RegisteredBlocks;
|
||||
import makeo.gadomancy.common.registration.RegisteredItems;
|
||||
import makeo.gadomancy.common.utils.GolemEnumHelper;
|
||||
import makeo.gadomancy.common.utils.JarMultiblockHandler;
|
||||
import makeo.gadomancy.common.utils.WandHandler;
|
||||
import makeo.gadomancy.common.utils.world.TCMazeHandler;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -58,7 +58,6 @@ public class EventHandlerWorld {
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public void on(WorldEvent.Load e) {
|
||||
if (!e.world.isRemote && e.world.provider.dimensionId == 0) {
|
||||
System.out.println("initWorld");
|
||||
Gadomancy.loadModData();
|
||||
|
||||
GolemEnumHelper.validateSavedMapping();
|
||||
@@ -184,7 +183,7 @@ public class EventHandlerWorld {
|
||||
if (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
ItemStack i = e.entityPlayer.getHeldItem();
|
||||
if (i != null && (i.getItem() instanceof ItemWandCasting)) {
|
||||
JarMultiblockHandler.handleWandInteract(e.world, e.x, e.y, e.z, e.entityPlayer, i);
|
||||
WandHandler.handleWandInteract(e.world, e.x, e.y, e.z, e.entityPlayer, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package makeo.gadomancy.common.items;
|
||||
|
||||
import makeo.gadomancy.common.utils.NBTHelper;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* for more read the LICENSE file
|
||||
*
|
||||
* Created by HellFirePvP @ 16.11.2015 15:23
|
||||
*/
|
||||
public class ItemAuraCore extends Item {
|
||||
|
||||
public ItemAuraCore() {
|
||||
setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean flag) {
|
||||
AuraCoreType type = getCoreType(stack);
|
||||
if(type != null) {
|
||||
list.add(EnumChatFormatting.GRAY + type.getLocalizedName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
for (int i = 0; i < AuraCoreType.values().length; i++) {
|
||||
ItemStack stack = new ItemStack(item);
|
||||
setCoreType(stack, AuraCoreType.values()[i]);
|
||||
list.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCoreType(ItemStack itemStack, AuraCoreType type) {
|
||||
if(itemStack == null || !(itemStack.getItem() instanceof ItemAuraCore)) return;
|
||||
if(type == null) return;
|
||||
NBTHelper.getData(itemStack).setInteger("type", type.ordinal());
|
||||
}
|
||||
|
||||
public AuraCoreType getCoreType(ItemStack itemStack) {
|
||||
if(itemStack == null || !(itemStack.getItem() instanceof ItemAuraCore)) return null;
|
||||
int ordinal = NBTHelper.getData(itemStack).getInteger("type");
|
||||
return AuraCoreType.values()[ordinal];
|
||||
}
|
||||
|
||||
public boolean isBlank(ItemStack itemStack) {
|
||||
AuraCoreType type = getCoreType(itemStack);
|
||||
return type == AuraCoreType.BLANK || type == null;
|
||||
}
|
||||
|
||||
public static enum AuraCoreType {
|
||||
|
||||
BLANK("Blank", "blank"),
|
||||
|
||||
AIR("Aer", "aer"),
|
||||
FIRE("Ignis", "ignis"),
|
||||
WATER("Aqua", "aqua"),
|
||||
EARTH("Terra", "terra"),
|
||||
ORDER("Ordo", "ordo"),
|
||||
ENTROPY("Perditio", "perditio"),
|
||||
|
||||
BALANCE("Balanced", "balanced");
|
||||
|
||||
public final String unlocName, fallback;
|
||||
|
||||
AuraCoreType(String fallback, String unlocName) {
|
||||
this.unlocName = "gadomancy.auracore." + unlocName;
|
||||
this.fallback = fallback;
|
||||
}
|
||||
|
||||
public String getLocalizedName() {
|
||||
return StatCollector.canTranslate(unlocName) ? StatCollector.translateToLocal(unlocName) : fallback;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class RegisteredBlocks {
|
||||
blockNodeManipulator = registerBlock(new BlockNodeManipulator(), ItemNodeManipulator.class);
|
||||
blockStoneMachine = registerBlock(new BlockStoneMachine(), ItemBlockStoneMachine.class);
|
||||
blockAdditionalEldrichPortal = registerBlock(new BlockAdditionalEldritchPortal(), ItemBlockAdditionalEldritchPortal.class);
|
||||
//blockAuraPylon = registerBlock(new BlockAuraPylon(), ItemBlockAuraPylon.class);
|
||||
blockAuraPylon = registerBlock(new BlockAuraPylon(), ItemBlockAuraPylon.class);
|
||||
}
|
||||
|
||||
private static <T extends Block> T registerBlock(String name, T block) {
|
||||
@@ -125,8 +125,8 @@ public class RegisteredBlocks {
|
||||
registerTile(TileManipulationFocus.class);
|
||||
registerTile(TileAdditionalEldritchPortal.class);
|
||||
registerTile(TileBlockProtector.class);
|
||||
//registerTile(TileAuraPylon.class);
|
||||
//registerTile(TileAuraPylonTop.class);
|
||||
registerTile(TileAuraPylon.class);
|
||||
registerTile(TileAuraPylonTop.class);
|
||||
}
|
||||
|
||||
private static void registerTile(Class<? extends TileEntity> tile, String name) {
|
||||
|
||||
@@ -39,6 +39,5 @@ public class RegisteredMultiblocks {
|
||||
public static final MultiblockHelper.MultiblockPattern auraPylonPattern = new MultiblockHelper.MultiblockPattern(RegisteredBlocks.blockAuraPylon, 1)
|
||||
.addBlock(0, -1, 0, RegisteredBlocks.blockAuraPylon, 0)
|
||||
.addBlock(0, -2, 0, RegisteredBlocks.blockAuraPylon, 0)
|
||||
.addBlock(0, -3, 0, RegisteredBlocks.blockAuraPylon, 0)
|
||||
.addBlock(0, -4, 0, RegisteredBlocks.blockAuraPylon, 0);
|
||||
.addBlock(0, -3, 0, RegisteredBlocks.blockAuraPylon, 0);
|
||||
}
|
||||
+61
-10
@@ -2,15 +2,18 @@ package makeo.gadomancy.common.utils;
|
||||
|
||||
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileExtendedNodeJar;
|
||||
import makeo.gadomancy.common.items.ItemAuraCore;
|
||||
import makeo.gadomancy.common.node.ExtendedNodeType;
|
||||
import makeo.gadomancy.common.registration.RegisteredBlocks;
|
||||
import makeo.gadomancy.common.registration.RegisteredIntegrations;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
@@ -26,6 +29,7 @@ import thaumcraft.common.tiles.TileJarNode;
|
||||
import thaumcraft.common.tiles.TileOwned;
|
||||
import thaumcraft.common.tiles.TileWarded;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -33,13 +37,15 @@ 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 @ 24.10.2015 18:09
|
||||
*/
|
||||
public class JarMultiblockHandler {
|
||||
public class WandHandler {
|
||||
|
||||
//All wand interacts are redirected to this.
|
||||
public static void handleWandInteract(World world, int x, int y, int z, EntityPlayer entityPlayer, ItemStack i) {
|
||||
Block target = world.getBlock(x, y, z);
|
||||
if(target == null) return;
|
||||
if (target.equals(Blocks.glass)) {
|
||||
if (ResearchManager.isResearchComplete(entityPlayer.getCommandSenderName(), "NODEJAR")) {
|
||||
tryTCJarNodeCreation(i, entityPlayer, world, x, y, z);
|
||||
@@ -49,11 +55,56 @@ public class JarMultiblockHandler {
|
||||
ResearchManager.isResearchComplete(entityPlayer.getCommandSenderName(), "ADVNODEJAR")) {
|
||||
tryAutomagyJarNodeCreation(i, entityPlayer, world, x, y, z);
|
||||
}
|
||||
} else if(target.equals(ConfigBlocks.blockCrystal)) {
|
||||
List items = world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 1, z + 1).expand(4, 4, 4));
|
||||
Iterator it = items.iterator();
|
||||
EntityItem itemAuraCore = null;
|
||||
while(itemAuraCore == null && it.hasNext()) {
|
||||
Object item = it.next();
|
||||
if(item != null && item instanceof EntityItem && !((EntityItem) item).isDead) {
|
||||
EntityItem entityItem = (EntityItem) item;
|
||||
if(entityItem.getEntityItem() != null && entityItem.getEntityItem().getItem() != null && entityItem.getEntityItem().getItem() instanceof ItemAuraCore) {
|
||||
if(((ItemAuraCore) entityItem.getEntityItem().getItem()).isBlank(entityItem.getEntityItem())) itemAuraCore = entityItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(itemAuraCore == null) return;
|
||||
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if(meta <= 6) {
|
||||
AspectList aspects = new AspectList();
|
||||
switch (meta) {
|
||||
case 0:
|
||||
aspects.add(Aspect.AIR, 6);
|
||||
break;
|
||||
case 1:
|
||||
aspects.add(Aspect.FIRE, 6);
|
||||
break;
|
||||
case 2:
|
||||
aspects.add(Aspect.WATER, 6);
|
||||
break;
|
||||
case 3:
|
||||
aspects.add(Aspect.EARTH, 6);
|
||||
break;
|
||||
case 4:
|
||||
aspects.add(Aspect.ORDER, 6);
|
||||
break;
|
||||
case 5:
|
||||
aspects.add(Aspect.ENTROPY, 6);
|
||||
break;
|
||||
case 6:
|
||||
aspects.add(Aspect.AIR, 1).add(Aspect.EARTH, 1).add(Aspect.FIRE, 1).add(Aspect.WATER, 1).add(Aspect.ORDER, 1).add(Aspect.ENTROPY, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
//TODO replace entityitem with entityAuraCore and attach starting aspects.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void tryTCJarNodeCreation(ItemStack wandStack, EntityPlayer player, World world, int x, int y, int z) {
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable slabRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
WandHandler.JarPieceEvaluationRunnable slabRunnable = new WandHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
Block block = world.getBlock(absX, absY, absZ);
|
||||
@@ -61,13 +112,13 @@ public class JarMultiblockHandler {
|
||||
return containsMatch(false, OreDictionary.getOres("slabWood"), new ItemStack(block, 1, md));
|
||||
}
|
||||
};
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable glassRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
WandHandler.JarPieceEvaluationRunnable glassRunnable = new WandHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
return world.getBlock(absX, absY, absZ) == Blocks.glass;
|
||||
}
|
||||
};
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable nodeRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
WandHandler.JarPieceEvaluationRunnable nodeRunnable = new WandHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
TileEntity tile = world.getTileEntity(absX, absY, absZ);
|
||||
@@ -77,7 +128,7 @@ public class JarMultiblockHandler {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
int[] result = JarMultiblockHandler.evaluateIfValidJarIsPresent(world, x, y, z, player, slabRunnable, glassRunnable, nodeRunnable);
|
||||
int[] result = WandHandler.evaluateIfValidJarIsPresent(world, x, y, z, player, slabRunnable, glassRunnable, nodeRunnable);
|
||||
|
||||
if (result == null){
|
||||
return;
|
||||
@@ -91,7 +142,7 @@ public class JarMultiblockHandler {
|
||||
}
|
||||
|
||||
private static void tryAutomagyJarNodeCreation(ItemStack wandStack, EntityPlayer player, World world, int x, int y, int z) {
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable silverWoodRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
WandHandler.JarPieceEvaluationRunnable silverWoodRunnable = new WandHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
TileEntity te = world.getTileEntity(absX, absY, absZ);
|
||||
@@ -104,7 +155,7 @@ public class JarMultiblockHandler {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable glassRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
WandHandler.JarPieceEvaluationRunnable glassRunnable = new WandHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
if ((world.getBlock(absX, absY, absZ) == ConfigBlocks.blockCosmeticOpaque) && (world.getBlockMetadata(absX, absY, absZ) == 2)) {
|
||||
@@ -116,7 +167,7 @@ public class JarMultiblockHandler {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable nodeRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
WandHandler.JarPieceEvaluationRunnable nodeRunnable = new WandHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
TileEntity tile = world.getTileEntity(absX, absY, absZ);
|
||||
@@ -126,7 +177,7 @@ public class JarMultiblockHandler {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
int[] result = JarMultiblockHandler.evaluateIfValidJarIsPresent(world, x, y, z, player, silverWoodRunnable, glassRunnable, nodeRunnable);
|
||||
int[] result = WandHandler.evaluateIfValidJarIsPresent(world, x, y, z, player, silverWoodRunnable, glassRunnable, nodeRunnable);
|
||||
|
||||
if (result == null){
|
||||
return;
|
||||
Reference in new issue
Block a user