Rendering fixes

Redid the *RiftFX classes based on the old 1.6.4 code, but overriding ParticleSimpleAnimated.
This commit is contained in:
Runemoro 2017-12-20 11:06:49 -05:00
parent 3d50cd8fdf
commit 0599a6d340
9 changed files with 129 additions and 139 deletions

View file

@ -1,6 +1,8 @@
language: java
notifications:
email: false
if: tag IS blank
before_install: chmod +x gradlew
install: "./gradlew setupCIWorkspace"
script: "./gradlew build"
@ -13,6 +15,7 @@ cache:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
sudo: false
deploy:
skip_cleanup: true
provider: releases

View file

@ -1,88 +0,0 @@
package com.zixiken.dimdoors.client;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ClosingRiftFX extends Particle {
private int baseTextureIndex = 160;
private boolean trail;
private boolean twinkle;
private float fadeColourRed;
private float fadeColourGreen;
private float fadeColourBlue;
private boolean hasFadeColour;
public ClosingRiftFX(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
super(world, x, y, z);
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
particleScale *= .55F;
particleMaxAge = 30 + rand.nextInt(16);
}
@Override
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX,
float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
if (!twinkle || particleAge < particleMaxAge / 3 || (particleAge + particleMaxAge) / 3 % 2 == 0) {
super.renderParticle(buffer, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
}
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate() {
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
particleAge++;
if (particleAge >= particleMaxAge) {
setExpired();
}
if (particleAge > particleMaxAge / 2) {
setAlphaF(1.0F - ((float) particleAge - (float) (particleMaxAge / 2)) / particleMaxAge);
if (hasFadeColour) {
particleRed += (fadeColourRed - particleRed) * 0.2F;
particleGreen += (fadeColourGreen - particleGreen) * 0.2F;
particleBlue += (fadeColourBlue - particleBlue) * 0.2F;
}
}
setParticleTextureIndex(baseTextureIndex + 7 - particleAge * 8 / particleMaxAge);
// this.motionY -= 0.004D;
move(motionX, motionY, motionZ);
motionX *= 0.9100000262260437D;
motionY *= 0.9100000262260437D;
motionZ *= 0.9100000262260437D;
if (trail && particleAge < particleMaxAge / 2 && (particleAge + particleMaxAge) % 2 == 0) {
ClosingRiftFX var1 = new ClosingRiftFX(world, posX, posY, posZ, 0.0D, 0.0D, 0.0D);
var1.setRBGColorF(particleRed, particleGreen, particleBlue);
var1.particleAge = var1.particleMaxAge / 2;
if (hasFadeColour) {
var1.hasFadeColour = true;
var1.fadeColourRed = fadeColourRed;
var1.fadeColourGreen = fadeColourGreen;
var1.fadeColourBlue = fadeColourBlue;
}
var1.twinkle = twinkle;
}
}
@Override
public int getBrightnessForRender(float p_189214_1_) {
return 15728880;
}
}

View file

@ -6,11 +6,8 @@ import net.minecraftforge.client.IRenderHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class CloudRenderBlank extends IRenderHandler
{
public class CloudRenderBlank extends IRenderHandler {
@Override
@SideOnly(Side.CLIENT)
public void render(float partialTicks, WorldClient world, Minecraft mc) {
}
public void render(float partialTicks, WorldClient world, Minecraft mc) {}
}

View file

@ -18,13 +18,13 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
@SideOnly(Side.CLIENT) // 8 4
public class DDProxyClient extends DDProxyCommon {
@Override
public void onPreInitialization(FMLPreInitializationEvent event) {
super.onPreInitialization(event);
//ModelManager.addCustomStateMappers();
// ModelManager.addCustomStateMappers(); // TODO: fix this
ModelManager.registerModelVariants();
registerRenderers();
}

View file

@ -1,15 +0,0 @@
package com.zixiken.dimdoors.client;
import net.minecraft.client.particle.ParticleCloud;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GoggleRiftFX extends ParticleCloud {
public GoggleRiftFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12) {
super(par1World, par2, par4, par6, par12, par12, par12);
particleMaxAge = 40 + rand.nextInt(26);
}
}

View file

@ -0,0 +1,59 @@
package com.zixiken.dimdoors.client;
import com.zixiken.dimdoors.shared.util.WorldUtils;
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
import net.minecraft.client.particle.ParticleFirework;
import net.minecraft.client.particle.ParticleSimpleAnimated;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
// This has exactly the same appearence as the 1.6.4 mod.
public class ParticleRiftEffect extends ParticleSimpleAnimated { // TODO: colors, density
private float colorMultiplier;
public ParticleRiftEffect(World world, double x, double y, double z, double motionX, double motionY, double motionZ, float nonPocketColorMultiplier, float pocketColorMultiplier, float scale, int size, int spread) {
super(world, x, y, z, 160, 8, 0);
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
particleScale *= scale;
particleMaxAge = size - spread / 2 + rand.nextInt(spread);
colorMultiplier = DimDoorDimensions.isPocketDimension(WorldUtils.getDim(world)) ? pocketColorMultiplier : nonPocketColorMultiplier;
}
@Override
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
if (particleAge < particleMaxAge / 3 || (particleAge + particleMaxAge) / 3 % 2 == 0) {
float oldRed = particleRed;
float oldGreen = particleGreen;
float oldBlue = particleBlue;
float oldAlpha = particleAlpha;
setRBGColorF(colorMultiplier * particleRed, colorMultiplier * particleGreen, colorMultiplier * particleBlue);
setAlphaF(0.7f);
super.renderParticle(buffer, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
setRBGColorF(oldRed, oldGreen, oldBlue);
setAlphaF(oldAlpha);
}
}
public static class Rift extends ParticleRiftEffect {
public Rift(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
super(world, x, y, z, motionX, motionY, motionZ, 0.0f, 0.7f, 0.55f, 38, 16);
}
}
public static class ClosingRiftEffect extends ParticleRiftEffect {
public ClosingRiftEffect(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
super(world, x, y, z, motionX, motionY, motionZ, 0.8f, 0.4f, 0.55f, 38, 16);
}
}
public static class GogglesRiftEffect extends ParticleRiftEffect {
public GogglesRiftEffect(World world, double x, double y, double z, double motionX, double motionY, double motionZ) {
super(world, x, y, z, motionX, motionY, motionZ, 0.0f, 0.7f, 0.55f, 38, 16);
}
}
}

View file

@ -1,15 +1,12 @@
package com.zixiken.dimdoors.shared.blocks;
import com.zixiken.dimdoors.DimDoors;
import com.zixiken.dimdoors.client.ClosingRiftFX;
import com.zixiken.dimdoors.client.GoggleRiftFX;
import com.zixiken.dimdoors.client.ParticleRiftEffect;
import com.zixiken.dimdoors.shared.items.ModItems;
import com.zixiken.dimdoors.shared.tileentities.TileEntityFloatingRift;
import java.util.*;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDoor;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.EnumPushReaction;
import net.minecraft.block.material.Material;
@ -134,24 +131,27 @@ public class BlockRift extends Block implements ITileEntityProvider {
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
//ArrayList<BlockPos> targets = findReachableBlocks(worldIn, pos, 2, false);
//TODO: implement the parts specified in the method comment?
int x = pos.getX(), y = pos.getY(), z = pos.getZ();
//ArrayList<BlockPos> targets = findReachableBlocks(worldIn, pos, 2, false); // TODO
TileEntityFloatingRift rift = (TileEntityFloatingRift) worldIn.getTileEntity(pos);
TileEntityFloatingRift tile = (TileEntityFloatingRift) worldIn.getTileEntity(pos);
//renders an extra little blob on top of the actual rift location so its easier to find.
// Eventually will only renderDoorRift if the player has the goggles.
//FMLClientHandler.instance().getClient().effectRenderer.addEffect(new GoggleRiftFX(
/* worldIn,
x + .5, y + .5, z + .5,
rand.nextGaussian() * 0.01D,
rand.nextGaussian() * 0.01D,
rand.nextGaussian() * 0.01D));*/
if (tile.shouldClose) { //renders an opposite color effect if it is being closed by the rift remover
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ClosingRiftFX(
if (true) {
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect.Rift( // TODO: this effect was unfinished in the 1.6.4 mod too
worldIn,
x + .5, y + .5, z + .5,
pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5,
rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D));
}
if (false) {
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect.GogglesRiftEffect( // TODO: this effect was unfinished in the 1.6.4 mod too
worldIn,
pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5,
rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D));
}
if (rift.shouldClose) { // Renders an opposite color effect if it is being closed by the rift remover
FMLClientHandler.instance().getClient().effectRenderer.addEffect(new ParticleRiftEffect.ClosingRiftEffect(
worldIn,
pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5,
rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D, rand.nextGaussian() * 0.01D));
}
}

View file

@ -0,0 +1,40 @@
package com.zixiken.dimdoors.shared.util;
import net.minecraft.entity.Entity;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class MCPReflection {
public static Field getMCPField(Class<?> class0, String deobfuscatedName, String obfuscatedName) throws NoSuchFieldException {
Field field;
try {
field = class0.getDeclaredField(obfuscatedName);
} catch (NoSuchFieldException e) { // Running on deobfuscated Minecraft
field = class0.getDeclaredField(deobfuscatedName);
}
field.setAccessible(true);
try {
Field modifiers = Field.class.getDeclaredField("modifiers");
modifiers.setAccessible(true);
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
return field;
}
public static Method getMCPMethod(Class<?> class0, String deobfuscatedName, String obfuscatedName, Class<?> args) throws NoSuchMethodException {
Method method;
try {
method = Entity.class.getDeclaredMethod(obfuscatedName, args);
} catch (NoSuchMethodException e) { // Running on deobfuscated Minecraft
method = Entity.class.getDeclaredMethod(deobfuscatedName, args);
}
method.setAccessible(true);
return method;
}
}

View file

@ -2,6 +2,7 @@ package com.zixiken.dimdoors.shared.util;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.play.server.*;
import net.minecraft.potion.PotionEffect;
@ -76,13 +77,7 @@ public class TeleportUtils {
if (entity instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) entity;
try {
Field invulnerableDimensionChange;
try {
invulnerableDimensionChange = EntityPlayerMP.class.getDeclaredField("field_184851_cj"); // If this breaks, check that Minecraft didn't rename the field
} catch (NoSuchFieldException e) { // Running on deobfuscated Minecraft
invulnerableDimensionChange = EntityPlayerMP.class.getDeclaredField("invulnerableDimensionChange");
}
invulnerableDimensionChange.setAccessible(true);
Field invulnerableDimensionChange = MCPReflection.getMCPField(EntityPlayerMP.class, "invulnerableDimensionChange", "field_184851_cj");
invulnerableDimensionChange.setBoolean(player, true); // Prevent Minecraft from cancelling the position change being too big if the player is not in creative
} catch (NoSuchFieldException|IllegalAccessException e) {
throw new RuntimeException(e);
@ -142,8 +137,7 @@ public class TeleportUtils {
if (newEntity != null) {
try {
Method copyDataFromOld = Entity.class.getDeclaredMethod("copyDataFromOld", Entity.class);
copyDataFromOld.setAccessible(true);
Method copyDataFromOld = MCPReflection.getMCPMethod(Entity.class,"copyDataFromOld", "func_180432_n", Entity.class);
copyDataFromOld.invoke(newEntity, entity);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(e);