Merge branch 'mc1.15/dev' into mc1.16/dev
This commit is contained in:
commit
37c3625d4a
12 changed files with 185 additions and 103 deletions
|
@ -14,21 +14,19 @@ import com.simibubi.create.content.curiosities.tools.SandPaperItem;
|
|||
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
||||
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.block.AbstractFireBlock;
|
||||
import net.minecraft.block.BeehiveBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
|
@ -41,13 +39,13 @@ import net.minecraft.item.ItemUseContext;
|
|||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.management.PlayerInteractionManager;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.tileentity.BeehiveTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
|
@ -55,6 +53,7 @@ import net.minecraft.util.math.RayTraceContext;
|
|||
import net.minecraft.util.math.RayTraceContext.BlockMode;
|
||||
import net.minecraft.util.math.RayTraceContext.FluidMode;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
@ -218,7 +217,7 @@ public class DeployerHandler {
|
|||
progress += before;
|
||||
|
||||
if (progress >= 1) {
|
||||
safeTryHarvestBlock(player.interactionManager, clickedPos);
|
||||
tryHarvestBlock(player.interactionManager, clickedPos);
|
||||
world.sendBlockBreakProgress(player.getEntityId(), clickedPos, -1);
|
||||
player.blockBreakingProgress = null;
|
||||
return;
|
||||
|
@ -240,7 +239,7 @@ public class DeployerHandler {
|
|||
Event.Result useItem = DEFAULT;
|
||||
if (!clickedState.getShape(world, clickedPos)
|
||||
.isEmpty()) {
|
||||
RightClickBlock event = ForgeHooks.onRightClickBlock(player, hand, clickedPos, face);
|
||||
RightClickBlock event = ForgeHooks.onRightClickBlock(player, hand, clickedPos, result);
|
||||
useBlock = event.getUseBlock();
|
||||
useItem = event.getUseItem();
|
||||
}
|
||||
|
@ -257,11 +256,9 @@ public class DeployerHandler {
|
|||
boolean flag1 =
|
||||
!(player.isSneaking() && holdingSomething) || (stack.doesSneakBypassUse(world, clickedPos, player));
|
||||
|
||||
if (clickedState.getBlock() instanceof BeehiveBlock)
|
||||
return; // Beehives assume a lot about the usage context. Crashes to side-effects
|
||||
|
||||
// Use on block
|
||||
if (useBlock != DENY && flag1 && clickedState.onUse(world, player, hand, result) == ActionResultType.SUCCESS)
|
||||
if (useBlock != DENY && flag1
|
||||
&& safeOnUse(clickedState, world, clickedPos, player, hand, result) == ActionResultType.SUCCESS)
|
||||
return;
|
||||
if (stack.isEmpty())
|
||||
return;
|
||||
|
@ -296,7 +293,8 @@ public class DeployerHandler {
|
|||
|
||||
ActionResult<ItemStack> onItemRightClick = item.onItemRightClick(itemUseWorld, player, hand);
|
||||
ItemStack resultStack = onItemRightClick.getResult();
|
||||
if (resultStack != stack || resultStack.getCount() != stack.getCount() || resultStack.getUseDuration() > 0 || resultStack.getDamage() != stack.getDamage()) {
|
||||
if (resultStack != stack || resultStack.getCount() != stack.getCount() || resultStack.getUseDuration() > 0
|
||||
|| resultStack.getDamage() != stack.getDamage()) {
|
||||
player.setHeldItem(hand, onItemRightClick.getResult());
|
||||
}
|
||||
|
||||
|
@ -311,51 +309,89 @@ public class DeployerHandler {
|
|||
player.resetActiveHand();
|
||||
}
|
||||
|
||||
private static boolean safeTryHarvestBlock(PlayerInteractionManager interactionManager, BlockPos clickedPos) {
|
||||
BlockState state = interactionManager.world.getBlockState(clickedPos);
|
||||
if (!(state.getBlock() instanceof BeehiveBlock))
|
||||
return interactionManager.tryHarvestBlock(clickedPos);
|
||||
else {
|
||||
harvestBeehive(interactionManager, state, clickedPos);
|
||||
}
|
||||
public static boolean tryHarvestBlock(PlayerInteractionManager interactionManager, BlockPos pos) {
|
||||
// <> PlayerInteractionManager#tryHarvestBlock
|
||||
|
||||
ServerWorld world = interactionManager.world;
|
||||
ServerPlayerEntity player = interactionManager.player;
|
||||
BlockState blockstate = world.getBlockState(pos);
|
||||
GameType gameType = interactionManager.getGameType();
|
||||
|
||||
if (net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(world, gameType, player, pos) == -1)
|
||||
return false;
|
||||
|
||||
TileEntity tileentity = world.getTileEntity(pos);
|
||||
if (player.getHeldItemMainhand()
|
||||
.onBlockStartBreak(pos, player))
|
||||
return false;
|
||||
if (player.isBlockBreakingRestricted(world, pos, gameType))
|
||||
return false;
|
||||
|
||||
ItemStack prevHeldItem = player.getHeldItemMainhand();
|
||||
ItemStack heldItem = prevHeldItem.copy();
|
||||
|
||||
boolean canHarvest = blockstate.canHarvestBlock(world, pos, player);
|
||||
prevHeldItem.onBlockDestroyed(world, blockstate, pos, player);
|
||||
if (prevHeldItem.isEmpty() && !heldItem.isEmpty())
|
||||
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, heldItem, Hand.MAIN_HAND);
|
||||
if (!blockstate.removedByPlayer(world, pos, player, canHarvest, world.getFluidState(pos)))
|
||||
return true;
|
||||
|
||||
blockstate.getBlock()
|
||||
.onPlayerDestroy(world, pos, blockstate);
|
||||
if (!canHarvest)
|
||||
return true;
|
||||
|
||||
Block.getDrops(blockstate, world, pos, tileentity, player, prevHeldItem)
|
||||
.forEach(item -> player.inventory.placeItemBackInInventory(world, item));
|
||||
blockstate.spawnAdditionalDrops(world, pos, prevHeldItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void harvestBeehive(PlayerInteractionManager interactionManager, BlockState state,
|
||||
BlockPos clickedPos) {
|
||||
// Modified code from PlayerInteractionManager, Block and BeehiveBlock to handle
|
||||
// deployers breaking beehives without crash.
|
||||
ItemStack itemstack = interactionManager.player.getHeldItemMainhand();
|
||||
ItemStack itemstack1 = itemstack.copy();
|
||||
|
||||
boolean flag1 = state.canHarvestBlock(interactionManager.world, clickedPos, interactionManager.player);
|
||||
itemstack.onBlockDestroyed(interactionManager.world, state, clickedPos, interactionManager.player);
|
||||
if (itemstack.isEmpty() && !itemstack1.isEmpty())
|
||||
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(interactionManager.player, itemstack1,
|
||||
Hand.MAIN_HAND);
|
||||
|
||||
boolean flag = state.removedByPlayer(interactionManager.world, clickedPos, interactionManager.player, flag1,
|
||||
interactionManager.world.getFluidState(clickedPos));
|
||||
if (flag)
|
||||
state.getBlock()
|
||||
.onPlayerDestroy(interactionManager.world, clickedPos, state);
|
||||
|
||||
if (flag && flag1) {
|
||||
interactionManager.player.addStat(Stats.BLOCK_MINED.get(state.getBlock()));
|
||||
interactionManager.player.addExhaustion(0.005F);
|
||||
TileEntity te = interactionManager.world.getTileEntity(clickedPos);
|
||||
ItemStack heldItem = interactionManager.player.getHeldItemMainhand();
|
||||
Block.spawnDrops(state, interactionManager.world, clickedPos, te, interactionManager.player, heldItem);
|
||||
|
||||
if (!interactionManager.world.isRemote && te instanceof BeehiveTileEntity) {
|
||||
BeehiveTileEntity beehivetileentity = (BeehiveTileEntity) te;
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, heldItem) == 0) {
|
||||
interactionManager.world.updateComparatorOutputLevel(clickedPos, state.getBlock());
|
||||
}
|
||||
|
||||
CriteriaTriggers.BEE_NEST_DESTROYED.test(interactionManager.player,
|
||||
state.getBlock(), heldItem, beehivetileentity.getBeeCount());
|
||||
}
|
||||
}
|
||||
public static ActionResultType safeOnUse(BlockState state, World world, BlockPos pos, PlayerEntity player,
|
||||
Hand hand, BlockRayTraceResult ray) {
|
||||
if (state.getBlock() instanceof BeehiveBlock)
|
||||
return safeOnBeehiveUse(state, world, pos, player, hand);
|
||||
return state.onUse(world, player, hand, ray);
|
||||
}
|
||||
|
||||
protected static ActionResultType safeOnBeehiveUse(BlockState state, World world, BlockPos pos, PlayerEntity player,
|
||||
Hand hand) {
|
||||
// <> BeehiveBlock#onUse
|
||||
|
||||
BeehiveBlock block = (BeehiveBlock) state.getBlock();
|
||||
ItemStack prevHeldItem = player.getHeldItem(hand);
|
||||
int honeyLevel = state.get(BeehiveBlock.HONEY_LEVEL);
|
||||
boolean success = false;
|
||||
if (honeyLevel < 5)
|
||||
return ActionResultType.PASS;
|
||||
|
||||
if (prevHeldItem.getItem() == Items.SHEARS) {
|
||||
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.BLOCK_BEEHIVE_SHEAR,
|
||||
SoundCategory.NEUTRAL, 1.0F, 1.0F);
|
||||
// <> BeehiveBlock#dropHoneycomb
|
||||
player.inventory.placeItemBackInInventory(world, new ItemStack(Items.HONEYCOMB, 3));
|
||||
prevHeldItem.damageItem(1, player, s -> s.sendBreakAnimation(hand));
|
||||
success = true;
|
||||
}
|
||||
|
||||
if (prevHeldItem.getItem() == Items.GLASS_BOTTLE) {
|
||||
prevHeldItem.shrink(1);
|
||||
world.playSound(player, player.getX(), player.getY(), player.getZ(), SoundEvents.ITEM_BOTTLE_FILL,
|
||||
SoundCategory.NEUTRAL, 1.0F, 1.0F);
|
||||
ItemStack honeyBottle = new ItemStack(Items.HONEY_BOTTLE);
|
||||
if (prevHeldItem.isEmpty())
|
||||
player.setHeldItem(hand, honeyBottle);
|
||||
else
|
||||
player.inventory.placeItemBackInInventory(world, honeyBottle);
|
||||
success = true;
|
||||
}
|
||||
|
||||
if (!success)
|
||||
return ActionResultType.PASS;
|
||||
|
||||
block.takeHoney(world, state, pos);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,6 +59,11 @@ public class ContraptionKineticRenderer extends InstancedTileRenderer<Contraptio
|
|||
actors.forEach(ActorInstance::beginFrame);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldTick(BlockPos worldPos, float lookX, float lookY, float lookZ, int cX, int cY, int cZ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ActorInstance createActor(Pair<Template.BlockInfo, MovementContext> actor) {
|
||||
Template.BlockInfo blockInfo = actor.getLeft();
|
||||
|
|
|
@ -157,6 +157,8 @@ public class FluidPropagator {
|
|||
if (PumpBlock.isPump(connectedState) && connectedState.get(PumpBlock.FACING)
|
||||
.getAxis() == side.getAxis())
|
||||
return false;
|
||||
if (connectedState.contains(BlockStateProperties.HONEY_LEVEL))
|
||||
return true;
|
||||
if (BlockHelper.hasBlockSolidSide(connectedState, reader, connectedPos, side.getOpposite()))
|
||||
return false;
|
||||
if (!(connectedState.getMaterial()
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.simibubi.create.content.contraptions.fluids;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.HONEY_LEVEL;
|
||||
import static net.minecraft.state.properties.BlockStateProperties.WATERLOGGED;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -22,7 +25,6 @@ import net.minecraft.nbt.CompoundNBT;
|
|||
import net.minecraft.potion.Effect;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.PotionUtils;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
|
@ -72,7 +74,13 @@ public class OpenEndedPipe extends FlowSource {
|
|||
|
||||
BlockState state = world.getBlockState(outputPos);
|
||||
FluidState fluidState = state.getFluidState();
|
||||
boolean waterlog = state.contains(BlockStateProperties.WATERLOGGED);
|
||||
boolean waterlog = state.contains(WATERLOGGED);
|
||||
|
||||
if (state.contains(HONEY_LEVEL) && state.get(HONEY_LEVEL) >= 5) {
|
||||
if (!simulate)
|
||||
world.setBlockState(outputPos, state.with(HONEY_LEVEL, 0), 3);
|
||||
return new FluidStack(AllFluids.HONEY.get(), 250);
|
||||
}
|
||||
|
||||
if (!waterlog && !state.getMaterial()
|
||||
.isReplaceable())
|
||||
|
@ -84,11 +92,11 @@ public class OpenEndedPipe extends FlowSource {
|
|||
|
||||
if (simulate)
|
||||
return stack;
|
||||
|
||||
|
||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.PIPE_SPILL, world, pos, 5);
|
||||
|
||||
if (waterlog) {
|
||||
world.setBlockState(outputPos, state.with(BlockStateProperties.WATERLOGGED, false), 3);
|
||||
world.setBlockState(outputPos, state.with(WATERLOGGED, false), 3);
|
||||
world.getPendingFluidTicks()
|
||||
.scheduleTick(outputPos, Fluids.WATER, 1);
|
||||
return stack;
|
||||
|
@ -106,7 +114,7 @@ public class OpenEndedPipe extends FlowSource {
|
|||
|
||||
BlockState state = world.getBlockState(outputPos);
|
||||
FluidState fluidState = state.getFluidState();
|
||||
boolean waterlog = state.contains(BlockStateProperties.WATERLOGGED);
|
||||
boolean waterlog = state.contains(WATERLOGGED);
|
||||
|
||||
if (!waterlog && !state.getMaterial()
|
||||
.isReplaceable())
|
||||
|
@ -140,11 +148,11 @@ public class OpenEndedPipe extends FlowSource {
|
|||
2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.PIPE_SPILL, world, pos, 5);
|
||||
|
||||
if (waterlog) {
|
||||
world.setBlockState(outputPos, state.with(BlockStateProperties.WATERLOGGED, true), 3);
|
||||
world.setBlockState(outputPos, state.with(WATERLOGGED, true), 3);
|
||||
world.getPendingFluidTicks()
|
||||
.scheduleTick(outputPos, Fluids.WATER, 1);
|
||||
return true;
|
||||
|
|
|
@ -142,6 +142,8 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren
|
|||
public static boolean canConnectTo(IBlockDisplayReader world, BlockPos neighbourPos, BlockState neighbour, Direction direction) {
|
||||
if (FluidPropagator.hasFluidCapability(world, neighbourPos, direction.getOpposite()))
|
||||
return true;
|
||||
if (neighbour.has(BlockStateProperties.HONEY_LEVEL))
|
||||
return true;
|
||||
FluidTransportBehaviour transport = TileEntityBehaviour.get(world, neighbourPos, FluidTransportBehaviour.TYPE);
|
||||
BracketedTileEntityBehaviour bracket = TileEntityBehaviour.get(world, neighbourPos, BracketedTileEntityBehaviour.TYPE);
|
||||
if (isPipe(neighbour))
|
||||
|
|
|
@ -78,13 +78,13 @@ public class ArmTileEntity extends KineticTileEntity {
|
|||
phase = Phase.SEARCH_INPUTS;
|
||||
previousTarget = ArmAngleTarget.NO_TARGET;
|
||||
baseAngle = new InterpolatedAngle();
|
||||
baseAngle.set(previousTarget.baseAngle);
|
||||
baseAngle.init(previousTarget.baseAngle);
|
||||
lowerArmAngle = new InterpolatedAngle();
|
||||
lowerArmAngle.set(previousTarget.lowerArmAngle);
|
||||
lowerArmAngle.init(previousTarget.lowerArmAngle);
|
||||
upperArmAngle = new InterpolatedAngle();
|
||||
upperArmAngle.set(previousTarget.upperArmAngle);
|
||||
upperArmAngle.init(previousTarget.upperArmAngle);
|
||||
headAngle = new InterpolatedAngle();
|
||||
headAngle.set(previousTarget.headAngle);
|
||||
headAngle.init(previousTarget.headAngle);
|
||||
clawAngle = new InterpolatedAngle();
|
||||
previousBaseAngle = previousTarget.baseAngle;
|
||||
updateInteractionPoints = true;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.simibubi.create.foundation.config;
|
|||
public class CClient extends ConfigBase {
|
||||
|
||||
public ConfigGroup client = group(0, "client",
|
||||
"Client-only settings - If you're looking for general settings, look inside your worlds serverconfig folder!");
|
||||
"Client-only settings - If you're looking for general settings, look inside your worlds serverconfig folder!");
|
||||
public ConfigBool tooltips = b(true, "enableTooltips", "Show item descriptions on Shift and controls on Ctrl.");
|
||||
public ConfigBool enableOverstressedTooltip =
|
||||
b(true, "enableOverstressedTooltip", "Display a tooltip when looking at overstressed components.");
|
||||
|
@ -12,14 +12,20 @@ public class CClient extends ConfigBase {
|
|||
public ConfigFloat fanParticleDensity = f(.5f, 0, 1, "fanParticleDensity");
|
||||
public ConfigBool rainbowDebug =
|
||||
b(true, "enableRainbowDebug", "Show colourful debug information while the F3-Menu is open.");
|
||||
|
||||
public ConfigBool experimentalRendering =
|
||||
b(true, "experimentalRendering", "Use modern OpenGL features to drastically increase performance.");
|
||||
|
||||
public ConfigInt overlayOffsetX = i(20, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetX", "Offset the overlay from goggle- and hover- information by this many pixels on the X axis; Use /create overlay");
|
||||
public ConfigInt overlayOffsetY = i(0, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetY", "Offset the overlay from goggle- and hover- information by this many pixels on the Y axis; Use /create overlay");
|
||||
public ConfigInt overlayOffsetX = i(20, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetX",
|
||||
"Offset the overlay from goggle- and hover- information by this many pixels on the X axis; Use /create overlay");
|
||||
public ConfigInt overlayOffsetY = i(0, Integer.MIN_VALUE, Integer.MAX_VALUE, "overlayOffsetY",
|
||||
"Offset the overlay from goggle- and hover- information by this many pixels on the Y axis; Use /create overlay");
|
||||
public ConfigBool smoothPlacementIndicator = b(false, "smoothPlacementIndicator",
|
||||
"Use an alternative indicator when showing where the assisted placement ends up relative to your crosshair");
|
||||
public ConfigEnum<PlacementIndicatorSetting> placementIndicator = e(PlacementIndicatorSetting.TEXTURE, "placementIndicator", "What indicator should be used when showing where the assisted placement ends up relative to your crosshair");
|
||||
public ConfigBool ignoreFabulousWarning = b(false, "ignoreFabulousWarning", "Setting this to true will prevent Create from sending you a warning when playing with Fabulous graphics enabled");
|
||||
|
||||
public ConfigGroup ponder = group(1, "ponder", "Ponder settings");
|
||||
public ConfigBool comfyReading =
|
||||
b(false, "comfyReading", "Slow down a ponder scene whenever there is text on screen.");
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
|
|
@ -12,6 +12,11 @@ public class InterpolatedValue {
|
|||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public InterpolatedValue init(float value) {
|
||||
this.lastValue = this.value = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float get(float partialTicks) {
|
||||
return MathHelper.lerp(partialTicks, lastValue, value);
|
||||
|
|
|
@ -5,6 +5,7 @@ import static com.simibubi.create.foundation.ponder.PonderLocalization.LANG_PREF
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||
|
@ -12,7 +13,12 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.foundation.gui.*;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
import com.simibubi.create.foundation.gui.AllIcons;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
import com.simibubi.create.foundation.gui.ScreenOpener;
|
||||
import com.simibubi.create.foundation.gui.UIRenderHelper;
|
||||
import com.simibubi.create.foundation.ponder.PonderScene.SceneTransform;
|
||||
import com.simibubi.create.foundation.ponder.content.DebugScenes;
|
||||
import com.simibubi.create.foundation.ponder.content.PonderChapter;
|
||||
|
@ -22,9 +28,15 @@ import com.simibubi.create.foundation.ponder.content.PonderTagScreen;
|
|||
import com.simibubi.create.foundation.ponder.elements.TextWindowElement;
|
||||
import com.simibubi.create.foundation.ponder.ui.PonderButton;
|
||||
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
|
||||
import com.simibubi.create.foundation.utility.*;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
import com.simibubi.create.foundation.utility.FontHelper;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.Pair;
|
||||
import com.simibubi.create.foundation.utility.Pointing;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
import com.simibubi.create.foundation.utility.animation.LerpedFloat.Chaser;
|
||||
|
||||
import net.minecraft.client.ClipboardHelper;
|
||||
import net.minecraft.client.GameSettings;
|
||||
import net.minecraft.client.MainWindow;
|
||||
|
@ -50,8 +62,6 @@ import net.minecraft.world.gen.feature.template.Template;
|
|||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class PonderUI extends NavigatableSimiScreen {
|
||||
|
||||
public static int ponderTicks;
|
||||
|
@ -76,7 +86,6 @@ public class PonderUI extends NavigatableSimiScreen {
|
|||
PonderChapter chapter = null;
|
||||
|
||||
private boolean userViewMode;
|
||||
private boolean slowTextMode;
|
||||
private boolean identifyMode;
|
||||
private ItemStack hoveredTooltipItem;
|
||||
private BlockPos hoveredBlockPos;
|
||||
|
@ -201,7 +210,7 @@ public class PonderUI extends NavigatableSimiScreen {
|
|||
.fade(0, -1));
|
||||
|
||||
widgets.add(slowMode = new PonderButton(width - 20 - 31, bY, () -> {
|
||||
slowTextMode = !slowTextMode;
|
||||
setComfyReadingEnabled(!isComfyReadingEnabled());
|
||||
}).showing(AllIcons.I_MTD_SLOW_MODE)
|
||||
.fade(0, -1));
|
||||
|
||||
|
@ -265,7 +274,7 @@ public class PonderUI extends NavigatableSimiScreen {
|
|||
PonderScene activeScene = scenes.get(index);
|
||||
|
||||
extendedTickLength = 0;
|
||||
if (slowTextMode)
|
||||
if (isComfyReadingEnabled())
|
||||
activeScene.forEachVisible(TextWindowElement.class, twe -> extendedTickLength = 2);
|
||||
|
||||
if (extendedTickTimer == 0) {
|
||||
|
@ -612,7 +621,7 @@ public class PonderUI extends NavigatableSimiScreen {
|
|||
userMode.dim();
|
||||
}
|
||||
|
||||
if (slowTextMode)
|
||||
if (isComfyReadingEnabled())
|
||||
slowMode.flash();
|
||||
else
|
||||
slowMode.dim();
|
||||
|
@ -976,4 +985,13 @@ public class PonderUI extends NavigatableSimiScreen {
|
|||
public void drawRightAlignedString(FontRenderer fontRenderer, MatrixStack ms, String string, int x, int y, int color) {
|
||||
fontRenderer.draw(ms, string, (float)(x - fontRenderer.getStringWidth(string)), (float)y, color);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isComfyReadingEnabled() {
|
||||
return AllConfigs.CLIENT.comfyReading.get();
|
||||
}
|
||||
|
||||
public void setComfyReadingEnabled(boolean slowTextMode) {
|
||||
AllConfigs.CLIENT.comfyReading.set(slowTextMode);
|
||||
}
|
||||
|
||||
}
|
|
@ -8,7 +8,7 @@ import net.minecraft.block.Blocks;
|
|||
|
||||
public class PonderIndex {
|
||||
|
||||
public static final boolean EDITOR_MODE = true;
|
||||
public static final boolean EDITOR_MODE = false;
|
||||
|
||||
public static void register() {
|
||||
// Register storyboards here
|
||||
|
|
|
@ -84,8 +84,8 @@ public class InputWindowElement extends AnimatedOverlayElement {
|
|||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
int xFade = direction == Pointing.RIGHT ? -1 : direction == Pointing.LEFT ? 1 : 0;
|
||||
int yFade = direction == Pointing.DOWN ? -1 : direction == Pointing.UP ? 1 : 0;
|
||||
float xFade = direction == Pointing.RIGHT ? -1 : direction == Pointing.LEFT ? 1 : 0;
|
||||
float yFade = direction == Pointing.DOWN ? -1 : direction == Pointing.UP ? 1 : 0;
|
||||
xFade *= 10 * (1 - fade);
|
||||
yFade *= 10 * (1 - fade);
|
||||
|
||||
|
|
|
@ -60,11 +60,7 @@ public abstract class InstancedTileRenderer<P extends BasicProgram> {
|
|||
int dY = pos.getY() - cY;
|
||||
int dZ = pos.getZ() - cZ;
|
||||
|
||||
int dSq = dX * dX + dY * dY + dZ * dZ;
|
||||
|
||||
int divisor = (dSq / 1024) + 1;
|
||||
|
||||
if (frame % divisor == 0)
|
||||
if ((frame % getUpdateDivisor(dX, dY, dZ)) == 0)
|
||||
instance.tick();
|
||||
}
|
||||
}
|
||||
|
@ -91,21 +87,7 @@ public abstract class InstancedTileRenderer<P extends BasicProgram> {
|
|||
continue;
|
||||
}
|
||||
|
||||
BlockPos pos = dyn.getWorldPosition();
|
||||
|
||||
int dX = pos.getX() - cX;
|
||||
int dY = pos.getY() - cY;
|
||||
int dZ = pos.getZ() - cZ;
|
||||
|
||||
float dot = dX * lookX + dY * lookY + dZ * lookZ;
|
||||
|
||||
if (dot < 0) continue; // is it behind the camera?
|
||||
|
||||
int dSq = dX * dX + dY * dY + dZ * dZ;
|
||||
|
||||
int divisor = (dSq / 1024) + 1; // https://www.desmos.com/calculator/aaycpludsy
|
||||
|
||||
if (frame % divisor == 0)
|
||||
if (shouldTick(dyn.getWorldPosition(), lookX, lookY, lookZ, cX, cY, cZ))
|
||||
dyn.beginFrame();
|
||||
}
|
||||
}
|
||||
|
@ -210,6 +192,24 @@ public abstract class InstancedTileRenderer<P extends BasicProgram> {
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean shouldTick(BlockPos worldPos, float lookX, float lookY, float lookZ, int cX, int cY, int cZ) {
|
||||
int dX = worldPos.getX() - cX;
|
||||
int dY = worldPos.getY() - cY;
|
||||
int dZ = worldPos.getZ() - cZ;
|
||||
|
||||
float dot = dX * lookX + dY * lookY + dZ * lookZ;
|
||||
|
||||
if (dot < 0) return false; // is it behind the camera?
|
||||
|
||||
return (frame % getUpdateDivisor(dX, dY, dZ)) == 0;
|
||||
}
|
||||
|
||||
protected int getUpdateDivisor(int dX, int dY, int dZ) {
|
||||
int dSq = dX * dX + dY * dY + dZ * dZ;
|
||||
|
||||
return (dSq / 1024) + 1;
|
||||
}
|
||||
|
||||
private void addInternal(TileEntity tile) {
|
||||
getInstance(tile, true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue