mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
added the aura spread effect and a nice clientside display of where aura spots are for debugging
This commit is contained in:
parent
656a76980b
commit
5700ab3053
5 changed files with 153 additions and 4 deletions
|
@ -38,7 +38,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile "vazkii.patchouli:Patchouli:1.0-10.45"
|
||||
compile "vazkii.patchouli:Patchouli:1.0-12.61"
|
||||
|
||||
deobfCompile "mezz.jei:jei_1.12.2:4.13.1.220"
|
||||
deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2"
|
||||
|
|
|
@ -54,6 +54,12 @@ public final class ModConfig {
|
|||
|
||||
@Comment("If particle spawning should respect the particle setting in Minecraft's video settings screen")
|
||||
public boolean respectVanillaParticleSettings = true;
|
||||
|
||||
@Comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
|
||||
public boolean debugText = true;
|
||||
|
||||
@Comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the world for debug purposes")
|
||||
public boolean debugWorld = false;
|
||||
}
|
||||
|
||||
public static void initOrReload(boolean reload) {
|
||||
|
|
|
@ -11,5 +11,6 @@ public final class DrainSpotEffects {
|
|||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(BalanceEffect.NAME, BalanceEffect::new);
|
||||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(ExplosionEffect.NAME, ExplosionEffect::new);
|
||||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(BreathlessEffect.NAME, BreathlessEffect::new);
|
||||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(SpreadEffect.NAME, SpreadEffect::new);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package de.ellpeck.naturesaura.chunk.effect;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
public class SpreadEffect implements IDrainSpotEffect {
|
||||
|
||||
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "spread");
|
||||
|
||||
@Override
|
||||
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (Math.abs(spot) < 10000)
|
||||
return;
|
||||
boolean drain = spot > 0;
|
||||
int toMove = 7200;
|
||||
while (toMove > 0) {
|
||||
BlockPos bestOffset = null;
|
||||
int bestAmount = drain ? Integer.MAX_VALUE : Integer.MIN_VALUE;
|
||||
for (EnumFacing facing : EnumFacing.VALUES) {
|
||||
BlockPos offset = pos.offset(facing, 15);
|
||||
int amount = IAuraChunk.getAuraInArea(world, offset, 14);
|
||||
if (drain ? amount < bestAmount : amount > bestAmount) {
|
||||
bestAmount = amount;
|
||||
bestOffset = offset;
|
||||
}
|
||||
}
|
||||
|
||||
BlockPos bestPos = drain ? IAuraChunk.getLowestSpot(world, bestOffset, 14, bestOffset)
|
||||
: IAuraChunk.getHighestSpot(world, bestOffset, 14, bestOffset);
|
||||
IAuraChunk bestChunk = IAuraChunk.getAuraChunk(world, bestPos);
|
||||
|
||||
int moved;
|
||||
if (drain) {
|
||||
moved = bestChunk.storeAura(bestPos, 1200);
|
||||
auraChunk.drainAura(pos, moved);
|
||||
} else {
|
||||
moved = bestChunk.drainAura(bestPos, 1200);
|
||||
auraChunk.storeAura(pos, moved);
|
||||
}
|
||||
toMove -= moved;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.events;
|
||||
|
||||
import baubles.api.BaublesApi;
|
||||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
|
@ -35,8 +36,11 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import net.minecraftforge.items.IItemHandler;
|
||||
import org.apache.commons.lang3.mutable.MutableFloat;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientEvents {
|
||||
|
@ -47,7 +51,7 @@ public class ClientEvents {
|
|||
public void onDebugRender(RenderGameOverlayEvent.Text event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onDebugRender");
|
||||
if (mc.gameSettings.showDebugInfo) {
|
||||
if (mc.gameSettings.showDebugInfo && ModConfig.client.debugText) {
|
||||
String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " ";
|
||||
List<String> left = event.getLeft();
|
||||
left.add("");
|
||||
|
@ -57,12 +61,12 @@ public class ClientEvents {
|
|||
left.add(prefix + "Aura (range 35)");
|
||||
MutableInt amount = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
||||
MutableInt spots = new MutableInt();
|
||||
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 35, ((blockPos, drainSpot) -> {
|
||||
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 35, (blockPos, drainSpot) -> {
|
||||
spots.increment();
|
||||
amount.add(drainSpot);
|
||||
if (mc.player.isSneaking())
|
||||
left.add(prefix + drainSpot + " @ " + blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ());
|
||||
}));
|
||||
});
|
||||
left.add(prefix + "Total: " + amount.intValue() + " in " + spots.intValue() + " spots");
|
||||
left.add(prefix + "Type: " + IAuraType.forWorld(mc.world).getName());
|
||||
}
|
||||
|
@ -93,6 +97,84 @@ public class ClientEvents {
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldRender(RenderWorldLastEvent event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onWorldRender");
|
||||
if (mc.gameSettings.showDebugInfo && mc.player.capabilities.isCreativeMode && ModConfig.client.debugWorld) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
float partial = event.getPartialTicks();
|
||||
GL11.glTranslated(
|
||||
-mc.player.prevPosX - (mc.player.posX - mc.player.prevPosX) * partial,
|
||||
-mc.player.prevPosY - (mc.player.posY - mc.player.prevPosY) * partial,
|
||||
-mc.player.prevPosZ - (mc.player.posZ - mc.player.prevPosZ) * partial);
|
||||
|
||||
Map<BlockPos, Integer> spots = new HashMap<>();
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBegin(GL11.GL_QUADS);
|
||||
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 64, (pos, spot) -> {
|
||||
spots.put(pos, spot);
|
||||
|
||||
GlStateManager.color(spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.5F);
|
||||
int x = pos.getX();
|
||||
int y = pos.getY();
|
||||
int z = pos.getZ();
|
||||
GL11.glVertex3d(x, y + 1, z);
|
||||
GL11.glVertex3d(x + 1, y + 1, z);
|
||||
GL11.glVertex3d(x + 1, y, z);
|
||||
GL11.glVertex3d(x, y, z);
|
||||
GL11.glVertex3d(x + 1, y, z + 1);
|
||||
GL11.glVertex3d(x + 1, y, z);
|
||||
GL11.glVertex3d(x + 1, y + 1, z);
|
||||
GL11.glVertex3d(x + 1, y + 1, z + 1);
|
||||
GL11.glVertex3d(x + 1, y + 1, z + 1);
|
||||
GL11.glVertex3d(x, y + 1, z + 1);
|
||||
GL11.glVertex3d(x, y, z + 1);
|
||||
GL11.glVertex3d(x + 1, y, z + 1);
|
||||
GL11.glVertex3d(x, y + 1, z + 1);
|
||||
GL11.glVertex3d(x, y + 1, z);
|
||||
GL11.glVertex3d(x, y, z);
|
||||
GL11.glVertex3d(x, y, z + 1);
|
||||
GL11.glVertex3d(x, y + 1, z);
|
||||
GL11.glVertex3d(x, y + 1, z + 1);
|
||||
GL11.glVertex3d(x + 1, y + 1, z + 1);
|
||||
GL11.glVertex3d(x + 1, y + 1, z);
|
||||
GL11.glVertex3d(x + 1, y, z);
|
||||
GL11.glVertex3d(x + 1, y, z + 1);
|
||||
GL11.glVertex3d(x, y, z + 1);
|
||||
GL11.glVertex3d(x, y, z);
|
||||
});
|
||||
GL11.glEnd();
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopAttrib();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
float scale = 0.03F;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
for (Map.Entry<BlockPos, Integer> spot : spots.entrySet()) {
|
||||
BlockPos pos = spot.getKey();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((pos.getX() + 0.1) / scale, (pos.getY() + 1) / scale, (pos.getZ() + 0.1) / scale);
|
||||
GlStateManager.rotate(90F, 1F, 0F, 0F);
|
||||
mc.fontRenderer.drawString(spot.getValue().toString(), 0, 0, 0);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
mc.profiler.endSection();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
|
Loading…
Reference in a new issue