Fixed a CME when chunk rendering is multithreaded, see #10
(back-port from 1.11)
This commit is contained in:
parent
b1a1b4e62a
commit
7a5edfa825
2 changed files with 31 additions and 9 deletions
|
@ -31,6 +31,8 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
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.Nullable;
|
||||
|
@ -146,10 +148,7 @@ public abstract class PanelComponent {
|
|||
String type = nbt.getString("type");
|
||||
if (baseCreaters.containsKey(type)) {
|
||||
PanelComponent ret = baseCreaters.get(type).get();
|
||||
ret.readCustomNBT(nbt);
|
||||
ret.setX(nbt.getFloat("x"));
|
||||
ret.setY(nbt.getFloat("y"));
|
||||
ret.setPanelHeight(nbt.getFloat("panelHeight"));
|
||||
ret.readFromNBT(nbt);
|
||||
return ret;
|
||||
} else {
|
||||
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) {
|
||||
GlStateManager.enableBlend();
|
||||
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();
|
||||
m4RotOnly.invert();
|
||||
m4RotOnly.transpose();
|
||||
for (PanelComponent pc : components) {
|
||||
Matrix4 m4Here = m4.copy().translate(pc.getX(), 0, pc.getY());
|
||||
//Intentionally not a for-each to help with CME's
|
||||
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();
|
||||
for (RawQuad bq : compQuads) {
|
||||
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) {
|
||||
base.clear();
|
||||
boolean allNew = list.tagCount() != base.size();
|
||||
if (allNew) {
|
||||
base.clear();
|
||||
}
|
||||
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) {
|
||||
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