Basic item simulation

- Support for generic entities inside ponder scenes
- Instructions for manipulating/creating entities
- Client-side belts are now slightly smarter inside a ponder world
- Some doc for the doc
This commit is contained in:
simibubi 2021-02-21 19:29:23 +01:00
parent c4e1f680c9
commit 9d4e52092e
23 changed files with 336 additions and 62 deletions

View file

@ -401,19 +401,19 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j
7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json
b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json
e3f618c5b622d21880de858678d1802cbf65e615 assets/create/lang/en_ud.json
4bc90775f20e4373d8acfcd68df5a65134e04866 assets/create/lang/en_us.json
556b49bc145684816fe4ed3d01b8292b027785f6 assets/create/lang/unfinished/de_de.json
0112e46354dc5a3e404e80f18c3e9cf2ce2ac3a7 assets/create/lang/unfinished/es_es.json
22d8dbe2f7a2b7bb7b8175e6ea7ffe5461138339 assets/create/lang/unfinished/es_mx.json
5aac59946786fe76ff0d5ab8e548c086adb46a7b assets/create/lang/unfinished/fr_fr.json
479b811f2a0a687e7a1d14cfbed85af8ed8167b9 assets/create/lang/unfinished/it_it.json
22ab034f6f8cadcbc689f27e8697e52bc9fd701f assets/create/lang/unfinished/ja_jp.json
c046e6335a67a8685bb7e74cd6b14a5ee9c376db assets/create/lang/unfinished/ko_kr.json
96995633b85eaff2ac1b38a8958c6d167150d255 assets/create/lang/unfinished/nl_nl.json
8e8159926be6be37f97f6d4cf47deb8c236b83dc assets/create/lang/unfinished/pt_br.json
4485be9e7a8a2b0d006464390e664d6d504328b5 assets/create/lang/unfinished/ru_ru.json
8bfa521e0220fe71dbeb537a08845522e1ae0899 assets/create/lang/unfinished/zh_cn.json
eeaa83dafc8a683b4834cd87a49cb9b3c88e4121 assets/create/lang/unfinished/zh_tw.json
9797de418101ddd344ac8ec2b91fb2ba25ea504e assets/create/lang/en_us.json
64b7f0ddac53567a3a23cd29774fdb2b93f9e777 assets/create/lang/unfinished/de_de.json
54ea6fa80308ee8908ae2596e8bcaa6d9e5d0731 assets/create/lang/unfinished/es_es.json
c1bf9ae424ffe72ba3684d1aa359f2b4a2bb2e88 assets/create/lang/unfinished/es_mx.json
104eeb4b28ce3be1c0fc7ce2b779dc79dc1e2f5d assets/create/lang/unfinished/fr_fr.json
da5819debc20d7a65c3f8472889f8be1e9bc97c5 assets/create/lang/unfinished/it_it.json
c697d1f20b6482e03a42cbdd9c2fad1b63094dcb assets/create/lang/unfinished/ja_jp.json
0746089d44ec5328f8ce8c8cf2328b2de5ec885e assets/create/lang/unfinished/ko_kr.json
cac8ff78aecfbf596af332d21406fddca9f53d5a assets/create/lang/unfinished/nl_nl.json
7424b098208ec7d3a06c6bf614a303b12944d4b5 assets/create/lang/unfinished/pt_br.json
95adcdad2f75c548cac7cdf61fd141b08e451f50 assets/create/lang/unfinished/ru_ru.json
be41354ccd7dbfbc60a4e36cf37388c7c7a4f88d assets/create/lang/unfinished/zh_cn.json
241fd40fc3ceba47f58c83da244fca4efd969b05 assets/create/lang/unfinished/zh_tw.json
846200eb548d3bfa2e77b41039de159b4b6cfb45 assets/create/models/block/acacia_window.json
1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets/create/models/block/acacia_window_pane_noside.json
1763ea2c9b981d187f5031ba608f3d5d3be3986a assets/create/models/block/acacia_window_pane_noside_alt.json

View file

@ -1816,6 +1816,7 @@
"create.ponder.brass_hand.scene_0.title": "Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "wut?",
"create.ponder.brass_hand.scene_2.title": "Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "Blocks outside of the base plate do not affect scaling",
@ -1832,6 +1833,7 @@
"create.ponder.brass_hand.scene_7.independent": "This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "Sections",
"create.ponder.brass_hand.scene_8.title": "Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 999",
"_": "Missing Localizations: 1001",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 41",
"_": "Missing Localizations: 43",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 929",
"_": "Missing Localizations: 931",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 711",
"_": "Missing Localizations: 713",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 46",
"_": "Missing Localizations: 48",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 53",
"_": "Missing Localizations: 55",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 100",
"_": "Missing Localizations: 102",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1198",
"_": "Missing Localizations: 1200",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 1264",
"_": "Missing Localizations: 1266",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 50",
"_": "Missing Localizations: 52",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 48",
"_": "Missing Localizations: 50",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -1,5 +1,5 @@
{
"_": "Missing Localizations: 53",
"_": "Missing Localizations: 55",
"_": "->------------------------] Game Elements [------------------------<-",
@ -1817,6 +1817,7 @@
"create.ponder.brass_hand.scene_0.title": "UNLOCALIZED: Coordinate Space",
"create.ponder.brass_hand.scene_1.change_blocks": "UNLOCALIZED: Blocks can be modified",
"create.ponder.brass_hand.scene_1.title": "UNLOCALIZED: Changing Blocks",
"create.ponder.brass_hand.scene_2.wut": "UNLOCALIZED: wut?",
"create.ponder.brass_hand.scene_2.title": "UNLOCALIZED: Showing Fluids",
"create.ponder.brass_hand.scene_2.fluids": "UNLOCALIZED: Fluid rendering test.",
"create.ponder.brass_hand.scene_3.outofbounds": "UNLOCALIZED: Blocks outside of the base plate do not affect scaling",
@ -1833,6 +1834,7 @@
"create.ponder.brass_hand.scene_7.independent": "UNLOCALIZED: This Section renders independently.",
"create.ponder.brass_hand.scene_7.merged": "UNLOCALIZED: This Section got merged to base.",
"create.ponder.brass_hand.scene_7.title": "UNLOCALIZED: Sections",
"create.ponder.brass_hand.scene_8.title": "UNLOCALIZED: Manipulating Items",
"_": "Thank you for translating Create!"

View file

@ -38,6 +38,7 @@ public class BeltInventory {
final List<TransportedItemStack> toInsert;
final List<TransportedItemStack> toRemove;
boolean beltMovementPositive;
boolean virtualMode;
final float SEGMENT_WINDOW = .75f;
public BeltInventory(BeltTileEntity te) {
@ -45,6 +46,7 @@ public class BeltInventory {
items = new LinkedList<>();
toInsert = new LinkedList<>();
toRemove = new LinkedList<>();
virtualMode = false;
}
public void tick() {
@ -82,7 +84,7 @@ public class BeltInventory {
.get(BeltBlock.SLOPE) == BeltSlope.HORIZONTAL;
float spacing = 1;
World world = belt.getWorld();
boolean onClient = world.isRemote;
boolean onClient = world.isRemote && !virtualMode;
// resolve ending only when items will reach it this tick
Ending ending = Ending.UNRESOLVED;
@ -437,4 +439,9 @@ public class BeltInventory {
return items;
}
// Simulating belt interactions in a client-only world
public void enableVirtualMode() {
virtualMode = true;
}
}

View file

@ -28,6 +28,7 @@ import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.Vector4f;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.util.math.Vec2f;
@ -126,6 +127,7 @@ public class PonderScene {
forEachVisible(PonderSceneElement.class, e -> e.renderLayer(world, buffer, type, ms));
forEachVisible(PonderSceneElement.class, e -> e.renderLast(world, buffer, ms));
info.set(transform.xRotation.getValue(pt), transform.yRotation.getValue(pt));
world.renderEntities(ms, buffer, info);
world.renderParticles(ms, buffer, info);
outliner.renderOutlines(ms, buffer);
ms.pop();
@ -152,7 +154,7 @@ public class PonderScene {
pointOfInterest = VecHelper.lerp(.25f, pointOfInterest, chasingPointOfInterest);
outliner.tickOutlines();
world.tickParticles();
world.tick();
transform.tick();
forEach(e -> e.tick(this));
@ -204,6 +206,12 @@ public class PonderScene {
function.accept(elemtent);
}
public <T extends Entity> void forEachWorldEntity(Class<T> type, Consumer<T> function) {
for (Entity element : world.getEntities())
if (type.isInstance(element))
function.accept(type.cast(element));
}
public <T extends PonderElement> void forEach(Class<T> type, Consumer<T> function) {
for (PonderElement element : elements)
if (type.isInstance(element))

View file

@ -1,12 +1,19 @@
package com.simibubi.create.foundation.ponder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.content.contraptions.relays.belt.BeltBlock;
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity;
import com.simibubi.create.content.schematics.SchematicWorld;
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -16,6 +23,11 @@ import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleManager;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.inventory.container.PlayerContainer;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.particles.BlockParticleData;
import net.minecraft.particles.IParticleData;
@ -25,6 +37,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.LightType;
@ -35,6 +48,7 @@ public class PonderWorld extends SchematicWorld {
protected Map<BlockPos, BlockState> originalBlocks;
protected Map<BlockPos, TileEntity> originalTileEntities;
protected List<Entity> originalEntities;
protected PonderWorldParticles particles;
int overrideLight;
@ -44,6 +58,7 @@ public class PonderWorld extends SchematicWorld {
super(anchor, original);
originalBlocks = new HashMap<>();
originalTileEntities = new HashMap<>();
originalEntities = new ArrayList<>();
particles = new PonderWorldParticles(this);
}
@ -52,9 +67,12 @@ public class PonderWorld extends SchematicWorld {
originalTileEntities.clear();
blocks.forEach((k, v) -> originalBlocks.put(k, v));
tileEntities.forEach((k, v) -> originalTileEntities.put(k, TileEntity.create(v.write(new CompoundNBT()))));
entities.forEach(e -> EntityType.loadEntityUnchecked(e.serializeNBT(), this)
.ifPresent(originalEntities::add));
}
public void restore() {
entities.clear();
blocks.clear();
tileEntities.clear();
renderedTileEntities.clear();
@ -65,7 +83,10 @@ public class PonderWorld extends SchematicWorld {
tileEntities.put(k, te);
renderedTileEntities.add(te);
});
originalEntities.forEach(e -> EntityType.loadEntityUnchecked(e.serializeNBT(), this)
.ifPresent(entities::add));
particles.clearEffects();
fixVirtualTileEntities();
}
public void pushFakeLight(int light) {
@ -101,12 +122,60 @@ public class PonderWorld extends SchematicWorld {
return this;
}
public void renderEntities(MatrixStack ms, SuperRenderTypeBuffer buffer, ActiveRenderInfo ari) {
Vec3d vec3d = ari.getProjectedView();
float pt = AnimationTickHolder.getPartialTicks();
double d0 = vec3d.getX();
double d1 = vec3d.getY();
double d2 = vec3d.getZ();
for (Entity entity : entities) {
if (entity.ticksExisted == 0) {
entity.lastTickPosX = entity.getX();
entity.lastTickPosY = entity.getY();
entity.lastTickPosZ = entity.getZ();
}
renderEntity(entity, d0, d1, d2, pt, ms, buffer);
}
buffer.draw(RenderType.getEntitySolid(PlayerContainer.BLOCK_ATLAS_TEXTURE));
buffer.draw(RenderType.getEntityCutout(PlayerContainer.BLOCK_ATLAS_TEXTURE));
buffer.draw(RenderType.getEntityCutoutNoCull(PlayerContainer.BLOCK_ATLAS_TEXTURE));
buffer.draw(RenderType.getEntitySmoothCutout(PlayerContainer.BLOCK_ATLAS_TEXTURE));
}
private void renderEntity(Entity entity, double x, double y, double z, float pt, MatrixStack ms,
IRenderTypeBuffer buffer) {
double d0 = MathHelper.lerp((double) pt, entity.lastTickPosX, entity.getX());
double d1 = MathHelper.lerp((double) pt, entity.lastTickPosY, entity.getY());
double d2 = MathHelper.lerp((double) pt, entity.lastTickPosZ, entity.getZ());
float f = MathHelper.lerp(pt, entity.prevRotationYaw, entity.rotationYaw);
EntityRendererManager renderManager = Minecraft.getInstance()
.getRenderManager();
int light = renderManager.getRenderer(entity)
.getLight(entity, pt);
renderManager.render(entity, d0 - x, d1 - y, d2 - z, f, pt, ms, buffer, light);
}
public void renderParticles(MatrixStack ms, IRenderTypeBuffer buffer, ActiveRenderInfo ari) {
particles.renderParticles(ms, buffer, ari);
}
public void tickParticles() {
public void tick() {
particles.tick();
for (Iterator<Entity> iterator = entities.iterator(); iterator.hasNext();) {
Entity entity = iterator.next();
entity.ticksExisted++;
entity.lastTickPosX = entity.getX();
entity.lastTickPosY = entity.getY();
entity.lastTickPosZ = entity.getZ();
entity.tick();
if (!entity.isAlive())
iterator.remove();
}
}
@Override
@ -129,6 +198,26 @@ public class PonderWorld extends SchematicWorld {
particles.addParticle(p);
}
public void fixVirtualTileEntities() {
for (TileEntity tileEntity : tileEntities.values()) {
if (!(tileEntity instanceof BeltTileEntity))
continue;
BeltTileEntity beltTileEntity = (BeltTileEntity) tileEntity;
if (!beltTileEntity.isController())
continue;
BlockPos controllerPos = tileEntity.getPos();
beltTileEntity.getInventory()
.enableVirtualMode();
for (BlockPos blockPos : BeltBlock.getBeltChain(this, controllerPos)) {
TileEntity tileEntity2 = getTileEntity(blockPos);
if (!(tileEntity2 instanceof BeltTileEntity))
continue;
BeltTileEntity belt2 = (BeltTileEntity) tileEntity2;
belt2.setController(controllerPos);
}
}
}
public void addBlockDestroyEffects(BlockPos pos, BlockState state) {
VoxelShape voxelshape = state.getShape(this, pos);
if (voxelshape.isEmpty())

View file

@ -2,9 +2,11 @@ package com.simibubi.create.foundation.ponder;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity;
import com.simibubi.create.content.contraptions.relays.gauge.SpeedGaugeTileEntity;
import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity;
import com.simibubi.create.foundation.ponder.content.PonderPalette;
@ -24,28 +26,57 @@ import com.simibubi.create.foundation.ponder.instructions.MovePoiInstruction;
import com.simibubi.create.foundation.ponder.instructions.OutlineSelectionInstruction;
import com.simibubi.create.foundation.ponder.instructions.ReplaceBlocksInstruction;
import com.simibubi.create.foundation.ponder.instructions.RotateSceneInstruction;
import com.simibubi.create.foundation.ponder.instructions.ShowCompleteSchematicInstruction;
import com.simibubi.create.foundation.ponder.instructions.ShowInputInstruction;
import com.simibubi.create.foundation.ponder.instructions.TextInstruction;
import com.simibubi.create.foundation.ponder.instructions.TileEntityDataInstruction;
import com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour;
import com.simibubi.create.foundation.utility.VecHelper;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.RedstoneParticleData;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
/**
* Enqueue instructions to the schedule via this object's methods.
*/
public class SceneBuilder {
/**
* Ponder's toolkit for showing information on top of the scene world, such as
* highlighted bounding boxes, texts, icons and keybindings.
*/
public final OverlayInstructions overlay;
public final SpecialInstructions special;
/**
* Instructions for manipulating the schematic and its currently visible areas.
* Allows to show, hide and modify blocks as the scene plays out.
*/
public final WorldInstructions world;
/**
* Additional tools for debugging ponder and bypassing the facade
*/
public final DebugInstructions debug;
/**
* Special effects to embellish and communicate with
*/
public final EffectInstructions effects;
/**
* Random other instructions that might come in handy
*/
public final SpecialInstructions special;
private final PonderScene scene;
public SceneBuilder(PonderScene ponderScene) {
@ -59,33 +90,85 @@ public class SceneBuilder {
// General
/**
* Assign the standard english translation for this scene's title using this
* method, anywhere inside the program function.
*
* @param title
*/
public void title(String title) {
PonderLocalization.registerSpecific(scene.component, scene.sceneIndex, "title", title);
}
/**
* Communicates to the ponder UI which parts of the schematic make up the base
* horizontally. Use of this is encouraged whenever there are components outside
* the the base plate. <br>
* As a result, showBasePlate() will only show the configured size, and the
* scene's scaling inside the UI will be consistent with its base size.
*
* @param xOffset Block spaces between the base plate and the schematic
* boundary on the Western side.
* @param zOffset Block spaces between the base plate and the schematic
* boundary on the Northern side.
* @param basePlateSize Length in blocks of the base plate itself. Ponder
* assumes it to be square
*/
public void configureBasePlate(int xOffset, int zOffset, int basePlateSize) {
scene.offsetX = xOffset;
scene.offsetZ = zOffset;
scene.size = basePlateSize;
}
/**
* Fade the layer of blocks into the scene ponder assumes to be the base plate
* of the schematic's structure. Makes for a nice opener
*/
public void showBasePlate() {
world.showSection(scene.getSceneBuildingUtil().select.cuboid(new BlockPos(scene.offsetX, 0, scene.offsetZ),
new Vec3i(scene.size, 0, scene.size)), Direction.UP);
}
/**
* Before running the upcoming instructions, wait for a duration to let previous
* actions play out. <br>
* Idle does not stall any animations, only schedules a time gap between
* instructions.
*
* @param ticks Duration to wait for
*/
public void idle(int ticks) {
addInstruction(new DelayInstruction(ticks));
}
/**
* Before running the upcoming instructions, wait for a duration to let previous
* actions play out. <br>
* Idle does not stall any animations, only schedules a time gap between
* instructions.
*
* @param seconds Duration to wait for
*/
public void idleSeconds(int seconds) {
idle(seconds * 20);
}
/**
* Once the scene reaches this instruction in the timeline, mark it as
* "finished". This happens automatically when the end of a storyboard is
* reached, but can be desirable to do earlier, in order to bypass the wait for
* any residual text windows to time out. <br>
* So far this event only affects the "next scene" button in the UI to flash.
*/
public void markAsFinished() {
addInstruction(new MarkAsFinishedInstruction());
}
/**
* Pans the scene's camera view around the vertical axis by the given amount
*
* @param degrees
*/
public void rotateCameraY(float degrees) {
addInstruction(new RotateSceneInstruction(0, degrees, true));
}
@ -240,6 +323,36 @@ public class SceneBuilder {
addInstruction(new ReplaceBlocksInstruction(selection, state, false, spawnParticles));
}
public <T extends Entity> void modifyEntities(Class<T> entityClass, Consumer<T> entityCallBack) {
addInstruction(scene -> scene.forEachWorldEntity(entityClass, entityCallBack));
}
public void createEntity(Function<World, Entity> factory) {
addInstruction(scene -> scene.getWorld()
.addEntity(factory.apply(scene.getWorld())));
}
public void createItemEntity(Vec3d location, Vec3d motion, ItemStack stack) {
createEntity(world -> {
ItemEntity itemEntity = new ItemEntity(world, location.x, location.y, location.z, stack);
itemEntity.setMotion(motion);
return itemEntity;
});
}
public void createItemOnBelt(BlockPos beltLocation, Direction insertionSide, ItemStack stack) {
addInstruction(scene -> {
TileEntity tileEntity = scene.getWorld()
.getTileEntity(beltLocation);
if (!(tileEntity instanceof BeltTileEntity))
return;
BeltTileEntity beltTileEntity = (BeltTileEntity) tileEntity;
DirectBeltInputBehaviour behaviour = beltTileEntity.getBehaviour(DirectBeltInputBehaviour.TYPE);
behaviour.handleInsertion(stack, insertionSide.getOpposite(), false);
});
flapFunnels(scene.getSceneBuildingUtil().select.position(beltLocation.up()), true);
}
public void setKineticSpeed(Selection selection, float speed) {
modifyKineticSpeed(selection, f -> speed);
}
@ -272,13 +385,18 @@ public class SceneBuilder {
public class DebugInstructions {
public void debugSchematic() {
addInstruction(new ShowCompleteSchematicInstruction());
addInstruction(
scene -> scene.addElement(new WorldSectionElement(scene.getSceneBuildingUtil().select.everywhere())));
}
public void addInstructionInstance(PonderInstruction instruction) {
addInstruction(instruction);
}
public void enqueueCallback(Consumer<PonderScene> callback) {
addInstruction(callback);
}
}
private void addInstruction(PonderInstruction instruction) {

View file

@ -8,6 +8,9 @@ import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
/**
* Helpful shortcuts for marking boundaries, points or sections inside the scene
*/
public class SceneBuildingUtil {
public final SelectionUtil select;

View file

@ -19,6 +19,8 @@ import com.simibubi.create.foundation.utility.Pointing;
import com.tterrag.registrate.util.entry.ItemEntry;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.ParticleTypes;
@ -41,6 +43,7 @@ public class DebugScenes {
add(DebugScenes::controlsScene);
add(DebugScenes::birbScene);
add(DebugScenes::sectionsScene);
add(DebugScenes::itemScene);
}
private static void add(PonderStoryBoard sb) {
@ -116,7 +119,7 @@ public class DebugScenes {
scene.idle(12);
scene.special.movePointOfInterest(util.grid.at(-4, 5, 4));
scene.overlay.showTargetedText(PonderPalette.RED, parrotPos.add(-.25f, 0.25f, .25f), "wut", "dafuq?", 40);
scene.overlay.showTargetedText(PonderPalette.RED, parrotPos.add(-.25f, 0.25f, .25f), "wut", "wut?", 40);
}
@ -347,4 +350,41 @@ public class DebugScenes {
}
public static void itemScene(SceneBuilder scene, SceneBuildingUtil util) {
scene.configureBasePlate(0, 0, 6);
scene.title("Manipulating Items");
scene.world.showSection(util.select.layer(0), Direction.UP);
scene.idle(10);
scene.world.showSection(util.select.layersFrom(1), Direction.DOWN);
ItemStack brassItem = AllItems.BRASS_INGOT.asStack();
ItemStack copperItem = AllItems.COPPER_INGOT.asStack();
for (int z = 4; z >= 2; z--) {
scene.world.createItemEntity(util.vector.centerOf(0, 4, z), Vec3d.ZERO, brassItem.copy());
scene.idle(10);
}
BlockPos beltPos = util.grid.at(2, 1, 3);
scene.world.createItemOnBelt(beltPos, Direction.EAST, copperItem.copy());
scene.idle(35);
scene.world.modifyEntities(ItemEntity.class, entity -> {
if (copperItem.isItemEqual(entity.getItem()))
entity.setNoGravity(true);
});
scene.idle(20);
scene.world.modifyEntities(ItemEntity.class, entity -> {
if (brassItem.isItemEqual(entity.getItem()))
entity.setMotion(util.vector.at(-.15f, .5f, 0));
});
scene.idle(27);
scene.world.modifyEntities(ItemEntity.class, Entity::remove);
}
}

View file

@ -8,7 +8,9 @@ public class PonderIndex {
public static final boolean EDITOR_MODE = true;
public static void register() {
// Register storyboards here (Changes require re-launch)
// Register storyboards here
// (!) Added entries require re-launch
// (!) Modifications inside storyboard methods only require re-opening the ui
PonderRegistry.forComponent(AllBlocks.SHAFT)
.addStoryBoard("shaft/relay", KineticsScenes::shaftAsRelay)

View file

@ -1,19 +0,0 @@
package com.simibubi.create.foundation.ponder.instructions;
import com.simibubi.create.foundation.ponder.PonderInstruction;
import com.simibubi.create.foundation.ponder.PonderScene;
import com.simibubi.create.foundation.ponder.elements.WorldSectionElement;
public class ShowCompleteSchematicInstruction extends PonderInstruction {
@Override
public void tick(PonderScene scene) {
scene.addElement(new WorldSectionElement(scene.getSceneBuildingUtil().select.everywhere()));
}
@Override
public boolean isComplete() {
return true;
}
}

Binary file not shown.