Compare commits

...
3 Commits
Author SHA1 Message Date
kstvr32 23312198a6 Allow autoplace channels to work in survival mode (#20)
* allow autoplace channels to work in survival mode

* bump NEI dependency version
2023-05-04 17:40:03 +02:00
Glease fa5e2ae4ca flush buffer to ensure vertexes in same trig being drawn in same batch (#19)
* flush buffer to ensure vertexes in same trig being drawn in same batch

* off by one
2023-03-08 12:23:32 +01:00
Glease a8a1547845 remove unnecessary shim code for IMultiblockInfoContainer
nobody implement these in practice, so we should be safe
2023-02-28 12:37:18 +08:00
4 changed files with 38 additions and 37 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
dependencies {
api("com.github.GTNewHorizons:GTNHLib:0.0.10:dev")
runtimeOnly("com.github.GTNewHorizons:NotEnoughItems:2.3.25-GTNH:dev")
runtimeOnly("com.github.GTNewHorizons:NotEnoughItems:2.3.46-GTNH:dev")
testImplementation(platform('org.junit:junit-bom:5.9.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
@@ -526,7 +526,8 @@ public class ClientProxy extends CommonProxy {
GL11.glTranslated(-d0 + i0, -d1 + i1, -d2 + i2);
Tessellator tes = Tessellator.instance;
tes.startDrawing(GL11.GL_TRIANGLES);
for (int i = 0, allHintsForRenderSize = allHintsForRender.size(); i < allHintsForRenderSize; i++) {
for (int i = 0, allHintsForRenderSize = allHintsForRender.size(), cubeDrawn = 0; i
< allHintsForRenderSize; i++, cubeDrawn++) {
HintParticleInfo hint = allHintsForRender.get(i);
if (!hint.isInFrustrum(frustrum)) continue;
if (renderThrough != hint.renderThrough) {
@@ -534,12 +535,21 @@ public class ClientProxy extends CommonProxy {
p.endStartSection("Draw");
tes.draw();
tes.startDrawing(GL11.GL_TRIANGLES);
cubeDrawn = 0;
p.endStartSection("Prepare");
}
if (hint.renderThrough) GL11.glDisable(GL11.GL_DEPTH_TEST);
else GL11.glEnable(GL11.GL_DEPTH_TEST);
renderThrough = hint.renderThrough;
}
// Minecraft Tessellator draw in batch of 4096. This plays nicely with quads, but for trigs
// it might occasionally end up with one half in first batch and the other half in later batch.
// so we manually flush the buffer here if that would happen.
// 6 faces per particle, 2 trig per face, 3 vertex per trig
if ((cubeDrawn + 1) >= 4096 / (6 * 2 * 3)) {
tes.draw();
tes.startDrawing(GL11.GL_TRIANGLES);
}
// TODO verify if we need to add eyeHeight
hint.draw(tes, d0, d1, d2, i0, i1, i2);
}
@@ -8,7 +8,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment;
import com.gtnewhorizon.structurelib.structure.IItemSource;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@@ -41,24 +43,35 @@ public interface IMultiblockInfoContainer<T> {
/**
* Construct the structure using
* {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, IItemSource, EntityPlayerMP, java.util.function.Consumer)}
*
* {@link com.gtnewhorizon.structurelib.structure.IStructureElement#survivalPlaceBlock(Object, World, int, int, int, ItemStack, AutoPlaceEnvironment)}
*
* @return -1 if done, a helping pointer
*/
default int survivalConstruct(ItemStack stackSize, int elementBudge, IItemSource source,
EntityPlayerMP actorProfile, T tileEntity, ExtendedFacing aSide) {
return -1;
}
int survivalConstruct(ItemStack stackSize, int elementBudge, ISurvivalBuildEnvironment env, T tileEntity,
ExtendedFacing aSide);
@SideOnly(Side.CLIENT)
String[] getDescription(ItemStack stackSize);
/**
* Override this and return {@link #toConstructable(IMultiblockInfoContainer, Object, ExtendedFacing)} if
* {@link #survivalConstruct(ItemStack, int, IItemSource, EntityPlayerMP, Object, ExtendedFacing)} isn't a stub
*/
default IConstructable toConstructable(T tileEntity, ExtendedFacing aSide) {
return new IConstructable() {
default ISurvivalConstructable toConstructable(T tileEntity, ExtendedFacing aSide) {
return new ISurvivalConstructable() {
@Override
public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
return IMultiblockInfoContainer.this
.survivalConstruct(stackSize, elementBudget, env, tileEntity, aSide);
}
@Override
public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source,
EntityPlayerMP actor) {
return IMultiblockInfoContainer.this.survivalConstruct(
stackSize,
elementBudget,
ISurvivalBuildEnvironment.create(source, actor),
tileEntity,
aSide);
}
@Override
public void construct(ItemStack stackSize, boolean hintsOnly) {
@@ -71,26 +84,4 @@ public interface IMultiblockInfoContainer<T> {
}
};
}
static <T> ISurvivalConstructable toConstructable(IMultiblockInfoContainer<T> thiz, T tileEntity,
ExtendedFacing aSide) {
return new ISurvivalConstructable() {
@Override
public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source,
EntityPlayerMP actor) {
return thiz.survivalConstruct(stackSize, elementBudget, source, actor, tileEntity, aSide);
}
@Override
public void construct(ItemStack stackSize, boolean hintsOnly) {
thiz.construct(stackSize, hintsOnly, tileEntity, aSide);
}
@Override
public String[] getStructureDescription(ItemStack stackSize) {
return thiz.getDescription(stackSize);
}
};
}
}
@@ -2591,7 +2591,7 @@ public class StructureUtility {
// we will bypass the chatter filter here, as this is a warning that player definitively want to see
// instead of some false positive error messages like item not find
warnNoExplicitSubChannel(env.getActor());
return backing.survivalPlaceBlock(t, world, x, y, z, trigger, env);
return backing.survivalPlaceBlock(t, world, x, y, z, newTrigger, env);
}
};
}