feat: fix and add some bugs

This commit is contained in:
LordMZTE 2022-11-23 18:30:48 +01:00
parent 63f12376f7
commit 8008a3cece
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
5 changed files with 248 additions and 210 deletions

6
austri3Fix.md Normal file
View file

@ -0,0 +1,6 @@
- plant effects not implemented
- entity position borked on client after teleport
- machines not yet implemented
- portal renders corners (GL stencil borked)
- portal seals that are broken sometimes don't get unregistered
- chunks not loading randomly???

View file

@ -3,10 +3,14 @@ package net.anvilcraft.arcaneseals;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent;
import net.anvilcraft.arcaneseals.render.PortalRenderer; import net.anvilcraft.arcaneseals.render.PortalRenderer;
import net.minecraft.client.Minecraft;
public class RenderTicker { public class RenderTicker {
@SubscribeEvent @SubscribeEvent
public void onRenderTickEvent(RenderTickEvent ev) { public void onRenderTickEvent(RenderTickEvent ev) {
if (Minecraft.getMinecraft().theWorld == null)
return;
for (PortalRenderer ren : PortalRenderer.INSTANCES) { for (PortalRenderer ren : PortalRenderer.INSTANCES) {
// TODO: optimize // TODO: optimize
ren.createPortalView(); ren.createPortalView();

View file

@ -12,8 +12,6 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IChatComponent; import net.minecraft.util.IChatComponent;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.EXTFramebufferObject; import org.lwjgl.opengl.EXTFramebufferObject;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -23,7 +21,6 @@ public class PortalRenderer {
public int portalTexture; public int portalTexture;
public int depthRenderBuffer; public int depthRenderBuffer;
public int frameBuffer; public int frameBuffer;
public static int renderRecursion;
public TileSeal seal; public TileSeal seal;
public PortalRenderer(TileSeal seal) { public PortalRenderer(TileSeal seal) {
@ -55,7 +52,6 @@ public class PortalRenderer {
} }
public void createPortalView() { public void createPortalView() {
++PortalRenderer.renderRecursion;
if (this.seal.otherSeal == null) if (this.seal.otherSeal == null)
return; return;
@ -67,19 +63,25 @@ public class PortalRenderer {
int prevFbo = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT); int prevFbo = GL11.glGetInteger(EXTFramebufferObject.GL_FRAMEBUFFER_BINDING_EXT);
EXTFramebufferObject.glBindFramebufferEXT(36160, this.frameBuffer); EXTFramebufferObject.glBindFramebufferEXT(36160, this.frameBuffer);
// TODO: stencils aren't stenciling
GL11.glEnable(2960); GL11.glEnable(2960);
GL11.glStencilFunc(519, 1, 1); GL11.glStencilFunc(519, 1, 1);
GL11.glStencilOp(7680, 7680, 7681); GL11.glStencilOp(7680, 7680, 7681);
GL11.glViewport(0, 0, 512, 512); GL11.glViewport(0, 0, 512, 512);
GL11.glMatrixMode(5889);
GL11.glLoadIdentity();
GL11.glMatrixMode(5888);
GL11.glLoadIdentity(); GL11.glLoadIdentity();
GL11.glDisable(3553); GL11.glDisable(3553);
GL11.glColor3f(1.0f, 1.0f, 1.0f); GL11.glColor3f(1.0F, 1.0F, 1.0F);
GL11.glBegin(6); GL11.glBegin(6);
GL11.glVertex2f(0.0f, 0.0f); GL11.glVertex2f(0.0F, 0.0F);
for (int oh = 0; oh <= 10; ++oh) { for (int oh = 0; oh <= 10; ++oh) {
final double aa = 6.283185307179586 * oh / 10.0; double aa = 6.283185307179586 * (double) oh / 10.0;
GL11.glVertex2f((float) Math.cos(aa), (float) Math.sin(aa)); GL11.glVertex2f((float) Math.cos(aa), (float) Math.sin(aa));
} }
GL11.glEnd(); GL11.glEnd();
GL11.glStencilFunc(514, 1, 1); GL11.glStencilFunc(514, 1, 1);
GL11.glStencilOp(7680, 7680, 7680); GL11.glStencilOp(7680, 7680, 7680);
@ -162,7 +164,7 @@ public class PortalRenderer {
} }
} }
mc.renderViewEntity.setPositionAndRotation( mc.renderViewEntity.setPositionAndRotation(
target.x + 0.5 + xm, target.y - 0.5f + ym, target.z + 0.5 + zm, yaw, pitch target.x + 0.5 + xm, target.y + 0.5f + ym, target.z + 0.5 + zm, yaw, pitch
); );
final boolean di = mc.gameSettings.showDebugInfo; final boolean di = mc.gameSettings.showDebugInfo;
mc.gameSettings.showDebugInfo = false; mc.gameSettings.showDebugInfo = false;
@ -187,9 +189,8 @@ public class PortalRenderer {
mc.gameSettings.fovSetting = fov; mc.gameSettings.fovSetting = fov;
mc.gameSettings.thirdPersonView = tpv; mc.gameSettings.thirdPersonView = tpv;
GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight); GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight);
//GL11.glDisable(2960); GL11.glDisable(2960);
EXTFramebufferObject.glBindFramebufferEXT(36160, prevFbo); EXTFramebufferObject.glBindFramebufferEXT(36160, prevFbo);
GL11.glPopMatrix(); GL11.glPopMatrix();
--PortalRenderer.renderRecursion;
} }
} }

View file

@ -6,7 +6,6 @@ import net.anvilcraft.arcaneseals.utils.UtilsFX;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;

View file

@ -27,12 +27,16 @@ import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
import net.minecraft.network.play.server.S12PacketEntityVelocity;
import net.minecraft.network.play.server.S18PacketEntityTeleport;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.potion.Potion; import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
@ -1543,7 +1547,7 @@ public class TileSeal extends TileEntity {
if (this.delay <= 0 && p) { if (this.delay <= 0 && p) {
//this.renderTeleportDest(); //this.renderTeleportDest();
this.delay = 3; this.delay = 10;
} }
--this.delay; --this.delay;
@ -1561,17 +1565,14 @@ public class TileSeal extends TileEntity {
list = this.getEntitiesSorted(super.worldObj, 2, this.orientation, false); list = this.getEntitiesSorted(super.worldObj, 2, this.orientation, false);
for (q = 0; q < list.size(); ++q) { for (q = 0; q < list.size(); ++q) {
if (list.get(q) instanceof EntityPlayer) { super.worldObj.playSoundEffect(
super.worldObj.playSoundEffect( (double) super.xCoord + 0.5,
(double) super.xCoord + 0.5, (double) super.yCoord + 0.5,
(double) super.yCoord + 0.5, (double) super.zCoord + 0.5,
(double) super.zCoord + 0.5, "arcaneseals:pclose",
"arcaneseals:pclose", 0.4F,
0.4F, 1.0F + super.worldObj.rand.nextFloat() * 0.2F
1.0F + super.worldObj.rand.nextFloat() * 0.2F );
);
break;
}
} }
} }
@ -1627,217 +1628,244 @@ public class TileSeal extends TileEntity {
//} //}
public boolean teleport() { public boolean teleport() {
if (this.delay > 0) { List<Entity> list = super.worldObj.getEntitiesWithinAABB(
Entity.class,
AxisAlignedBB.getBoundingBox(
(double) super.xCoord,
(double) super.yCoord,
(double) super.zCoord,
(double) (super.xCoord + 1),
(double) (super.yCoord + 1),
(double) (super.zCoord + 1)
)
);
if (list.isEmpty()) {
return false; return false;
} else { } else {
List<Entity> list = super.worldObj.getEntitiesWithinAABB( Entity entity = (Entity) list.get(0);
Entity.class, if (entity instanceof EntityFX) {
AxisAlignedBB.getBoundingBox(
(double) super.xCoord,
(double) super.yCoord,
(double) super.zCoord,
(double) (super.xCoord + 1),
(double) (super.yCoord + 1),
(double) (super.zCoord + 1)
)
);
if (list.size() == 0) {
return false; return false;
} else { } else {
Entity entity = (Entity) list.get(0); if (this.otherSeal == null) {
if (entity instanceof EntityFX) {
return false; return false;
} else { } else {
if (this.otherSeal == null) { SealData targetDest = this.otherSeal;
return false; TileEntity ts = super.worldObj.getTileEntity(
} else { targetDest.x, targetDest.y, targetDest.z
SealData targetDest = this.otherSeal; );
TileEntity ts = super.worldObj.getTileEntity( if (ts != null && ts instanceof TileSeal) {
targetDest.x, targetDest.y, targetDest.z TileSeal target = (TileSeal) ts;
); if (target.runes[0] == 0 && target.runes[1] == 1) {
if (ts != null && ts instanceof TileSeal) { target.delay = 40;
TileSeal target = (TileSeal) ts; float tYaw = entity.rotationYaw;
if (target.runes[0] == 0 && target.runes[1] == 1) { switch (target.orientation) {
target.delay = 40; case 2:
float tYaw = entity.rotationYaw; tYaw = 180.0F;
switch (target.orientation) { break;
case 2: case 3:
tYaw = 180.0F; tYaw = 0.0F;
break; break;
case 3: case 4:
tYaw = 0.0F; tYaw = 90.0F;
break; break;
case 4: case 5:
tYaw = 90.0F; tYaw = 270.0F;
break; }
case 5:
tYaw = 270.0F;
}
int diff = this.orientation - target.orientation; int diff = this.orientation - target.orientation;
double t; double t;
if (diff == -3 || diff == 2 if (diff == -3 || diff == 2
|| diff == -1 || diff == -1
&& this.orientation + target.orientation != 5 && this.orientation + target.orientation != 5
&& this.orientation + target.orientation != 9) { && this.orientation + target.orientation != 9) {
t = entity.motionX; t = entity.motionX;
entity.motionX = entity.motionZ; entity.motionX = entity.motionZ;
entity.motionZ = -t; entity.motionZ = -t;
if (entity.ridingEntity != null) { if (entity.ridingEntity != null) {
entity.ridingEntity.motionX entity.ridingEntity.motionX
= entity.ridingEntity.motionZ; = entity.ridingEntity.motionZ;
entity.ridingEntity.motionZ = -t; entity.ridingEntity.motionZ = -t;
} }
} else if (diff == -2 || diff == 3 || diff == 1 && } else if (diff == -2 || diff == 3 || diff == 1 &&
this.orientation + target.orientation != 5 && this.orientation + target.orientation != 5 &&
this.orientation + target.orientation != 9) { this.orientation + target.orientation != 9) {
t = entity.motionX; t = entity.motionX;
entity.motionX = -entity.motionZ; entity.motionX = -entity.motionZ;
entity.motionZ = t; entity.motionZ = t;
if (entity.ridingEntity != null) { if (entity.ridingEntity != null) {
entity.ridingEntity.motionX entity.ridingEntity.motionX
= -entity.ridingEntity.motionZ; = -entity.ridingEntity.motionZ;
entity.ridingEntity.motionZ = t; entity.ridingEntity.motionZ = t;
}
} else if (diff == 0) {
entity.motionX = -entity.motionX;
entity.motionZ = -entity.motionZ;
if (entity.ridingEntity != null) {
entity.ridingEntity.motionX
= -entity.ridingEntity.motionX;
entity.ridingEntity.motionZ
= -entity.ridingEntity.motionZ;
}
} }
} else if (diff == 0) {
if (diff == 0 entity.motionX = -entity.motionX;
&& (this.orientation == 1 || this.orientation == 0)) { entity.motionZ = -entity.motionZ;
entity.motionY = -entity.motionY; if (entity.ridingEntity != null) {
if (entity.ridingEntity != null) { entity.ridingEntity.motionX
entity.ridingEntity.motionY = -entity.ridingEntity.motionX;
= -entity.ridingEntity.motionY; entity.ridingEntity.motionZ
} = -entity.ridingEntity.motionZ;
} }
}
UtilsFX.poof( if (diff == 0
super.worldObj, && (this.orientation == 1 || this.orientation == 0)) {
(float) entity.posX - 0.5F, entity.motionY = -entity.motionY;
(float) entity.posY - 0.5F, if (entity.ridingEntity != null) {
(float) entity.posZ - 0.5F entity.ridingEntity.motionY
); = -entity.ridingEntity.motionY;
super.worldObj.playSoundEffect(
entity.posX,
entity.posY,
entity.posZ,
"mob.endermen.portal",
1.0F,
1.0F
);
int xm = 0;
int zm = 0;
int ym = 0;
switch (target.orientation) {
case 0:
ym = -1;
break;
case 1:
ym = 1;
break;
case 2:
zm = -1;
break;
case 3:
zm = 1;
break;
case 4:
xm = -1;
break;
case 5:
xm = 1;
} }
}
if (target.orientation > 1 UtilsFX.poof(
&& super.worldObj.isAirBlock( super.worldObj,
target.xCoord + xm, (float) entity.posX - 0.5F,
target.yCoord + ym - 1, (float) entity.posY - 0.5F,
target.zCoord + zm (float) entity.posZ - 0.5F
)) { );
--ym; super.worldObj.playSoundEffect(
} entity.posX,
entity.posY,
entity.posZ,
"mob.endermen.portal",
1.0F,
1.0F
);
int xm = 0;
int zm = 0;
int ym = 0;
switch (target.orientation) {
case 0:
ym = -1;
break;
case 1:
ym = 1;
break;
case 2:
zm = -1;
break;
case 3:
zm = 1;
break;
case 4:
xm = -1;
break;
case 5:
xm = 1;
}
entity.setLocationAndAngles( if (target.orientation > 1
&& super.worldObj.isAirBlock(
target.xCoord + xm,
target.yCoord + ym - 1,
target.zCoord + zm
)) {
--ym;
}
entity.setLocationAndAngles(
(double) target.xCoord + 0.5 + (double) xm,
(double) target.yCoord + 0.5 + (double) ym,
(double) target.zCoord + 0.5 + (double) zm,
tYaw,
entity.rotationPitch
);
if (entity.ridingEntity != null) {
entity.ridingEntity.setLocationAndAngles(
(double) target.xCoord + 0.5 + (double) xm, (double) target.xCoord + 0.5 + (double) xm,
(double) target.yCoord + 0.5 + (double) ym, (double) target.yCoord + 0.5 + (double) ym,
(double) target.zCoord + 0.5 + (double) zm, (double) target.zCoord + 0.5 + (double) zm,
tYaw, tYaw,
entity.rotationPitch entity.ridingEntity.rotationPitch
); );
if (entity.ridingEntity != null) {
entity.ridingEntity.setLocationAndAngles(
(double) target.xCoord + 0.5 + (double) xm,
(double) target.yCoord + 0.5 + (double) ym,
(double) target.zCoord + 0.5 + (double) zm,
tYaw,
entity.ridingEntity.rotationPitch
);
}
UtilsFX.poof(
super.worldObj,
(float) entity.posX - 0.5F,
(float) entity.posY - 0.5F,
(float) entity.posZ - 0.5F
);
super.worldObj.playSoundEffect(
entity.posX,
entity.posY,
entity.posZ,
"mob.endermen.portal",
1.0F,
1.0F
);
// TODO: use specific aspect for flux
int thisAura = AuraManager.getClosestAuraWithinRange(
this.worldObj,
this.xCoord,
this.yCoord,
this.zCoord,
512
);
if (thisAura >= 0) {
AuraManager.addRandomFlux(
this.worldObj,
AuraManager.getNode(thisAura),
(entity instanceof EntityItem) ? 1 : 4
);
}
int otherAura = AuraManager.getClosestAuraWithinRange(
target.worldObj,
target.xCoord,
target.yCoord,
target.zCoord,
512
);
if (otherAura >= 0) {
AuraManager.addRandomFlux(
this.worldObj,
AuraManager.getNode(otherAura),
(entity instanceof EntityItem) ? 1 : 4
);
}
this.worked = true;
return true;
} else {
return false;
} }
UtilsFX.poof(
super.worldObj,
(float) entity.posX - 0.5F,
(float) entity.posY - 0.5F,
(float) entity.posZ - 0.5F
);
super.worldObj.playSoundEffect(
entity.posX,
entity.posY,
entity.posZ,
"mob.endermen.portal",
1.0F,
1.0F
);
// TODO: use specific aspect for flux
int thisAura = AuraManager.getClosestAuraWithinRange(
this.worldObj, this.xCoord, this.yCoord, this.zCoord, 512
);
if (thisAura >= 0) {
AuraManager.addRandomFlux(
this.worldObj,
AuraManager.getNode(thisAura),
(entity instanceof EntityItem) ? 1 : 4
);
}
int otherAura = AuraManager.getClosestAuraWithinRange(
target.worldObj,
target.xCoord,
target.yCoord,
target.zCoord,
512
);
if (otherAura >= 0) {
AuraManager.addRandomFlux(
this.worldObj,
AuraManager.getNode(otherAura),
(entity instanceof EntityItem) ? 1 : 4
);
}
if (entity instanceof EntityPlayer) {
((EntityPlayerMP) entity)
.playerNetServerHandler.sendPacket(
new S08PacketPlayerPosLook(
entity.posX,
entity.posY + 1.6,
entity.posZ,
entity.rotationYaw,
entity.rotationPitch,
false
)
);
} else {
System.out.println(entity.posX + " " + entity.posY + " " + entity.posZ);
Packet pkt1
= new S18PacketEntityTeleport(
entity.getEntityId(),
MathHelper.floor_double(entity.posX * 32.0D),
MathHelper.floor_double(entity.posY * 32.0D),
MathHelper.floor_double(entity.posZ * 32.0D),
(byte
) ((int) (entity.rotationYaw * 256.0F / 360.0F)),
(byte
) ((int) (entity.rotationPitch * 256.0F / 360.0F))
);
Packet pkt2 = new S12PacketEntityVelocity(entity);
for (EntityPlayerMP pl : (List<EntityPlayerMP>) this
.worldObj.playerEntities) {
pl.playerNetServerHandler.sendPacket(pkt1);
pl.playerNetServerHandler.sendPacket(pkt2);
}
}
this.worked = true;
return true;
} else { } else {
return false; return false;
} }
} else {
return false;
} }
} }
} }