Keeping outlines until animation is done. Fix itemstack not found error when undoing in creative.
Disabled create test code.
This commit is contained in:
@@ -50,7 +50,7 @@ public class BuildModifiers {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int delay = CommonConfig.visuals.appearAnimationLength.get() * 3; //DelayedBlockPlacer is called 3 times per tick?
|
int delay = CommonConfig.visuals.appearAnimationLength.get() * 3 - 3; //DelayedBlockPlacer is called 3 times per tick?
|
||||||
|
|
||||||
//place blocks after delay
|
//place blocks after delay
|
||||||
EffortlessBuilding.DELAYED_BLOCK_PLACER.placeBlocksDelayed(new DelayedBlockPlacer.Entry(world, player, coordinates,
|
EffortlessBuilding.DELAYED_BLOCK_PLACER.placeBlocksDelayed(new DelayedBlockPlacer.Entry(world, player, coordinates,
|
||||||
|
|||||||
@@ -98,14 +98,14 @@ public class UndoRedo {
|
|||||||
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
||||||
|
|
||||||
//get blockstate from itemstack
|
//get blockstate from itemstack
|
||||||
BlockState previousBlockState = Blocks.AIR.defaultBlockState();
|
BlockState previousBlockState = previousBlockStates.get(i);
|
||||||
if (itemStack.getItem() instanceof BlockItem) {
|
if (itemStack.getItem() instanceof BlockItem) {
|
||||||
previousBlockState = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState();
|
previousBlockState = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.level.isLoaded(coordinate)) {
|
if (player.level.isLoaded(coordinate)) {
|
||||||
//check itemstack empty
|
//check itemstack empty
|
||||||
if (itemStack.isEmpty()) {
|
if (itemStack.isEmpty() && !player.isCreative()) {
|
||||||
itemStack = findItemStackInInventory(player, previousBlockStates.get(i));
|
itemStack = findItemStackInInventory(player, previousBlockStates.get(i));
|
||||||
//get blockstate from new itemstack
|
//get blockstate from new itemstack
|
||||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
|
if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
|
||||||
@@ -158,14 +158,14 @@ public class UndoRedo {
|
|||||||
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
if (previousBlockStates.get(i).equals(newBlockStates.get(i))) continue;
|
||||||
|
|
||||||
//get blockstate from itemstack
|
//get blockstate from itemstack
|
||||||
BlockState newBlockState = Blocks.AIR.defaultBlockState();
|
BlockState newBlockState = newBlockStates.get(i);
|
||||||
if (itemStack.getItem() instanceof BlockItem) {
|
if (itemStack.getItem() instanceof BlockItem) {
|
||||||
newBlockState = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState();
|
newBlockState = ((BlockItem) itemStack.getItem()).getBlock().defaultBlockState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.level.isLoaded(coordinate)) {
|
if (player.level.isLoaded(coordinate)) {
|
||||||
//check itemstack empty
|
//check itemstack empty
|
||||||
if (itemStack.isEmpty()) {
|
if (itemStack.isEmpty() && !player.isCreative()) {
|
||||||
itemStack = findItemStackInInventory(player, newBlockStates.get(i));
|
itemStack = findItemStackInInventory(player, newBlockStates.get(i));
|
||||||
//get blockstate from new itemstack
|
//get blockstate from new itemstack
|
||||||
if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
|
if (!itemStack.isEmpty() && itemStack.getItem() instanceof BlockItem) {
|
||||||
|
|||||||
@@ -11,21 +11,21 @@ import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
|||||||
@Mod.EventBusSubscriber(Dist.CLIENT)
|
@Mod.EventBusSubscriber(Dist.CLIENT)
|
||||||
public class CreateClientTest {
|
public class CreateClientTest {
|
||||||
|
|
||||||
@SubscribeEvent
|
// @SubscribeEvent
|
||||||
public static void onTick(TickEvent.ClientTickEvent event) {
|
// public static void onTick(TickEvent.ClientTickEvent event) {
|
||||||
CreateClient.GHOST_BLOCKS.showGhostState(1, Blocks.SPRUCE_LOG.defaultBlockState())
|
// CreateClient.GHOST_BLOCKS.showGhostState(1, Blocks.SPRUCE_LOG.defaultBlockState())
|
||||||
.at(0, 120, 0)
|
// .at(0, 120, 0)
|
||||||
.breathingAlpha();
|
// .breathingAlpha();
|
||||||
CreateClient.GHOST_BLOCKS.showGhostState(2, Blocks.SPRUCE_LOG.defaultBlockState())
|
// CreateClient.GHOST_BLOCKS.showGhostState(2, Blocks.SPRUCE_LOG.defaultBlockState())
|
||||||
.at(1, 120, 0)
|
// .at(1, 120, 0)
|
||||||
.breathingAlpha();
|
// .breathingAlpha();
|
||||||
|
//
|
||||||
CreateClient.OUTLINER.showAABB(1, new AABB(0, 0, 0, 10, 2, 6)
|
// CreateClient.OUTLINER.showAABB(1, new AABB(0, 0, 0, 10, 2, 6)
|
||||||
.move(10, 120, 0))
|
// .move(10, 120, 0))
|
||||||
.withFaceTexture(AllSpecialTextures.CHECKERED)
|
// .withFaceTexture(AllSpecialTextures.CHECKERED)
|
||||||
.colored(new Color(0.11f, 0.49f, 0.7f, 1f))
|
// .colored(new Color(0.11f, 0.49f, 0.7f, 1f))
|
||||||
// .colored(0xbfbfbf)
|
//// .colored(0xbfbfbf)
|
||||||
.disableNormals()
|
// .disableNormals()
|
||||||
.lineWidth(1 / 32f);
|
// .lineWidth(1 / 32f);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ public class Outliner {
|
|||||||
outlines.get(slot).ticksTillRemoval = 1;
|
outlines.get(slot).ticksTillRemoval = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ADDED
|
||||||
|
public void keep(Object slot, int ticks) {
|
||||||
|
if (outlines.containsKey(slot))
|
||||||
|
outlines.get(slot).ticksTillRemoval = ticks;
|
||||||
|
}
|
||||||
|
|
||||||
public void remove(Object slot) {
|
public void remove(Object slot) {
|
||||||
outlines.remove(slot);
|
outlines.remove(slot);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import nl.requios.effortlessbuilding.compatibility.CompatHelper;
|
|||||||
import nl.requios.effortlessbuilding.create.AllSpecialTextures;
|
import nl.requios.effortlessbuilding.create.AllSpecialTextures;
|
||||||
import nl.requios.effortlessbuilding.create.CreateClient;
|
import nl.requios.effortlessbuilding.create.CreateClient;
|
||||||
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
import nl.requios.effortlessbuilding.create.foundation.utility.Color;
|
||||||
|
import nl.requios.effortlessbuilding.create.foundation.utility.VecHelper;
|
||||||
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
import nl.requios.effortlessbuilding.helper.ReachHelper;
|
||||||
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
import nl.requios.effortlessbuilding.helper.SurvivalHelper;
|
||||||
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
import nl.requios.effortlessbuilding.item.AbstractRandomizerBagItem;
|
||||||
@@ -59,8 +60,6 @@ public class BlockPreviews {
|
|||||||
|
|
||||||
float dissolve = (ClientEvents.ticksInGame - placed.time) / (float) totalTime;
|
float dissolve = (ClientEvents.ticksInGame - placed.time) / (float) totalTime;
|
||||||
renderBlockPreviews(player, modifierSettings, placed.coordinates, placed.blockStates, placed.itemStacks, dissolve, placed.firstPos, placed.secondPos, false, placed.breaking);
|
renderBlockPreviews(player, modifierSettings, placed.coordinates, placed.blockStates, placed.itemStacks, dissolve, placed.firstPos, placed.secondPos, false, placed.breaking);
|
||||||
|
|
||||||
CreateClient.OUTLINER.showCluster(placed.time, placed.coordinates);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,7 +290,7 @@ public class BlockPreviews {
|
|||||||
float scale = 0.5f;
|
float scale = 0.5f;
|
||||||
float alpha = 0.7f;
|
float alpha = 0.7f;
|
||||||
if (dissolve > 0f) {
|
if (dissolve > 0f) {
|
||||||
float animationLength = 0.7f;
|
float animationLength = 0.8f;
|
||||||
|
|
||||||
double firstToSecond = secondPos.distSqr(firstPos);
|
double firstToSecond = secondPos.distSqr(firstPos);
|
||||||
double place = 0;
|
double place = 0;
|
||||||
@@ -308,20 +307,18 @@ public class BlockPreviews {
|
|||||||
t = Mth.clamp(t, 0, 1);
|
t = Mth.clamp(t, 0, 1);
|
||||||
//Now we got a usable t value for this block
|
//Now we got a usable t value for this block
|
||||||
|
|
||||||
float sine = Mth.sin((t + (1/7f) * t) * Mth.TWO_PI - (3/4f) * Mth.PI); // -1 to 1
|
|
||||||
sine = (sine + 1f) / 2f; // 0 to 1
|
|
||||||
|
|
||||||
// scale = 1f + (sine * 0.5f);
|
|
||||||
|
|
||||||
t = (float) Mth.smoothstep(t);
|
t = (float) Mth.smoothstep(t);
|
||||||
|
// t = (float) bezier(t, .58,-0.08,.23,1.33);
|
||||||
|
|
||||||
if (!breaking) {
|
if (!breaking) {
|
||||||
scale = 0.5f + (t * 0.3f);
|
scale = 0.5f + (t * 0.3f);
|
||||||
alpha = 0.7f + (t * 0.3f);
|
alpha = 0.7f + (t * 0.3f);
|
||||||
} else {
|
} else {
|
||||||
t = 1f - t;
|
t = 1f - t;
|
||||||
scale = 0.5f + (t * 0.5f);
|
scale = 0.5f + (t * 0.5f);
|
||||||
alpha = t;
|
alpha = 0.7f + (t * 0.3f);
|
||||||
}
|
}
|
||||||
|
alpha = Mth.clamp(alpha, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateClient.GHOST_BLOCKS.showGhostState(blockPos.toShortString(), blockState)
|
CreateClient.GHOST_BLOCKS.showGhostState(blockPos.toShortString(), blockState)
|
||||||
@@ -330,6 +327,23 @@ public class BlockPreviews {
|
|||||||
.scale(scale);
|
.scale(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//A bezier easing function where implicit first and last control points are (0,0) and (1,1).
|
||||||
|
public static double bezier(double t, double x1, double y1, double x2, double y2) {
|
||||||
|
double t2 = t * t;
|
||||||
|
double t3 = t2 * t;
|
||||||
|
|
||||||
|
double cx = 3.0 * x1;
|
||||||
|
double bx = 3.0 * (x2 - x1) - cx;
|
||||||
|
double ax = 1.0 - cx -bx;
|
||||||
|
|
||||||
|
double cy = 3.0 * y1;
|
||||||
|
double by = 3.0 * (y2 - y1) - cy;
|
||||||
|
double ay = 1.0 - cy - by;
|
||||||
|
|
||||||
|
// Calculate the curve point at parameter value t
|
||||||
|
return (ay * t3) + (by * t2) + (cy * t) + 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static void onBlocksPlaced() {
|
public static void onBlocksPlaced() {
|
||||||
onBlocksPlaced(previousCoordinates, previousItemStacks, previousBlockStates, previousFirstPos, previousSecondPos);
|
onBlocksPlaced(previousCoordinates, previousItemStacks, previousBlockStates, previousFirstPos, previousSecondPos);
|
||||||
}
|
}
|
||||||
@@ -350,6 +364,8 @@ public class BlockPreviews {
|
|||||||
placedDataList.add(new PlacedData(ClientEvents.ticksInGame, coordinates, blockStates,
|
placedDataList.add(new PlacedData(ClientEvents.ticksInGame, coordinates, blockStates,
|
||||||
itemStacks, firstPos, secondPos, false));
|
itemStacks, firstPos, secondPos, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreateClient.OUTLINER.keep(firstPos, CommonConfig.visuals.appearAnimationLength.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -376,6 +392,8 @@ public class BlockPreviews {
|
|||||||
placedDataList.add(new PlacedData(ClientEvents.ticksInGame, coordinates, blockStates,
|
placedDataList.add(new PlacedData(ClientEvents.ticksInGame, coordinates, blockStates,
|
||||||
itemStacks, firstPos, secondPos, true));
|
itemStacks, firstPos, secondPos, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreateClient.OUTLINER.keep(firstPos, CommonConfig.visuals.breakAnimationLength.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user