Added rainbows

This commit is contained in:
Sollace 2019-02-04 15:25:12 +02:00
parent 307e83770c
commit 1f259a7e22
6 changed files with 353 additions and 12 deletions

128
rainbow.svg Normal file
View file

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="241.44592mm"
height="241.44592mm"
viewBox="0 0 241.44592 241.44592"
version="1.1"
id="svg8"
sodipodi:docname="rainbow.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<defs
id="defs2">
<mask
maskUnits="userSpaceOnUse"
id="mask891">
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M -3.7233945,214.15447 C 45.480637,96.633673 161.83001,111.85648 220.14571,211.36193"
id="path893"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</mask>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath927">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M -4.2783609,209.45815 C 27.595941,225.58204 39.492563,194.31934 40.808982,191.6865 42.1254,189.05366 66.479153,155.81408 104.9844,160.09245 c 38.50525,4.27836 79.31422,47.39107 81.94706,53.64406 2.63284,6.25299 17.44255,5.59478 33.56868,-5.59478 C 236.62627,196.95217 196.9884,109.17656 107.94634,104.47375 18.904283,99.770936 -36.152661,193.33426 -4.2783609,209.45815 Z"
id="path929"
inkscape:connector-curvature="0"
sodipodi:nodetypes="zzzzzzz" />
</clipPath>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="0.56847767"
inkscape:cx="446.57708"
inkscape:cy="401.19458"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
objecttolerance="1"
inkscape:window-width="1600"
inkscape:window-height="837"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="true"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(16.892626,19.317423)">
<g
id="g889"
mask="url(#mask891)"
clip-path="url(#clipPath927)">
<g
id="g937">
<path
style="fill:none;fill-rule:evenodd;stroke:#ff5a5a;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M -3.7233944,214.15447 C 45.480638,96.63367 161.83001,111.85648 220.14571,211.36193"
id="path823-5"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ff9e5a;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M -0.7614527,220.40746 C 56.341093,103.87397 159.19717,123.04604 217.51287,222.55149"
id="path823-5-1"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffbe80;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 1.5789981,231.68901 C 58.681549,115.15552 152.6518,129.72013 210.9675,229.22558"
id="path823-5-1-5"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#f7ff80;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 9.1484066,236.95589 C 66.250956,120.4224 152.32269,142.88552 210.63839,242.39096"
id="path823-5-1-5-4"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#80c9ff;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 15.401395,246.03534 C 72.503944,129.50186 146.72791,151.63588 205.04361,251.14131"
id="path823-5-1-5-4-8"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#be80ff;stroke-width:52.91666794;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 22.806252,250.84622 C 75.30134,134.64185 142.6141,162.04155 200.9298,261.54697"
id="path823-5-1-5-4-8-3"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -1,23 +1,23 @@
package com.minelittlepony.unicopia;
import java.util.List;
import com.minelittlepony.unicopia.entity.EntityCloud;
import com.minelittlepony.unicopia.entity.EntityConstructionCloud;
import com.minelittlepony.unicopia.entity.EntityRacingCloud;
import com.minelittlepony.unicopia.entity.EntityRainbow;
import com.minelittlepony.unicopia.entity.EntitySpell;
import com.minelittlepony.unicopia.entity.EntitySpellbook;
import com.minelittlepony.unicopia.entity.EntityProjectile;
import com.minelittlepony.unicopia.entity.EntityWildCloud;
import com.minelittlepony.unicopia.forgebullshit.BiomeBS;
import com.minelittlepony.unicopia.forgebullshit.EntityType;
import com.minelittlepony.unicopia.render.RenderCloud;
import com.minelittlepony.unicopia.render.RenderGem;
import com.minelittlepony.unicopia.render.RenderProjectile;
import com.minelittlepony.unicopia.render.RenderRainbow;
import com.minelittlepony.unicopia.render.RenderSpellbook;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.SpawnListEntry;
import net.minecraft.world.biome.BiomeEnd;
import net.minecraft.world.biome.BiomeHell;
import net.minecraftforge.common.BiomeManager;
@ -38,6 +38,8 @@ public class UEntities {
builder.creature(EntityConstructionCloud.class, "construction_cloud"),
builder.creature(EntitySpell.class, "magic_spell"),
builder.creature(EntitySpellbook.class, "spellbook"),
builder.creature(EntityRainbow.Spawner.class, "rainbow_spawner"),
builder.projectile(EntityRainbow.class, "rainbow", 500, 5),
builder.projectile(EntityProjectile.class, "thrown_item", 10, 5)
);
}
@ -47,19 +49,18 @@ public class UEntities {
RenderingRegistry.registerEntityRenderingHandler(EntitySpell.class, RenderGem::new);
RenderingRegistry.registerEntityRenderingHandler(EntityProjectile.class, RenderProjectile::new);
RenderingRegistry.registerEntityRenderingHandler(EntitySpellbook.class, RenderSpellbook::new);
RenderingRegistry.registerEntityRenderingHandler(EntityRainbow.class, RenderRainbow::new);
}
static void registerSpawnEntries(Biome biome) {
if (!(biome instanceof BiomeHell || biome instanceof BiomeEnd)) {
List<SpawnListEntry> entries = biome.getSpawnableList(EnumCreatureType.AMBIENT);
entries.stream().filter(p -> p.entityClass == EntityWildCloud.class).findFirst().orElseGet(() -> {
entries.add(
BiomeManager.oceanBiomes.contains(biome) ?
EntityWildCloud.SPAWN_ENTRY_LAND : EntityWildCloud.SPAWN_ENTRY_OCEAN
);
return null;
});
BiomeBS.addSpawnEntry(biome, EnumCreatureType.AMBIENT, EntityWildCloud.class, b ->
BiomeManager.oceanBiomes.contains(b) ? EntityWildCloud.SPAWN_ENTRY_LAND : EntityWildCloud.SPAWN_ENTRY_OCEAN
);
BiomeBS.addSpawnEntry(biome, EnumCreatureType.CREATURE, EntityRainbow.Spawner.class, b -> EntityRainbow.SPAWN_ENTRY);
}
}
}

View file

@ -0,0 +1,128 @@
package com.minelittlepony.unicopia.entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.effect.EntityWeatherEffect;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome.SpawnListEntry;
public class EntityRainbow extends EntityWeatherEffect {
public static final SpawnListEntry SPAWN_ENTRY = new SpawnListEntry(EntityRainbow.Spawner.class, 1, 1, 1);
private int ticksAlive;
private double radius;
public static final int RAINBOW_MAX_SIZE = 180;
public static final int RAINBOW_MIN_SIZE = 50;
public EntityRainbow(World world) {
this(world, 0, 0, 0);
}
public EntityRainbow(World world, double x, double y, double z) {
super(world);
float yaw = (int)MathHelper.nextDouble((world == null ? rand : world.rand), 0, 360);
setLocationAndAngles(x, y, z, yaw, 0);
radius = MathHelper.nextDouble(world == null ? rand : world.rand, RAINBOW_MIN_SIZE, RAINBOW_MAX_SIZE);
ticksAlive = 10000;
ignoreFrustumCheck = true;
width = (float)radius;
height = width;
}
@Override
public void setPosition(double x, double y, double z) {
posX = x;
posY = y;
posZ = z;
setEntityBoundingBox(new AxisAlignedBB(
x - width, y - radius/2, z,
x + width, y + radius/2, z
));
}
@Override
public AxisAlignedBB getRenderBoundingBox() {
return super.getRenderBoundingBox();
}
@Override
public SoundCategory getSoundCategory() {
return SoundCategory.WEATHER;
}
@Override
public boolean isInRangeToRenderDist(double distance) {
return true;
}
public double getRadius() {
return radius;
}
@Override
public void onUpdate() {
super.onUpdate();
if (ticksAlive-- <= 0) {
setDead();
}
}
@Override
protected void entityInit() {
}
@Override
protected void readEntityFromNBT(NBTTagCompound compound) {
}
@Override
protected void writeEntityToNBT(NBTTagCompound compound) {
}
public static class Spawner extends EntityLiving {
public static final AxisAlignedBB SPAWN_COLLISSION_RADIUS = new AxisAlignedBB(0, 0, 0, RAINBOW_MAX_SIZE, RAINBOW_MAX_SIZE, RAINBOW_MAX_SIZE);
public Spawner(World worldIn) {
super(worldIn);
this.setInvisible(true);
}
@Override
public boolean getCanSpawnHere() {
if (super.getCanSpawnHere()) {
return world.getEntitiesWithinAABB(EntityRainbow.class, SPAWN_COLLISSION_RADIUS.offset(getPosition())).size() == 0;
}
return false;
}
@Override
public int getMaxSpawnedInChunk() {
return 1;
}
@Override
public void onUpdate() {
super.onUpdate();
setDead();
EntityRainbow rainbow = new EntityRainbow(world);
rainbow.setPosition(posX, posY, posZ);
world.spawnEntity(rainbow);
}
}
}

View file

@ -1,10 +1,15 @@
package com.minelittlepony.unicopia.forgebullshit;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import com.google.common.collect.Lists;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.SpawnListEntry;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.BiomeManager.BiomeType;
@ -24,4 +29,16 @@ public class BiomeBS {
.isPresent()
).findFirst();
}
/**
* Adds a spawn entry for the specified entity if one does not already exist.
*/
public static void addSpawnEntry(Biome biome, EnumCreatureType list, Class<? extends EntityLivingBase> type, Function<Biome, SpawnListEntry> func) {
List<SpawnListEntry> entries = biome.getSpawnableList(list);
entries.stream().filter(p -> p.entityClass == type).findFirst().orElseGet(() -> {
entries.add(func.apply(biome));
return null;
});
}
}

View file

@ -0,0 +1,67 @@
package com.minelittlepony.unicopia.render;
import org.lwjgl.opengl.GL11;
import com.minelittlepony.unicopia.entity.EntityRainbow;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
public class RenderRainbow extends Render<EntityRainbow> {
public RenderRainbow(RenderManager renderManager) {
super(renderManager);
}
private static final ResourceLocation TEXTURE = new ResourceLocation("unicopia", "textures/environment/rainbow.png");
public void doRender(EntityRainbow entity, double x, double y, double z, float entityYaw, float partialTicks) {
bindEntityTexture(entity);
GlStateManager.pushMatrix();
GlStateManager.disableLighting();
GlStateManager.disableCull();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.translate(x, y, z);
GlStateManager.rotate(entityYaw, 0, 1, 0);
float distance = Minecraft.getMinecraft().getRenderViewEntity().getDistance(entity);
float maxDistance = 16 * Minecraft.getMinecraft().gameSettings.renderDistanceChunks;
GlStateManager.color(1, 1, 1, ((maxDistance - distance) / maxDistance) * 0.9f);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
double r = entity.getRadius();
bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
bufferbuilder.pos(-r, r, 0).tex(1, 0).endVertex();
bufferbuilder.pos( r, r, 0).tex(0, 0).endVertex();
bufferbuilder.pos( r, 0, 0).tex(0, 1).endVertex();
bufferbuilder.pos(-r, 0, 0).tex(1, 1).endVertex();
tessellator.draw();
GlStateManager.disableBlend();
GlStateManager.enableCull();
GlStateManager.enableLighting();
GlStateManager.popMatrix();
}
@Override
protected ResourceLocation getEntityTexture(EntityRainbow entity) {
return TEXTURE;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB