mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-20 12:09:51 +00:00
- Added ExtendedNodeTypes
- GrowingNode Behavior updated. - ExplosionHandler Added
This commit is contained in:
1 parent
f0a01374e0
commit
924d305c56
14 files changed
+475
-163
No files matched your search
@@ -1,7 +1,7 @@
|
||||
package makeo.gadomancy.client.events;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import makeo.gadomancy.client.util.GrowingDisplayManager;
|
||||
import makeo.gadomancy.client.util.ExtendedTypeDisplayManager;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
|
||||
import makeo.gadomancy.common.registration.RegisteredBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -15,7 +15,6 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import thaumcraft.api.BlockCoordinates;
|
||||
import thaumcraft.api.IArchitect;
|
||||
import thaumcraft.api.nodes.INode;
|
||||
import thaumcraft.api.wands.ItemFocusBasic;
|
||||
import thaumcraft.client.lib.REHWandHandler;
|
||||
import thaumcraft.common.items.relics.ItemThaumometer;
|
||||
@@ -72,8 +71,8 @@ public class RenderEventHandler {
|
||||
TileEntity tile = e.player.worldObj.getTileEntity(blockX, blockY, blockZ);
|
||||
if(tile instanceof TileExtendedNode) {
|
||||
TileExtendedNode node = (TileExtendedNode) tile;
|
||||
if(!node.growing) return;
|
||||
GrowingDisplayManager.notifyDisplayTick(node.getId(), node.getNodeType());
|
||||
if(node.getExtendedNodeType() == null) return;
|
||||
ExtendedTypeDisplayManager.notifyDisplayTick(node.getId(), node.getNodeType(), node.getExtendedNodeType());
|
||||
} else if(tile instanceof TileJarNode) {
|
||||
TileJarNode nodeJar = (TileJarNode) tile;
|
||||
|
||||
@@ -84,6 +83,6 @@ public class RenderEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void worldRenderEvent(RenderWorldLastEvent event) {
|
||||
GrowingDisplayManager.notifyRenderTick();
|
||||
ExtendedTypeDisplayManager.notifyRenderTick();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package makeo.gadomancy.client.renderers.tile;
|
||||
|
||||
import makeo.gadomancy.client.renderers.tile.tc.RenderTileNodeBasic;
|
||||
import makeo.gadomancy.common.blocks.tiles.ExtendedNodeType;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -23,7 +24,7 @@ public class RenderTileExtendedNode extends TileEntitySpecialRenderer {
|
||||
double rY = node.yCoord + 0.5;
|
||||
double rZ = node.zCoord + 0.5;
|
||||
float size = 1.0F;
|
||||
if(node.growing) {
|
||||
if(node.getExtendedNodeType() != null && node.getExtendedNodeType() == ExtendedNodeType.GROWING) {
|
||||
size *= 1.5F;
|
||||
}
|
||||
RenderTileNodeBasic.renderTileEntityAt(tile, rX, rY, rZ, partialTicks, size);
|
||||
|
||||
+4
-3
@@ -1,6 +1,7 @@
|
||||
package makeo.gadomancy.client.util;
|
||||
|
||||
import makeo.gadomancy.client.events.ResourceReloadListener;
|
||||
import makeo.gadomancy.common.blocks.tiles.ExtendedNodeType;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import thaumcraft.api.nodes.NodeType;
|
||||
|
||||
@@ -12,7 +13,7 @@ import thaumcraft.api.nodes.NodeType;
|
||||
*
|
||||
* Created by HellFirePvP @ 23.10.2015 22:53
|
||||
*/
|
||||
public class GrowingDisplayManager {
|
||||
public class ExtendedTypeDisplayManager {
|
||||
|
||||
private static int timeout = 7;
|
||||
private static int currTime = 0;
|
||||
@@ -38,7 +39,7 @@ public class GrowingDisplayManager {
|
||||
changedLanguageFile = false;
|
||||
}
|
||||
|
||||
public static void notifyDisplayTick(String id, NodeType nodeType) {
|
||||
public static void notifyDisplayTick(String id, NodeType nodeType, ExtendedNodeType extendedNodeType) {
|
||||
currTime = 0;
|
||||
|
||||
if(currentNodeId != null && !currentNodeId.equals(id)) {
|
||||
@@ -49,7 +50,7 @@ public class GrowingDisplayManager {
|
||||
if(!changedLanguageFile) {
|
||||
String toChance = "nodetype." + nodeType + ".name";
|
||||
String name = StatCollector.translateToLocal(toChance);
|
||||
String growingStr = StatCollector.translateToLocal("gadomancy.nodes.growing");
|
||||
String growingStr = StatCollector.translateToLocal("gadomancy.nodes." + extendedNodeType.name());
|
||||
String newName = name + ", " + growingStr;
|
||||
ResourceReloadListener.languageList.put(toChance, newName);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package makeo.gadomancy.common.blocks.tiles;
|
||||
|
||||
/**
|
||||
* 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 @ 25.10.2015 10:33
|
||||
*/
|
||||
public enum ExtendedNodeType {
|
||||
|
||||
GROWING,
|
||||
STARVING
|
||||
|
||||
}
|
||||
@@ -3,11 +3,9 @@ package makeo.gadomancy.common.blocks.tiles;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
@@ -21,7 +19,10 @@ public class GrowingNodeBehavior {
|
||||
|
||||
public static final double SATURATION_DIFFICULTY = 10D;
|
||||
public static final double SATURATION_CAP = 100D;
|
||||
private static final Random rand = new Random();
|
||||
public static final int HAPPINESS_CAP = 100;
|
||||
|
||||
//The node the behavior belongs to
|
||||
private final TileExtendedNode owningNode;
|
||||
|
||||
//The lower the 'happier'
|
||||
private double overallHappiness = 0.0D;
|
||||
@@ -39,12 +40,16 @@ public class GrowingNodeBehavior {
|
||||
//If this is true, the node stops growing.
|
||||
private boolean isSaturated = false;
|
||||
|
||||
public void addAspect(AspectType type, AspectList nodeAspects, Aspect aspect, int value) {
|
||||
public GrowingNodeBehavior(TileExtendedNode owningNode) {
|
||||
this.owningNode = owningNode;
|
||||
}
|
||||
|
||||
public void addAspect(AspectType type, Aspect aspect, int value) {
|
||||
if(isSaturated) return;
|
||||
|
||||
double increasedSaturation = getSaturation(type, aspect);
|
||||
addSaturation(aspect, increasedSaturation);
|
||||
nodeAspects.add(aspect, value);
|
||||
owningNode.getAspectsBase().add(aspect, value);
|
||||
|
||||
computeOverallSaturation();
|
||||
}
|
||||
@@ -69,6 +74,11 @@ public class GrowingNodeBehavior {
|
||||
satCmp *= 8.5;
|
||||
satCmp /= 10;
|
||||
|
||||
if(overallHappiness > HAPPINESS_CAP) {
|
||||
overallHappiness /= 10;
|
||||
owningNode.triggerVortexExplosion();
|
||||
}
|
||||
|
||||
//If the saturation is in the upper 85%
|
||||
System.out.println(percentSaturation + " - " + overallHappiness);
|
||||
if(percentSaturation > satCmp) {
|
||||
@@ -103,6 +113,8 @@ public class GrowingNodeBehavior {
|
||||
case ASPECT_ORB:
|
||||
mult -= 0.3D; //Growing node prefers aspects in their most natural form.
|
||||
break;
|
||||
case MANA_BEAN:
|
||||
mult += 0.4D; //Mana beans are hard to breed but easy to multiply.. thus growing node doesn't like.
|
||||
}
|
||||
if(lastFedAspect != null) {
|
||||
if(lastFedAspect.equals(aspect)) {
|
||||
@@ -123,7 +135,7 @@ public class GrowingNodeBehavior {
|
||||
|
||||
if(aspectSaturation.containsKey(aspect)) {
|
||||
double percentageToSaturation = aspectSaturation.get(aspect) / SATURATION_CAP; // 0.0 - 1.0
|
||||
boolean mayAdd = rand.nextFloat() > percentageToSaturation;
|
||||
boolean mayAdd = owningNode.getWorldObj().rand.nextFloat() > percentageToSaturation;
|
||||
if(mayAdd) {
|
||||
double inc = 1D / (1D - percentageToSaturation);
|
||||
if(lastFedAspect != null) {
|
||||
@@ -146,11 +158,10 @@ public class GrowingNodeBehavior {
|
||||
}
|
||||
|
||||
private double evaluateFeedingDenialFunc(double i) {
|
||||
return Math.pow(2D, (i / 6D));
|
||||
return (Math.log(i) / 2) + 1;
|
||||
}
|
||||
|
||||
private void handleOverfeed() {
|
||||
System.out.println("OVERFED");
|
||||
//TODO let node collapse if overfed & still feeding...
|
||||
}
|
||||
|
||||
@@ -196,7 +207,7 @@ public class GrowingNodeBehavior {
|
||||
|
||||
public static enum AspectType {
|
||||
|
||||
WISP, WISP_ESSENCE, ASPECT_ORB
|
||||
WISP, WISP_ESSENCE, ASPECT_ORB, MANA_BEAN
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package makeo.gadomancy.common.blocks.tiles;
|
||||
|
||||
import makeo.gadomancy.common.utils.ExplosionHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.aspects.IEssentiaContainerItem;
|
||||
import thaumcraft.common.entities.EntityAspectOrb;
|
||||
import thaumcraft.common.entities.monster.EntityWisp;
|
||||
import thaumcraft.common.items.ItemManaBean;
|
||||
import thaumcraft.common.items.ItemWispEssence;
|
||||
import thaumcraft.common.tiles.TileNode;
|
||||
|
||||
@@ -24,13 +28,37 @@ import java.util.Random;
|
||||
*/
|
||||
public class TileExtendedNode extends TileNode {
|
||||
|
||||
public boolean growing = new Random().nextBoolean();
|
||||
private GrowingNodeBehavior behavior = new GrowingNodeBehavior();
|
||||
private ExtendedNodeType extendedNodeType;
|
||||
private GrowingNodeBehavior behavior;
|
||||
|
||||
private boolean doingVortexExplosion = false;
|
||||
private ExplosionHelper.VortexExplosion vortexExplosion;
|
||||
|
||||
|
||||
public TileExtendedNode() {
|
||||
this.behavior = new GrowingNodeBehavior(this);
|
||||
|
||||
if(new Random().nextBoolean()) {
|
||||
this.extendedNodeType = ExtendedNodeType.GROWING;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if(this.doingVortexExplosion) {
|
||||
if(this.vortexExplosion == null) {
|
||||
this.vortexExplosion = new ExplosionHelper.VortexExplosion(this);
|
||||
}
|
||||
if(vortexExplosion.isFinished()) {
|
||||
this.vortexExplosion = null;
|
||||
this.doingVortexExplosion = false;
|
||||
} else {
|
||||
vortexExplosion.update();
|
||||
}
|
||||
}
|
||||
|
||||
boolean needUpdate;
|
||||
|
||||
needUpdate = handleGrowingNode(false);
|
||||
@@ -38,31 +66,30 @@ public class TileExtendedNode extends TileNode {
|
||||
if(!worldObj.isRemote && needUpdate) {
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
markDirty();
|
||||
System.out.println(needUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleGrowingNode(boolean needUpdate) {
|
||||
if(!growing) return needUpdate;
|
||||
if(extendedNodeType == null || extendedNodeType != ExtendedNodeType.GROWING) return needUpdate;
|
||||
|
||||
List aspectOrbs = this.worldObj.getEntitiesWithinAABB(EntityAspectOrb.class, AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord, this.zCoord, this.xCoord + 1, this.yCoord + 1, this.zCoord + 1).expand(15.0D, 15.0D, 15.0D));
|
||||
if ((aspectOrbs != null) && (aspectOrbs.size() > 0)) {
|
||||
for (Object orb : aspectOrbs) {
|
||||
EntityAspectOrb aspectOrb = (EntityAspectOrb) orb;
|
||||
if ((aspectOrb.isEntityAlive()) && (!aspectOrb.isEntityInvulnerable())) {
|
||||
double d = getDistanceTo(aspectOrb.posX, aspectOrb.posY, aspectOrb.posZ);
|
||||
if (d < 1.0D) { //prev: 2.0D
|
||||
if (d < 0.5D) { //prev: 2.0D
|
||||
Aspect aspect = aspectOrb.getAspect();
|
||||
|
||||
if (getAspects().getAmount(aspect) < getNodeVisBase(aspect)) {
|
||||
addToContainer(aspect, 1);
|
||||
needUpdate = true;
|
||||
} else {
|
||||
//Adding it permanently
|
||||
if(!worldObj.isRemote && behavior.doesAccept(aspect)) {
|
||||
behavior.addAspect(GrowingNodeBehavior.AspectType.ASPECT_ORB, getAspectsBase(), aspect, 1);
|
||||
needUpdate = true;
|
||||
behavior.addAspect(GrowingNodeBehavior.AspectType.ASPECT_ORB, aspect, 1);
|
||||
}
|
||||
}
|
||||
needUpdate = true;
|
||||
aspectOrb.setDead();
|
||||
}
|
||||
}
|
||||
@@ -73,24 +100,25 @@ public class TileExtendedNode extends TileNode {
|
||||
if ((items != null) && (items.size() > 0)) {
|
||||
for (Object item : items) {
|
||||
EntityItem entityItem = (EntityItem) item;
|
||||
if(!(entityItem.getEntityItem().getItem() instanceof ItemWispEssence)) continue;
|
||||
Item it = entityItem.getEntityItem().getItem();
|
||||
if(!(it instanceof ItemWispEssence || it instanceof ItemManaBean)) continue;
|
||||
if ((entityItem.isEntityAlive()) && (!entityItem.isEntityInvulnerable())) {
|
||||
double d = getDistanceTo(entityItem.posX, entityItem.posY, entityItem.posZ);
|
||||
if (d < 1.0D) { //prev: 2.0D
|
||||
ItemWispEssence essence = (ItemWispEssence) entityItem.getEntityItem().getItem();
|
||||
AspectList list = essence.getAspects(entityItem.getEntityItem());
|
||||
if (d < 0.5D) { //prev: 2.0D
|
||||
IEssentiaContainerItem container = (IEssentiaContainerItem) it;
|
||||
AspectList list = container.getAspects(entityItem.getEntityItem());
|
||||
if(!(list == null || list.size() == 0)) {
|
||||
Aspect aspect = list.getAspects()[0];
|
||||
if (getAspects().getAmount(aspect) < getNodeVisBase(aspect)) {
|
||||
addToContainer(aspect, 1);
|
||||
needUpdate = true;
|
||||
} else {
|
||||
//Adding it permanently
|
||||
if(!worldObj.isRemote && behavior.doesAccept(aspect)) {
|
||||
behavior.addAspect(GrowingNodeBehavior.AspectType.WISP_ESSENCE, getAspectsBase(), aspect, 1);
|
||||
needUpdate = true;
|
||||
GrowingNodeBehavior.AspectType type = it instanceof ItemWispEssence ? GrowingNodeBehavior.AspectType.WISP_ESSENCE : GrowingNodeBehavior.AspectType.MANA_BEAN;
|
||||
behavior.addAspect(type, aspect, 1);
|
||||
}
|
||||
}
|
||||
needUpdate = true;
|
||||
}
|
||||
entityItem.setDead();
|
||||
}
|
||||
@@ -104,21 +132,20 @@ public class TileExtendedNode extends TileNode {
|
||||
EntityWisp wisp = (EntityWisp) wispObj;
|
||||
if ((wisp.isEntityAlive()) && (!wisp.isEntityInvulnerable())) {
|
||||
double d = getDistanceTo(wisp.posX, wisp.posY, wisp.posZ);
|
||||
if (d < 1.0D) { //prev: 2.0D
|
||||
if (d < 0.5D) { //prev: 2.0D
|
||||
Aspect aspect = Aspect.getAspect(wisp.getType());
|
||||
|
||||
if(aspect != null) {
|
||||
if (getAspects().getAmount(aspect) < getNodeVisBase(aspect)) {
|
||||
addToContainer(aspect, 1);
|
||||
needUpdate = true;
|
||||
} else {
|
||||
//Adding it permanently
|
||||
|
||||
if(!worldObj.isRemote && behavior.doesAccept(aspect)) {
|
||||
behavior.addAspect(GrowingNodeBehavior.AspectType.WISP, getAspectsBase(), aspect, 1);
|
||||
needUpdate = true;
|
||||
behavior.addAspect(GrowingNodeBehavior.AspectType.WISP, aspect, 1);
|
||||
}
|
||||
}
|
||||
needUpdate = true;
|
||||
}
|
||||
wisp.setDead();
|
||||
}
|
||||
@@ -143,15 +170,24 @@ public class TileExtendedNode extends TileNode {
|
||||
}
|
||||
}
|
||||
|
||||
public ExtendedNodeType getExtendedNodeType() {
|
||||
return extendedNodeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readCustomNBT(nbttagcompound);
|
||||
|
||||
NBTTagCompound compound = nbttagcompound.getCompoundTag("Gadomancy");
|
||||
|
||||
this.growing = compound.getBoolean("growing");
|
||||
String exName = compound.getString("exNodeType");
|
||||
if(exName != null && !exName.isEmpty()) {
|
||||
this.extendedNodeType = ExtendedNodeType.valueOf(exName);
|
||||
} else {
|
||||
this.extendedNodeType = null;
|
||||
}
|
||||
|
||||
if(growing) {
|
||||
if(extendedNodeType != null && extendedNodeType == ExtendedNodeType.GROWING) {
|
||||
NBTTagCompound growingNodeBehavior = compound.getCompoundTag("NodeBehavior");
|
||||
behavior.readFromNBT(growingNodeBehavior);
|
||||
}
|
||||
@@ -162,15 +198,22 @@ public class TileExtendedNode extends TileNode {
|
||||
super.writeCustomNBT(nbttagcompound);
|
||||
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setBoolean("growing", growing);
|
||||
|
||||
if(growing) {
|
||||
NBTTagCompound behaviorCompound = new NBTTagCompound();
|
||||
behavior.writeToNBT(behaviorCompound);
|
||||
compound.setTag("NodeBehavior", behaviorCompound);
|
||||
if(extendedNodeType != null) {
|
||||
compound.setString("exNodeType", extendedNodeType.name());
|
||||
|
||||
if(extendedNodeType == ExtendedNodeType.GROWING) {
|
||||
NBTTagCompound behaviorCompound = new NBTTagCompound();
|
||||
behavior.writeToNBT(behaviorCompound);
|
||||
compound.setTag("NodeBehavior", behaviorCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("Gadomancy", compound);
|
||||
}
|
||||
|
||||
public void triggerVortexExplosion() {
|
||||
doingVortexExplosion = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -267,7 +267,7 @@ public class TileInfusionClaw extends SynchronizedTileEntity implements IInvento
|
||||
}
|
||||
|
||||
private void startRunning() {
|
||||
PacketHandler.INSTANCE.sendToAllAround(new PacketStartAnimation((byte)0, xCoord, yCoord, zCoord),
|
||||
PacketHandler.INSTANCE.sendToAllAround(new PacketStartAnimation(PacketStartAnimation.ID_INFUSIONCLAW, xCoord, yCoord, zCoord),
|
||||
new NetworkRegistry.TargetPoint(getWorldObj().provider.dimensionId, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 48));
|
||||
cooldown = 22*20;
|
||||
}
|
||||
|
||||
@@ -115,118 +115,11 @@ public class EventHandlerWorld {
|
||||
if (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
ItemStack i = e.entityPlayer.getHeldItem();
|
||||
if (i != null && (i.getItem() instanceof ItemWandCasting)) {
|
||||
Block target = e.world.getBlock(e.x, e.y, e.z);
|
||||
if (target.equals(Blocks.glass)) {
|
||||
if (ResearchManager.isResearchComplete(e.entityPlayer.getCommandSenderName(), "NODEJAR")) {
|
||||
tryTCJarNodeCreation(i, e.entityPlayer, e.world, e.x, e.y, e.z);
|
||||
}
|
||||
} else if (target.equals(ConfigBlocks.blockWarded)) {
|
||||
if (RegisteredIntegrations.automagy.isPresent() &&
|
||||
ResearchManager.isResearchComplete(e.entityPlayer.getCommandSenderName(), "ADVNODEJAR")) {
|
||||
tryAutomagyJarNodeCreation(i, e.entityPlayer, e.world, e.x, e.y, e.z);
|
||||
}
|
||||
}
|
||||
JarMultiblockHandler.handleWandInteract(e.world, e.x, e.y, e.z, e.entityPlayer, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tryTCJarNodeCreation(ItemStack wandStack, EntityPlayer player, World world, int x, int y, int z) {
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable slabRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
Block block = world.getBlock(absX, absY, absZ);
|
||||
int md = world.getBlockMetadata(absX, absY, absZ);
|
||||
return containsMatch(false, OreDictionary.getOres("slabWood"), new ItemStack(block, 1, md));
|
||||
}
|
||||
};
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable glassRunnable = new JarMultiblockHandler.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() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
TileEntity tile = world.getTileEntity(absX, absY, absZ);
|
||||
if ((tile == null) || (!(tile instanceof INode)) || ((tile instanceof TileJarNode))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
int[] result = JarMultiblockHandler.evaluateIfValidJarIsPresent(world, x, y, z, player, slabRunnable, glassRunnable, nodeRunnable);
|
||||
|
||||
if (result == null){
|
||||
return;
|
||||
}
|
||||
|
||||
if(!ThaumcraftApiHelper.consumeVisFromWandCrafting(wandStack, player, new AspectList().add(Aspect.FIRE, 70).add(Aspect.EARTH, 70).add(Aspect.ORDER, 70).add(Aspect.AIR, 70).add(Aspect.ENTROPY, 70).add(Aspect.WATER, 70), true))
|
||||
return;
|
||||
|
||||
if(world.isRemote) return;
|
||||
JarMultiblockHandler.replaceTCJar(world, result[0], result[1], result[2]);
|
||||
}
|
||||
|
||||
private void tryAutomagyJarNodeCreation(ItemStack wandStack, EntityPlayer player, World world, int x, int y, int z) {
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable silverWoodRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
TileEntity te = world.getTileEntity(absX, absY, absZ);
|
||||
if ((te instanceof TileWarded)) {
|
||||
TileWarded warded = (TileWarded) te;
|
||||
if ((warded.block == ConfigBlocks.blockMagicalLog) && (BlockMagicalLog.limitToValidMetadata(warded.blockMd) == 1)) {
|
||||
return player.getCommandSenderName().hashCode() == warded.owner;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable glassRunnable = new JarMultiblockHandler.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)) {
|
||||
TileEntity te = world.getTileEntity(absX, absY, absZ);
|
||||
if ((te instanceof TileOwned)) {
|
||||
return player.getCommandSenderName().equals(((TileOwned) te).owner);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable nodeRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
TileEntity tile = world.getTileEntity(absX, absY, absZ);
|
||||
if ((tile == null) || (!(tile instanceof INode)) || ((tile instanceof TileJarNode))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
int[] result = JarMultiblockHandler.evaluateIfValidJarIsPresent(world, x, y, z, player, silverWoodRunnable, glassRunnable, nodeRunnable);
|
||||
|
||||
if (result == null){
|
||||
return;
|
||||
}
|
||||
|
||||
if(!RegisteredIntegrations.automagy.handleNodeJarVisCost(wandStack, player)) return;
|
||||
|
||||
if(world.isRemote) return;
|
||||
JarMultiblockHandler.replaceAutomagyJar(world, result[0], result[1], result[2]);
|
||||
}
|
||||
|
||||
private boolean containsMatch(boolean strict, List<ItemStack> inputs, ItemStack... targets) {
|
||||
for (ItemStack input : inputs) {
|
||||
for (ItemStack target : targets) {
|
||||
if (OreDictionary.itemMatches(input, target, strict)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isStickyJar(ItemStack stack) {
|
||||
return stack != null && RegisteredItems.isStickyableJar(stack)
|
||||
&& stack.hasTagCompound() && stack.stackTagCompound.getBoolean("isStickyJar");
|
||||
|
||||
@@ -4,6 +4,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import makeo.gadomancy.common.Gadomancy;
|
||||
import makeo.gadomancy.common.network.packets.PacketAnimationAbsorb;
|
||||
import makeo.gadomancy.common.network.packets.PacketStartAnimation;
|
||||
import makeo.gadomancy.common.network.packets.PacketUpdateGolemTypeOrder;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class PacketHandler {
|
||||
|
||||
INSTANCE.registerMessage(PacketUpdateGolemTypeOrder.class, PacketUpdateGolemTypeOrder.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(PacketStartAnimation.class, PacketStartAnimation.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(PacketAnimationAbsorb.class, PacketAnimationAbsorb.class, id++, Side.CLIENT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package makeo.gadomancy.common.network.packets;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* <p/>
|
||||
* Created by HellFirePvP @ 25.10.2015 18:04
|
||||
*/
|
||||
public class PacketAnimationAbsorb implements IMessage, IMessageHandler<PacketAnimationAbsorb, IMessage> {
|
||||
|
||||
private double x, y, z;
|
||||
private int targetX, targetY, targetZ;
|
||||
|
||||
public PacketAnimationAbsorb() {}
|
||||
|
||||
public PacketAnimationAbsorb(double x, double y, double z, int targetX, int targetY, int targetZ) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.targetX = targetX;
|
||||
this.targetY = targetY;
|
||||
this.targetZ = targetZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.x = buf.readDouble();
|
||||
this.y = buf.readDouble();
|
||||
this.z = buf.readDouble();
|
||||
this.targetX = buf.readInt();
|
||||
this.targetY = buf.readInt();
|
||||
this.targetZ = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeDouble(x);
|
||||
buf.writeDouble(y);
|
||||
buf.writeDouble(z);
|
||||
buf.writeInt(targetX);
|
||||
buf.writeInt(targetY);
|
||||
buf.writeInt(targetZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketAnimationAbsorb p, MessageContext ctx) {
|
||||
Block b = Minecraft.getMinecraft().theWorld.getBlock(p.targetX, p.targetY, p.targetZ);
|
||||
int md = Minecraft.getMinecraft().theWorld.getBlockMetadata(p.targetX, p.targetY, p.targetZ);
|
||||
Thaumcraft.proxy.boreDigFx(Minecraft.getMinecraft().theWorld, (int) p.x, (int) p.y, (int) p.z, p.targetX, p.targetY, p.targetZ, b, md);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,11 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileInfusionClaw;
|
||||
import makeo.gadomancy.common.utils.ExplosionHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
@@ -16,6 +19,10 @@ import net.minecraft.client.Minecraft;
|
||||
* Created by makeo @ 11.10.2015 15:19
|
||||
*/
|
||||
public class PacketStartAnimation implements IMessage, IMessageHandler<PacketStartAnimation, IMessage> {
|
||||
|
||||
public static final byte ID_INFUSIONCLAW = 0;
|
||||
public static final byte ID_EX_VORTEX = 1;
|
||||
|
||||
private byte annimationId;
|
||||
private int x;
|
||||
private int y;
|
||||
@@ -48,11 +55,18 @@ public class PacketStartAnimation implements IMessage, IMessageHandler<PacketSta
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketStartAnimation message, MessageContext ctx) {
|
||||
if(message.annimationId == 0) {
|
||||
TileInfusionClaw tile = (TileInfusionClaw) Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z);
|
||||
if(tile != null) {
|
||||
tile.animationStates[8] = 1;
|
||||
}
|
||||
switch (message.annimationId) {
|
||||
case ID_INFUSIONCLAW:
|
||||
TileInfusionClaw tile = (TileInfusionClaw) Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z);
|
||||
if(tile != null) {
|
||||
tile.animationStates[8] = 1;
|
||||
}
|
||||
break;
|
||||
case ID_EX_VORTEX:
|
||||
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(message.x, message.y, message.z);
|
||||
if(te == null || !(te instanceof TileExtendedNode)) return null;
|
||||
ExplosionHelper.VortexExplosion.vortexLightning((TileExtendedNode) te);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
package makeo.gadomancy.common.utils;
|
||||
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileExtendedNode;
|
||||
import makeo.gadomancy.common.network.PacketHandler;
|
||||
import makeo.gadomancy.common.network.packets.PacketAnimationAbsorb;
|
||||
import makeo.gadomancy.common.network.packets.PacketStartAnimation;
|
||||
import makeo.gadomancy.common.registration.RegisteredBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.lib.utils.Utils;
|
||||
import thaumcraft.common.lib.world.ThaumcraftWorldGenerator;
|
||||
import thaumcraft.common.tiles.TileNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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
|
||||
* <p/>
|
||||
* Created by HellFirePvP @ 25.10.2015 10:17
|
||||
*/
|
||||
public class ExplosionHelper {
|
||||
|
||||
public static void taintplosion(World world, int x, int y, int z, boolean taintBiome, int chanceToTaint) {
|
||||
if(chanceToTaint < 1) chanceToTaint = 1;
|
||||
world.createExplosion(null, x + 0.5D, y + 0.5D, z + 0.5D, 3.0F, false);
|
||||
for (int a = 0; a < 50; a++) {
|
||||
int xx = x + world.rand.nextInt(8) - world.rand.nextInt(8);
|
||||
int yy = y + world.rand.nextInt(8) - world.rand.nextInt(8);
|
||||
int zz = z + world.rand.nextInt(8) - world.rand.nextInt(8);
|
||||
if (world.isAirBlock(xx, yy, zz)) {
|
||||
if (yy < y) {
|
||||
world.setBlock(xx, yy, zz, ConfigBlocks.blockFluxGoo, 8, 3);
|
||||
} else {
|
||||
world.setBlock(xx, yy, zz, ConfigBlocks.blockFluxGas, 8, 3);
|
||||
}
|
||||
}
|
||||
if(taintBiome && world.rand.nextInt(chanceToTaint) == 0) {
|
||||
Utils.setBiomeAt(world, xx, zz, ThaumcraftWorldGenerator.biomeTaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class VortexExplosion {
|
||||
|
||||
//Phase 0: Lightnings to blocks and entities around
|
||||
//Phase 1: Creating FallingBlocks and drawing them in
|
||||
//Phase END: Shooting all FallingBlocks into random directories around the node + taint explosion around the node
|
||||
private int tick;
|
||||
private int phase;
|
||||
private World world;
|
||||
private int x, y, z;
|
||||
private List<Vec3> pastTickBlocks = null;
|
||||
|
||||
public VortexExplosion(TileNode exNode) {
|
||||
this.world = exNode.getWorldObj();
|
||||
this.x = exNode.xCoord;
|
||||
this.y = exNode.yCoord;
|
||||
this.z = exNode.zCoord;
|
||||
this.phase = 0;
|
||||
this.tick = 0;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
switch (phase) {
|
||||
case 0: {
|
||||
tick++;
|
||||
if(tick > 200) {
|
||||
tick = 0;
|
||||
phase = 1;
|
||||
}
|
||||
|
||||
sendRadomVortexLightningPacket(world, x, y, z);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
tick++;
|
||||
int range = tick > 100 ? tick > 200 ? 8 : 6 : 4;
|
||||
if(pastTickBlocks != null) {
|
||||
for(Vec3 v : pastTickBlocks) {
|
||||
world.setBlockToAir((int) v.xCoord, (int) v.yCoord, (int) v.zCoord);
|
||||
}
|
||||
}
|
||||
pastTickBlocks = new ArrayList<Vec3>();
|
||||
int cnt = 10;
|
||||
do {
|
||||
int xx = x + world.rand.nextInt(range) - world.rand.nextInt(range);
|
||||
int yy = y + world.rand.nextInt(range) - world.rand.nextInt(range);
|
||||
int zz = z + world.rand.nextInt(range) - world.rand.nextInt(range);
|
||||
Block b = world.getBlock(xx, yy, zz);
|
||||
float hardness = b.getBlockHardness(world, xx, yy, zz);
|
||||
if(b != Blocks.air && hardness > 0 && hardness <= 50 && b != RegisteredBlocks.blockNode) {
|
||||
PacketAnimationAbsorb absorb = new PacketAnimationAbsorb(x + 0.5D, y + 0.5D, z + 0.5D, xx, yy, zz);
|
||||
PacketHandler.INSTANCE.sendToAllAround(absorb, new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32D));
|
||||
pastTickBlocks.add(Vec3.createVectorHelper(xx, yy, zz));
|
||||
}
|
||||
cnt--;
|
||||
} while (cnt > 0);
|
||||
|
||||
if(tick > 300) {
|
||||
phase = 2;
|
||||
taintplosion(world, x, y, z, true, 5);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendRadomVortexLightningPacket(World world, int x, int y, int z) {
|
||||
PacketStartAnimation animationPacket = new PacketStartAnimation(PacketStartAnimation.ID_EX_VORTEX, x, y, z);
|
||||
NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32.0D);
|
||||
PacketHandler.INSTANCE.sendToAllAround(animationPacket, point);
|
||||
}
|
||||
|
||||
public static void vortexLightning(TileExtendedNode te) {
|
||||
World world = te.getWorldObj();
|
||||
int x = te.xCoord;
|
||||
int y = te.yCoord;
|
||||
int z = te.zCoord;
|
||||
float xx = x + world.rand.nextInt(3) - world.rand.nextInt(3);
|
||||
float yy = y + world.rand.nextInt(3) - world.rand.nextInt(3);
|
||||
float zz = z + world.rand.nextInt(3) - world.rand.nextInt(3);
|
||||
xx += world.rand.nextFloat() * (world.rand.nextBoolean() ? 1 : -1);
|
||||
yy += world.rand.nextFloat() * (world.rand.nextBoolean() ? 1 : -1);
|
||||
zz += world.rand.nextFloat() * (world.rand.nextBoolean() ? 1 : -1);
|
||||
Thaumcraft.proxy.nodeBolt(world, x + 0.5F, y + 0.5F, z + 0.5F, xx, yy, zz);
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return phase > 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,27 @@
|
||||
package makeo.gadomancy.common.utils;
|
||||
|
||||
import makeo.gadomancy.common.registration.RegisteredIntegrations;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import thaumcraft.api.ThaumcraftApiHelper;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.nodes.INode;
|
||||
import thaumcraft.api.nodes.NodeModifier;
|
||||
import thaumcraft.api.nodes.NodeType;
|
||||
import thaumcraft.common.blocks.BlockMagicalLog;
|
||||
import thaumcraft.common.config.ConfigBlocks;
|
||||
import thaumcraft.common.lib.research.ResearchManager;
|
||||
import thaumcraft.common.tiles.TileJarNode;
|
||||
import thaumcraft.common.tiles.TileOwned;
|
||||
import thaumcraft.common.tiles.TileWarded;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
@@ -20,7 +33,118 @@ import thaumcraft.common.tiles.TileJarNode;
|
||||
*/
|
||||
public class JarMultiblockHandler {
|
||||
|
||||
public static int[] evaluateIfValidJarIsPresent(World world, int x, int y, int z, EntityPlayer player, JarPieceEvaluationRunnable topRunnable, JarPieceEvaluationRunnable glassRunnable, JarPieceEvaluationRunnable centerRunnable) {
|
||||
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.equals(Blocks.glass)) {
|
||||
if (ResearchManager.isResearchComplete(entityPlayer.getCommandSenderName(), "NODEJAR")) {
|
||||
tryTCJarNodeCreation(i, entityPlayer, world, x, y, z);
|
||||
}
|
||||
} else if (target.equals(ConfigBlocks.blockWarded)) {
|
||||
if (RegisteredIntegrations.automagy.isPresent() &&
|
||||
ResearchManager.isResearchComplete(entityPlayer.getCommandSenderName(), "ADVNODEJAR")) {
|
||||
tryAutomagyJarNodeCreation(i, entityPlayer, world, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void tryTCJarNodeCreation(ItemStack wandStack, EntityPlayer player, World world, int x, int y, int z) {
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable slabRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
Block block = world.getBlock(absX, absY, absZ);
|
||||
int md = world.getBlockMetadata(absX, absY, absZ);
|
||||
return containsMatch(false, OreDictionary.getOres("slabWood"), new ItemStack(block, 1, md));
|
||||
}
|
||||
};
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable glassRunnable = new JarMultiblockHandler.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() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
TileEntity tile = world.getTileEntity(absX, absY, absZ);
|
||||
if ((tile == null) || (!(tile instanceof INode)) || ((tile instanceof TileJarNode))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
int[] result = JarMultiblockHandler.evaluateIfValidJarIsPresent(world, x, y, z, player, slabRunnable, glassRunnable, nodeRunnable);
|
||||
|
||||
if (result == null){
|
||||
return;
|
||||
}
|
||||
|
||||
if(!ThaumcraftApiHelper.consumeVisFromWandCrafting(wandStack, player, new AspectList().add(Aspect.FIRE, 70).add(Aspect.EARTH, 70).add(Aspect.ORDER, 70).add(Aspect.AIR, 70).add(Aspect.ENTROPY, 70).add(Aspect.WATER, 70), true))
|
||||
return;
|
||||
|
||||
if(world.isRemote) return;
|
||||
JarMultiblockHandler.replaceTCJar(world, result[0], result[1], result[2]);
|
||||
}
|
||||
|
||||
private static void tryAutomagyJarNodeCreation(ItemStack wandStack, EntityPlayer player, World world, int x, int y, int z) {
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable silverWoodRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
TileEntity te = world.getTileEntity(absX, absY, absZ);
|
||||
if ((te instanceof TileWarded)) {
|
||||
TileWarded warded = (TileWarded) te;
|
||||
if ((warded.block == ConfigBlocks.blockMagicalLog) && (BlockMagicalLog.limitToValidMetadata(warded.blockMd) == 1)) {
|
||||
return player.getCommandSenderName().hashCode() == warded.owner;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable glassRunnable = new JarMultiblockHandler.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)) {
|
||||
TileEntity te = world.getTileEntity(absX, absY, absZ);
|
||||
if ((te instanceof TileOwned)) {
|
||||
return player.getCommandSenderName().equals(((TileOwned) te).owner);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
JarMultiblockHandler.JarPieceEvaluationRunnable nodeRunnable = new JarMultiblockHandler.JarPieceEvaluationRunnable() {
|
||||
@Override
|
||||
public boolean isValidPieceAt(World world, int absX, int absY, int absZ, EntityPlayer player) {
|
||||
TileEntity tile = world.getTileEntity(absX, absY, absZ);
|
||||
if ((tile == null) || (!(tile instanceof INode)) || ((tile instanceof TileJarNode))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
int[] result = JarMultiblockHandler.evaluateIfValidJarIsPresent(world, x, y, z, player, silverWoodRunnable, glassRunnable, nodeRunnable);
|
||||
|
||||
if (result == null){
|
||||
return;
|
||||
}
|
||||
|
||||
if(!RegisteredIntegrations.automagy.handleNodeJarVisCost(wandStack, player)) return;
|
||||
|
||||
if(world.isRemote) return;
|
||||
JarMultiblockHandler.replaceAutomagyJar(world, result[0], result[1], result[2]);
|
||||
}
|
||||
|
||||
private static boolean containsMatch(boolean strict, List<ItemStack> inputs, ItemStack... targets) {
|
||||
for (ItemStack input : inputs) {
|
||||
for (ItemStack target : targets) {
|
||||
if (OreDictionary.itemMatches(input, target, strict)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static int[] evaluateIfValidJarIsPresent(World world, int x, int y, int z, EntityPlayer player, JarPieceEvaluationRunnable topRunnable, JarPieceEvaluationRunnable glassRunnable, JarPieceEvaluationRunnable centerRunnable) {
|
||||
for (int xx = x - 2; xx <= x; xx++) {
|
||||
for (int yy = y - 3; yy <= y; yy++) {
|
||||
for (int zz = z - 2; zz <= z; zz++) {
|
||||
@@ -33,7 +157,7 @@ public class JarMultiblockHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isValidJarAt(World world, int x, int y, int z, EntityPlayer player, JarPieceEvaluationRunnable topRunnable, JarPieceEvaluationRunnable glassRunnable, JarPieceEvaluationRunnable centerRunnable) {
|
||||
private static boolean isValidJarAt(World world, int x, int y, int z, EntityPlayer player, JarPieceEvaluationRunnable topRunnable, JarPieceEvaluationRunnable glassRunnable, JarPieceEvaluationRunnable centerRunnable) {
|
||||
int[][][] blueprint = {{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 3, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}};
|
||||
for (int yy = 0; yy < 4; yy++) {
|
||||
for (int xx = 0; xx < 3; xx++) {
|
||||
@@ -56,7 +180,7 @@ public class JarMultiblockHandler {
|
||||
|
||||
//TODO spawn growingNodeJar and handle renders and such nasty stuff...
|
||||
|
||||
public static void replaceTCJar(World world, int x, int y, int z) {
|
||||
private static void replaceTCJar(World world, int x, int y, int z) {
|
||||
int[][][] blueprint = {{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 3, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}};
|
||||
for (int yy = 0; yy < 4; yy++) {
|
||||
for (int xx = 0; xx < 3; xx++) {
|
||||
@@ -101,7 +225,7 @@ public class JarMultiblockHandler {
|
||||
world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "thaumcraft:wand", 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public static void replaceAutomagyJar(World world, int x, int y, int z) {
|
||||
private static void replaceAutomagyJar(World world, int x, int y, int z) {
|
||||
int[][][] blueprint = {{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 3, 2}, {2, 2, 2}}, {{2, 2, 2}, {2, 2, 2}, {2, 2, 2}}};
|
||||
for (int yy = 0; yy < 4; yy++) {
|
||||
for (int xx = 0; xx < 3; xx++) {
|
||||
|
||||
Reference in new issue
Block a user