mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-21 20:42:12 +00:00
- AI Shutdown: Costs Perditio essentia, fancy effects, no model yet.
This commit is contained in:
1 parent
37300f7d0c
commit
40b28dad8d
8 files changed
+218
-65
No files matched your search
@@ -116,6 +116,8 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderTileEssentiaCompressor renderTileEssentiaCompressor = new RenderTileEssentiaCompressor();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEssentiaCompressor.class, renderTileEssentiaCompressor);
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileAIShutdown.class, new RenderTileAIShutdown());
|
||||
|
||||
RenderTileAuraPylon renderTileAuraPylon = new RenderTileAuraPylon();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileAuraPylon.class, renderTileAuraPylon);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileAuraPylonTop.class, renderTileAuraPylon);
|
||||
|
||||
@@ -56,6 +56,7 @@ public final class Orbital {
|
||||
|
||||
public void doRender(float partialTicks) {
|
||||
if(MiscUtils.getPositionVector(Minecraft.getMinecraft().renderViewEntity).distance(center) > ModConfig.renderParticleDistance) return;
|
||||
if(Minecraft.getMinecraft().isGamePaused()) return;
|
||||
|
||||
for(OrbitalRenderProperties orbitalNode : orbitals) {
|
||||
Axis axis = orbitalNode.getAxis();
|
||||
@@ -68,9 +69,11 @@ public final class Orbital {
|
||||
Vector3 point = axis.getAxis().clone().perpendicular().normalize().multiply(orbitalNode.getOffset()).rotate(currentRad, axis.getAxis()).add(center);
|
||||
|
||||
if(orbitalNode.getRunnable() != null) {
|
||||
orbitalNode.getRunnable().onRender(point, orbitalNode, orbitalCounter, partialTicks);
|
||||
orbitalNode.getRunnable().onRender(world, point, orbitalNode, orbitalCounter, partialTicks);
|
||||
}
|
||||
|
||||
if(orbitalNode.getParticleSize() <= 0) continue;
|
||||
|
||||
FXFlow.FXFlowBase flow = new FXFlow.FXFlowBase(world, point.getX(), point.getY(), point.getZ(),
|
||||
orbitalNode.getColor(), orbitalNode.getParticleSize(), orbitalNode.getMultiplier(), orbitalNode.getBrightness());
|
||||
|
||||
@@ -268,7 +271,7 @@ public final class Orbital {
|
||||
}
|
||||
|
||||
public static abstract class OrbitalRenderRunnable {
|
||||
public abstract void onRender(Vector3 selectedPosition, OrbitalRenderProperties properties, int orbitalExisted, float partialTicks);
|
||||
public abstract void onRender(World world, Vector3 selectedPosition, OrbitalRenderProperties properties, int orbitalExisted, float partialTicks);
|
||||
}
|
||||
|
||||
public static class Axis {
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package makeo.gadomancy.client.renderers.tile;
|
||||
|
||||
import makeo.gadomancy.client.effect.EffectHandler;
|
||||
import makeo.gadomancy.client.effect.fx.Orbital;
|
||||
import makeo.gadomancy.common.blocks.tiles.TileAIShutdown;
|
||||
import makeo.gadomancy.common.utils.Vector3;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.client.fx.ParticleEngine;
|
||||
import thaumcraft.client.fx.particles.FXWisp;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 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 @ 09.06.2016 / 12:56
|
||||
*/
|
||||
public class RenderTileAIShutdown extends TileEntitySpecialRenderer {
|
||||
|
||||
private static final Random rand = new Random();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float parTicks) {
|
||||
if(tileEntity == null || !(tileEntity instanceof TileAIShutdown)) return;
|
||||
TileAIShutdown ta = (TileAIShutdown) tileEntity;
|
||||
|
||||
if(ta.hasMultiblock() && ta.getStoredEssentia() > 0) {
|
||||
handleOrbital(ta);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleOrbital(TileAIShutdown ta) {
|
||||
if(ta.orbital == null && ta.getWorldObj() != null) {
|
||||
ta.orbital = new Orbital(new Vector3(ta.xCoord + 0.5, ta.yCoord + 0.2, ta.zCoord + 0.5), ta.getWorldObj());
|
||||
}
|
||||
|
||||
if(ta.orbital != null && !ta.orbital.registered) {
|
||||
EffectHandler.getInstance().registerOrbital(ta.orbital);
|
||||
}
|
||||
|
||||
if(ta.orbital != null) ta.orbital.lastRenderCall = System.currentTimeMillis();
|
||||
|
||||
if(ta.hasMultiblock() && ta.getStoredEssentia() > 0) {
|
||||
if(ta.orbital != null && ta.orbital.orbitalsSize() == 0) {
|
||||
fillOrbital(ta.orbital);
|
||||
}
|
||||
} else {
|
||||
if(ta.orbital != null && ta.orbital.orbitalsSize() > 0) {
|
||||
ta.orbital.clearOrbitals();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillOrbital(final Orbital orbital) {
|
||||
Orbital.OrbitalRenderProperties prop = new Orbital.OrbitalRenderProperties(Orbital.Axis.Y_AXIS, 1.5);
|
||||
prop.setTicksForFullCircle(50).setOffsetTicks(0);
|
||||
prop.setParticleSize(0F);
|
||||
prop.setRenderRunnable(new Orbital.OrbitalRenderRunnable() {
|
||||
@Override
|
||||
public void onRender(World world, Vector3 pos, Orbital.OrbitalRenderProperties properties, int orbitalExisted, float partialTicks) {
|
||||
if(rand.nextInt(3) == 0) {
|
||||
FXWisp ef = new FXWisp(world,
|
||||
pos.getX() + randomOffset(), pos.getY() + randomOffset(), pos.getZ() + randomOffset(),
|
||||
0.2F, 3);
|
||||
ef.setGravity(-0.08F);
|
||||
ParticleEngine.instance.addEffect(world, ef);
|
||||
}
|
||||
}
|
||||
});
|
||||
orbital.addOrbitalPoint(prop);
|
||||
|
||||
prop = new Orbital.OrbitalRenderProperties(Orbital.Axis.Y_AXIS, 1.5);
|
||||
prop.setTicksForFullCircle(50).setOffsetTicks(25);
|
||||
prop.setParticleSize(0F);
|
||||
prop.setRenderRunnable(new Orbital.OrbitalRenderRunnable() {
|
||||
@Override
|
||||
public void onRender(World world, Vector3 pos, Orbital.OrbitalRenderProperties properties, int orbitalExisted, float partialTicks) {
|
||||
if(rand.nextInt(3) == 0) {
|
||||
FXWisp ef = new FXWisp(world,
|
||||
pos.getX() + randomOffset(), pos.getY() + randomOffset(), pos.getZ() + randomOffset(),
|
||||
0.2F, 3);
|
||||
ef.setGravity(-0.08F);
|
||||
ParticleEngine.instance.addEffect(world, ef);
|
||||
}
|
||||
}
|
||||
});
|
||||
orbital.addOrbitalPoint(prop);
|
||||
|
||||
prop = new Orbital.OrbitalRenderProperties(Orbital.Axis.Y_AXIS, 3);
|
||||
prop.setTicksForFullCircle(90).setOffsetTicks(0);
|
||||
prop.setParticleSize(0F);
|
||||
prop.setRenderRunnable(new Orbital.OrbitalRenderRunnable() {
|
||||
@Override
|
||||
public void onRender(World world, Vector3 pos, Orbital.OrbitalRenderProperties properties, int orbitalExisted, float partialTicks) {
|
||||
if(rand.nextBoolean()) {
|
||||
FXWisp ef = new FXWisp(world,
|
||||
pos.getX() + randomOffset(), pos.getY() + randomOffset(), pos.getZ() + randomOffset(),
|
||||
0.15F, 5);
|
||||
ef.setGravity(-0.08F);
|
||||
ParticleEngine.instance.addEffect(world, ef);
|
||||
}
|
||||
}
|
||||
});
|
||||
orbital.addOrbitalPoint(prop);
|
||||
|
||||
prop = new Orbital.OrbitalRenderProperties(Orbital.Axis.Y_AXIS, 3);
|
||||
prop.setTicksForFullCircle(90).setOffsetTicks(30);
|
||||
prop.setParticleSize(0F);
|
||||
prop.setRenderRunnable(new Orbital.OrbitalRenderRunnable() {
|
||||
@Override
|
||||
public void onRender(World world, Vector3 pos, Orbital.OrbitalRenderProperties properties, int orbitalExisted, float partialTicks) {
|
||||
if(rand.nextBoolean()) {
|
||||
FXWisp ef = new FXWisp(world,
|
||||
pos.getX() + randomOffset(), pos.getY() + randomOffset(), pos.getZ() + randomOffset(),
|
||||
0.15F, 5);
|
||||
ef.setGravity(-0.08F);
|
||||
ParticleEngine.instance.addEffect(world, ef);
|
||||
}
|
||||
}
|
||||
});
|
||||
orbital.addOrbitalPoint(prop);
|
||||
|
||||
prop = new Orbital.OrbitalRenderProperties(Orbital.Axis.Y_AXIS, 3);
|
||||
prop.setTicksForFullCircle(90).setOffsetTicks(60);
|
||||
prop.setParticleSize(0F);
|
||||
prop.setRenderRunnable(new Orbital.OrbitalRenderRunnable() {
|
||||
@Override
|
||||
public void onRender(World world, Vector3 pos, Orbital.OrbitalRenderProperties properties, int orbitalExisted, float partialTicks) {
|
||||
if(rand.nextBoolean()) {
|
||||
FXWisp ef = new FXWisp(world,
|
||||
pos.getX() + randomOffset(), pos.getY() + randomOffset(), pos.getZ() + randomOffset(),
|
||||
0.15F, 5);
|
||||
ef.setGravity(-0.08F);
|
||||
ParticleEngine.instance.addEffect(world, ef);
|
||||
}
|
||||
}
|
||||
});
|
||||
orbital.addOrbitalPoint(prop);
|
||||
|
||||
}
|
||||
|
||||
private static float randomOffset() {
|
||||
return rand.nextFloat() * 0.2F;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -139,8 +139,7 @@ public class RenderTileAuraPylon extends TileEntitySpecialRenderer {
|
||||
private void addNewOrbitalPoint(Orbital orbital, Random rand, Color color) {
|
||||
Orbital.OrbitalRenderProperties properties = new Orbital.OrbitalRenderProperties(Orbital.Axis.persisentRandomAxis(), rand.nextDouble() + 2D);
|
||||
properties.setColor(color).setTicksForFullCircle(60 + rand.nextInt(40)).setOffsetTicks(rand.nextInt(80));
|
||||
color.brighter().brighter();
|
||||
properties.setSubParticleColor(color);
|
||||
properties.setSubParticleColor(color.brighter().brighter());
|
||||
orbital.addOrbitalPoint(properties);
|
||||
}
|
||||
|
||||
|
||||
@@ -278,6 +278,8 @@ public class BlockStoneMachine extends Block {
|
||||
setBlockBounds(0, 0, 0, 1, 3/16f, 1);
|
||||
} else if(metadata == 4) {
|
||||
setBlockBounds(0, 0, 0, 1, 12/16f, 1);
|
||||
} else if(metadata == 5) {
|
||||
setBlockBounds(0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
super.setBlockBoundsBasedOnState(world, x, y, z);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package makeo.gadomancy.common.blocks.tiles;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import makeo.gadomancy.client.effect.fx.Orbital;
|
||||
import makeo.gadomancy.common.registration.AIShutdownWhitelist;
|
||||
import makeo.gadomancy.common.registration.RegisteredMultiblocks;
|
||||
import makeo.gadomancy.common.utils.Injector;
|
||||
@@ -12,10 +13,12 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.ai.EntityAIBase;
|
||||
import net.minecraft.entity.ai.EntityAITasks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
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;
|
||||
@@ -25,6 +28,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -37,12 +41,16 @@ import java.util.UUID;
|
||||
*/
|
||||
public class TileAIShutdown extends SynchronizedTileEntity implements IAspectContainer, IEssentiaTransport {
|
||||
|
||||
private static final Random RAND = new Random();
|
||||
|
||||
private static Map<ChunkCoordinates, List<AffectedEntity>> trackedEntities = Maps.newHashMap();
|
||||
private static AxisAlignedBB BOX = AxisAlignedBB.getBoundingBox(-3, 1, -3, 4, 3, 4);
|
||||
private static AxisAlignedBB BOX = AxisAlignedBB.getBoundingBox(-3, -1, -3, 4, 2, 4);
|
||||
private static Injector injEntityLivingBase = new Injector(EntityLivingBase.class);
|
||||
|
||||
public static final int MAX_AMT = 16;
|
||||
|
||||
public Orbital orbital;
|
||||
|
||||
private int ticksExisted = 0;
|
||||
private int storedAmount = 0;
|
||||
private boolean foundMultiblock = false;
|
||||
@@ -76,14 +84,33 @@ public class TileAIShutdown extends SynchronizedTileEntity implements IAspectCon
|
||||
if((ticksExisted & 15) == 0) {
|
||||
killAI();
|
||||
}
|
||||
if(((ticksExisted & 7) == 0)) {
|
||||
handleIO();
|
||||
}
|
||||
} else {
|
||||
if(foundMultiblock) {
|
||||
if(foundMultiblock && storedAmount > 0) {
|
||||
//Effects?
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleIO() {
|
||||
if (storedAmount < MAX_AMT) {
|
||||
TileEntity te = ThaumcraftApiHelper.getConnectableTile(this.worldObj, this.xCoord, this.yCoord, this.zCoord, ForgeDirection.UP);
|
||||
if (te != null) {
|
||||
IEssentiaTransport ic = (IEssentiaTransport) te;
|
||||
if (!ic.canOutputTo(ForgeDirection.DOWN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ic.getSuctionAmount(ForgeDirection.DOWN) < getSuctionAmount(ForgeDirection.UP)) {
|
||||
addToContainer(Aspect.ENTROPY, ic.takeEssentia(Aspect.ENTROPY, 1, ForgeDirection.DOWN));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void killAI() {
|
||||
ChunkCoordinates cc = getCoords();
|
||||
List objEntityList = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, BOX.copy().offset(xCoord, yCoord, zCoord));
|
||||
@@ -91,6 +118,7 @@ public class TileAIShutdown extends SynchronizedTileEntity implements IAspectCon
|
||||
if(o != null && o instanceof EntityLiving &&
|
||||
!((EntityLiving) o).isDead && canAffect((EntityLiving) o)) {
|
||||
EntityLiving el = (EntityLiving) o;
|
||||
if(storedAmount <= 0) return;
|
||||
AffectedEntity affected = removeAI(el);
|
||||
trackedEntities.get(cc).add(affected);
|
||||
}
|
||||
@@ -98,6 +126,12 @@ public class TileAIShutdown extends SynchronizedTileEntity implements IAspectCon
|
||||
}
|
||||
|
||||
private AffectedEntity removeAI(EntityLiving el) {
|
||||
if(RAND.nextInt(4) == 0) {
|
||||
storedAmount = Math.max(0, storedAmount - 1);
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
UUID uu = el.getUniqueID();
|
||||
List<EntityAITasks.EntityAITaskEntry> tasks =
|
||||
new ArrayList<EntityAITasks.EntityAITaskEntry>(el.tasks.taskEntries);
|
||||
@@ -143,6 +177,17 @@ public class TileAIShutdown extends SynchronizedTileEntity implements IAspectCon
|
||||
markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
if(!foundMultiblock) {
|
||||
storedAmount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasMultiblock() {
|
||||
return foundMultiblock;
|
||||
}
|
||||
|
||||
public int getStoredEssentia() {
|
||||
return storedAmount;
|
||||
}
|
||||
|
||||
public boolean canAffect(EntityLiving el) {
|
||||
@@ -156,7 +201,8 @@ public class TileAIShutdown extends SynchronizedTileEntity implements IAspectCon
|
||||
}
|
||||
|
||||
private boolean checkGrassBlocks() {
|
||||
return MultiblockHelper.isMultiblockPresent(worldObj, xCoord, yCoord, zCoord, RegisteredMultiblocks.aiShutdownPattern);
|
||||
boolean mbPresent = MultiblockHelper.isMultiblockPresent(worldObj, xCoord, yCoord, zCoord, RegisteredMultiblocks.aiShutdownPattern);
|
||||
return mbPresent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,7 +233,7 @@ public class TileAIShutdown extends SynchronizedTileEntity implements IAspectCon
|
||||
|
||||
@Override
|
||||
public boolean doesContainerAccept(Aspect aspect) {
|
||||
return false;
|
||||
return aspect == Aspect.ENTROPY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -237,7 +283,7 @@ public class TileAIShutdown extends SynchronizedTileEntity implements IAspectCon
|
||||
|
||||
@Override
|
||||
public boolean isConnectable(ForgeDirection direction) {
|
||||
return direction != null && direction.equals(ForgeDirection.DOWN);
|
||||
return direction != null && direction.equals(ForgeDirection.UP);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -247,7 +293,7 @@ public class TileAIShutdown extends SynchronizedTileEntity implements IAspectCon
|
||||
|
||||
@Override
|
||||
public boolean canOutputTo(ForgeDirection direction) {
|
||||
return false;
|
||||
return isConnectable(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,7 +308,7 @@ public class TileAIShutdown extends SynchronizedTileEntity implements IAspectCon
|
||||
@Override
|
||||
public int getSuctionAmount(ForgeDirection direction) {
|
||||
if(!isConnectable(direction)) return 0;
|
||||
return 64;
|
||||
return getMinimumSuction();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -277,13 +323,13 @@ public class TileAIShutdown extends SynchronizedTileEntity implements IAspectCon
|
||||
|
||||
@Override
|
||||
public Aspect getEssentiaType(ForgeDirection direction) {
|
||||
if(!isConnectable(direction)) return null;
|
||||
return Aspect.ENTROPY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEssentiaAmount(ForgeDirection direction) {
|
||||
return 0;
|
||||
if(!isConnectable(direction)) return 0;
|
||||
return storedAmount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package makeo.gadomancy.common.blocks.tiles;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 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 makeo @ 05.06.2016 15:35
|
||||
*/
|
||||
public class TileAISuppressor extends SynchronizedTileEntity {
|
||||
|
||||
private static final AxisAlignedBB PART_RANGE = AxisAlignedBB.getBoundingBox(0, 0, 0, 10, 10, 10);
|
||||
|
||||
private Map<Entity, Float> tracked = new HashMap<Entity, Float>();
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if(count++ % 10 == 0) {
|
||||
AxisAlignedBB cube = PART_RANGE.addCoord(xCoord + .5 - ((PART_RANGE.maxX - PART_RANGE.minX) / 2), yCoord + .5 - ((PART_RANGE.maxY - PART_RANGE.minY) / 2), zCoord + .5 - ((PART_RANGE.maxZ - PART_RANGE.minZ) / 2));
|
||||
List<Entity> entities = worldObj.getEntitiesWithinAABB(Entity.class, cube);
|
||||
|
||||
List<Entity> outdated = new ArrayList<Entity>(tracked.keySet());
|
||||
|
||||
for(Entity entity : entities) {
|
||||
if(!tracked.containsKey(entity)) {
|
||||
tracked.put(entity, entity.entityCollisionReduction);
|
||||
}
|
||||
|
||||
entity.entityCollisionReduction = 0;
|
||||
outdated.remove(entity);
|
||||
}
|
||||
|
||||
for(Entity entity : outdated) {
|
||||
float val = tracked.get(entity);
|
||||
tracked.remove(entity);
|
||||
entity.entityCollisionReduction = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,8 +47,8 @@ public class RegisteredMultiblocks {
|
||||
|
||||
static {
|
||||
for (int xx = -3; xx <= 3; xx++) {
|
||||
for (int zz = -3; zz <= -3; zz++) {
|
||||
aiShutdownPattern.addBlock(xx, 1, zz, Blocks.grass, 0);
|
||||
for (int zz = -3; zz <= 3; zz++) {
|
||||
aiShutdownPattern.addBlock(xx, -1, zz, Blocks.grass, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user