Fixed a CME when chunk rendering is multithreaded, see #10
(back-port from 1.11)
This commit is contained in:
parent
b1a1b4e62a
commit
7a5edfa825
|
@ -31,6 +31,8 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -146,10 +148,7 @@ public abstract class PanelComponent {
|
||||||
String type = nbt.getString("type");
|
String type = nbt.getString("type");
|
||||||
if (baseCreaters.containsKey(type)) {
|
if (baseCreaters.containsKey(type)) {
|
||||||
PanelComponent ret = baseCreaters.get(type).get();
|
PanelComponent ret = baseCreaters.get(type).get();
|
||||||
ret.readCustomNBT(nbt);
|
ret.readFromNBT(nbt);
|
||||||
ret.setX(nbt.getFloat("x"));
|
|
||||||
ret.setY(nbt.getFloat("y"));
|
|
||||||
ret.setPanelHeight(nbt.getFloat("panelHeight"));
|
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
IELogger.info("(IndustrialWires) Unknown panel component: " + type);//TODO own logger?
|
IELogger.info("(IndustrialWires) Unknown panel component: " + type);//TODO own logger?
|
||||||
|
@ -157,6 +156,14 @@ public abstract class PanelComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void readFromNBT(NBTTagCompound nbt) {
|
||||||
|
readCustomNBT(nbt);
|
||||||
|
setX(nbt.getFloat("x"));
|
||||||
|
setY(nbt.getFloat("y"));
|
||||||
|
setPanelHeight(nbt.getFloat("panelHeight"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
public void renderBox(TileEntityPanel te) {
|
public void renderBox(TileEntityPanel te) {
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||||
|
|
|
@ -80,8 +80,10 @@ public final class PanelUtils {
|
||||||
Matrix4 m4RotOnly = m4.copy();
|
Matrix4 m4RotOnly = m4.copy();
|
||||||
m4RotOnly.invert();
|
m4RotOnly.invert();
|
||||||
m4RotOnly.transpose();
|
m4RotOnly.transpose();
|
||||||
for (PanelComponent pc : components) {
|
//Intentionally not a for-each to help with CME's
|
||||||
Matrix4 m4Here = m4.copy().translate(pc.getX(), 0, pc.getY());
|
for (int i = 0; i < components.size(); i++) {
|
||||||
|
PanelComponent pc = components.get(i);
|
||||||
|
Matrix4 m4Here = m4.copy().translate(pc.getX(), .0001, pc.getY());
|
||||||
List<RawQuad> compQuads = pc.getQuads();
|
List<RawQuad> compQuads = pc.getQuads();
|
||||||
for (RawQuad bq : compQuads) {
|
for (RawQuad bq : compQuads) {
|
||||||
ret.add(bakeQuad(bq, m4Here, m4RotOnly, false));
|
ret.add(bakeQuad(bq, m4Here, m4RotOnly, false));
|
||||||
|
@ -331,11 +333,24 @@ public final class PanelUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void readListFromNBT(NBTTagList list, @Nonnull List<PanelComponent> base) {
|
public static void readListFromNBT(NBTTagList list, @Nonnull List<PanelComponent> base) {
|
||||||
base.clear();
|
boolean allNew = list.tagCount() != base.size();
|
||||||
|
if (allNew) {
|
||||||
|
base.clear();
|
||||||
|
}
|
||||||
for (int i = 0; i < list.tagCount(); i++) {
|
for (int i = 0; i < list.tagCount(); i++) {
|
||||||
PanelComponent pc = PanelComponent.read(list.getCompoundTagAt(i));
|
NBTTagCompound nbt = list.getCompoundTagAt(i);
|
||||||
|
PanelComponent pc = PanelComponent.read(nbt);
|
||||||
if (pc != null) {
|
if (pc != null) {
|
||||||
base.add(pc);
|
if (allNew) {
|
||||||
|
base.add(pc);
|
||||||
|
} else {
|
||||||
|
PanelComponent oldPc = base.get(i);
|
||||||
|
if (pc.getClass() != oldPc.getClass()) {
|
||||||
|
base.set(i, pc);
|
||||||
|
} else {
|
||||||
|
oldPc.readFromNBT(nbt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue