Merge remote-tracking branch 'origin/mc1.18/dev' into mc1.18/dev

This commit is contained in:
zelophed 2024-08-06 20:08:11 +02:00
commit 8c696b5f8a
21 changed files with 219 additions and 46 deletions

View file

@ -203,6 +203,7 @@ dependencies {
// implementation fg.deobf("curse.maven:druidcraft-340991:3101903")
// implementation fg.deobf("com.ferreusveritas.dynamictrees:DynamicTrees-1.16.5:0.10.0-Beta25")
// runtimeOnly fg.deobf("curse.maven:framedblocks-441647:4567924")
// runtimeOnly fg.deobf("curse.maven:galosphere-631098:4398234")
// runtimeOnly fg.deobf("curse.maven:elementary-ores-332609:3956498")
// runtimeOnly fg.deobf("curse.maven:flib-661261:3956196")

View file

@ -25,7 +25,7 @@ registrate_version = MC1.18.2-1.1.3
flywheel_minecraft_version = 1.18.2
flywheel_version = 0.6.10-105
jei_minecraft_version = 1.18.2
jei_version = 9.7.0.209
jei_version = 9.7.2.277
curios_minecraft_version = 1.18.2
curios_version = 5.0.7.0

View file

@ -2,7 +2,6 @@ package com.simibubi.create;
import static com.simibubi.create.AllTags.NameSpace.CURIOS;
import static com.simibubi.create.AllTags.NameSpace.FORGE;
import static com.simibubi.create.AllTags.NameSpace.GS;
import static com.simibubi.create.AllTags.NameSpace.MOD;
import static com.simibubi.create.AllTags.NameSpace.QUARK;
import static com.simibubi.create.AllTags.NameSpace.TIC;

View file

@ -6,6 +6,8 @@ import java.util.function.Supplier;
import com.simibubi.create.foundation.utility.Lang;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.registries.ForgeRegistries;
@ -25,6 +27,7 @@ public enum Mods {
SOPHISTICATEDSTORAGE,
STORAGEDRAWERS,
TCONSTRUCT,
FRAMEDBLOCKS,
XLPACKETS,
MODERNUI;
@ -48,6 +51,19 @@ public enum Mods {
public Block getBlock(String id) {
return ForgeRegistries.BLOCKS.getValue(rl(id));
}
public Item getItem(String id) {
return ForgeRegistries.ITEMS.getValue(rl(id));
}
public boolean contains(ItemLike entry) {
if (!isLoaded())
return false;
Item asItem = entry.asItem();
return asItem != null && asItem.getRegistryName()
.getNamespace()
.equals(id);
}
/**
* @return a boolean of whether the mod is loaded or not based on mod id

View file

@ -0,0 +1,71 @@
package com.simibubi.create.compat.framedblocks;
import java.util.ArrayList;
import java.util.List;
import com.simibubi.create.compat.Mods;
import com.simibubi.create.content.schematics.requirement.ItemRequirement;
import com.simibubi.create.content.schematics.requirement.ItemRequirement.ItemUseType;
import com.simibubi.create.content.schematics.requirement.ItemRequirement.StackRequirement;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
public class FramedBlocksInSchematics {
static final List<String> KEYS_TO_RETAIN =
List.of("intangible", "glowing", "reinforced", "camo_stack", "camo_stack_two", "camo_state", "camo_state_two");
public static CompoundTag prepareBlockEntityData(BlockState blockState, BlockEntity blockEntity) {
CompoundTag data = null;
if (blockEntity == null)
return data;
data = blockEntity.saveWithFullMetadata();
List<String> keysToRemove = new ArrayList<>();
for (String key : data.getAllKeys())
if (!KEYS_TO_RETAIN.contains(key))
keysToRemove.add(key);
for (String key : keysToRemove)
data.remove(key);
return data;
}
public static ItemRequirement getRequiredItems(BlockState blockState, BlockEntity blockEntity) {
if (blockEntity == null)
return ItemRequirement.NONE;
CompoundTag data = blockEntity.saveWithFullMetadata();
List<StackRequirement> list = new ArrayList<>();
if (data.getBoolean("intangible"))
list.add(new StackRequirement(new ItemStack(Items.PHANTOM_MEMBRANE), ItemUseType.CONSUME));
if (data.getBoolean("glowing"))
list.add(new StackRequirement(new ItemStack(Items.GLOWSTONE_DUST), ItemUseType.CONSUME));
if (data.getBoolean("reinforced"))
list.add(new StackRequirement(new ItemStack(Mods.FRAMEDBLOCKS.getItem("framed_reinforcement")),
ItemUseType.CONSUME));
if (data.contains("camo_stack"))
addCamoStack(data.getCompound("camo_stack"), list);
if (data.contains("camo_stack_two"))
addCamoStack(data.getCompound("camo_stack_two"), list);
return new ItemRequirement(list);
}
private static void addCamoStack(CompoundTag tag, List<StackRequirement> list) {
ItemStack itemStack = ItemStack.of(tag);
if (!itemStack.isEmpty())
list.add(new StackRequirement(itemStack, ItemUseType.CONSUME));
}
}

View file

@ -870,10 +870,11 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit
public static class ContraptionRotationState {
public static final ContraptionRotationState NONE = new ContraptionRotationState();
float xRotation = 0;
float yRotation = 0;
float zRotation = 0;
float secondYRotation = 0;
public float xRotation = 0;
public float yRotation = 0;
public float zRotation = 0;
public float secondYRotation = 0;
Matrix3d matrix;
public Matrix3d asMatrix() {

View file

@ -1125,7 +1125,7 @@ public abstract class Contraption {
CompoundTag tag = block.nbt;
if (blockEntity != null)
tag = NBTProcessors.process(blockEntity, tag, false);
tag = NBTProcessors.process(state, blockEntity, tag, false);
if (blockEntity != null && tag != null) {
tag.putInt("x", targetPos.getX());
tag.putInt("y", targetPos.getY());

View file

@ -469,9 +469,10 @@ public class RollerMovementBehaviour extends BlockBreakingMovementBehaviour {
if (existing.is(toPlace.getBlock()))
return PaveResult.PASS;
if (!existing.is(BlockTags.LEAVES) && !existing.getMaterial()
.isReplaceable()
&& !existing.getCollisionShape(level, targetPos)
.isEmpty())
.isReplaceable()
&& (!existing.getCollisionShape(level, targetPos)
.isEmpty()
|| existing.is(BlockTags.PORTALS)))
return PaveResult.FAIL;
FilterItemStack filter = context.getFilterFromBE();

View file

@ -0,0 +1,71 @@
package com.simibubi.create.content.contraptions.actors.seat;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity.ContraptionRotationState;
import com.simibubi.create.content.trains.entity.CarriageContraptionEntity;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.infrastructure.config.AllConfigs;
import net.minecraft.client.Minecraft;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
public class ContraptionPlayerPassengerRotation {
static boolean active;
static int prevId;
static float prevYaw;
static float prevPitch;
public static void tick() {
active = AllConfigs.client().rotateWhenSeated.get();
}
public static void frame() {
Player player = Minecraft.getInstance().player;
if (!active)
return;
if (player == null || !player.isPassenger()) {
prevId = 0;
return;
}
Entity vehicle = player.getVehicle();
if (!(vehicle instanceof AbstractContraptionEntity contraptionEntity))
return;
ContraptionRotationState rotationState = contraptionEntity.getRotationState();
float yaw = AngleHelper.wrapAngle180((contraptionEntity instanceof CarriageContraptionEntity cce)
? cce.getViewYRot(AnimationTickHolder.getPartialTicks())
: rotationState.yRotation);
float pitch = (contraptionEntity instanceof CarriageContraptionEntity cce)
? cce.getViewXRot(AnimationTickHolder.getPartialTicks())
: 0;
if (prevId != contraptionEntity.getId()) {
prevId = contraptionEntity.getId();
prevYaw = yaw;
prevPitch = pitch;
}
float yawDiff = AngleHelper.getShortestAngleDiff(yaw, prevYaw);
float pitchDiff = AngleHelper.getShortestAngleDiff(pitch, prevPitch);
prevYaw = yaw;
prevPitch = pitch;
float yawRelativeToTrain = Mth.abs(AngleHelper.getShortestAngleDiff(player.getYRot(), -yaw - 90));
if (yawRelativeToTrain > 120)
pitchDiff *= -1;
else if (yawRelativeToTrain > 60)
pitchDiff *= 0;
player.setYRot((float) (player.getYRot() + yawDiff));
player.setXRot((float) (player.getXRot() + pitchDiff));
}
}

View file

@ -234,7 +234,7 @@ public abstract class ZapperItem extends Item implements CustomArmPoseItem {
if (data != null && AllBlockTags.SAFE_NBT.matches(state)) {
BlockEntity blockEntity = world.getBlockEntity(pos);
if (blockEntity != null) {
data = NBTProcessors.process(blockEntity, data, !player.isCreative());
data = NBTProcessors.process(state, blockEntity, data, !player.isCreative());
if (data == null)
return;
data.putInt("x", pos.getX());

View file

@ -224,7 +224,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
// airCurrent.findEntities();
if (bottomPullDistance <= 0 && !getItem().isEmpty() || itemSpeed <= 0 || level == null || level.isClientSide)
return;
if (!canCollectItemsFromBelow())
if (!canActivate())
return;
Vec3 center = VecHelper.getCenterOf(worldPosition);
AABB searchArea = new AABB(center.add(0, -bottomPullDistance - 0.5, 0), center.add(0, -0.5, 0)).inflate(.45f);
@ -305,7 +305,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
if (!up && BlockHelper.noCollisionInSpace(level, worldPosition.below()))
spawnAirFlow(0, -1, absMotion, .5f);
if (up && canCollectItemsFromBelow() && bottomPullDistance > 0) {
if (up && canActivate() && bottomPullDistance > 0) {
spawnAirFlow(-bottomPullDistance, 0, absMotion, 2);
spawnAirFlow(-bottomPullDistance, 0, absMotion, 2);
}
@ -340,6 +340,8 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
private void handleInput(IItemHandler inv, float startLocation) {
if (inv == null)
return;
if (!canActivate())
return;
if (invVersionTracker.stillWaiting(inv))
return;
Predicate<ItemStack> canAccept = this::canAcceptItem;
@ -361,7 +363,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
ChuteBlockEntity targetChute = getTargetChute(blockState);
Direction direction = AbstractChuteBlock.getChuteFacing(blockState);
if (level == null || direction == null || !this.canOutputItems())
if (level == null || direction == null || !this.canActivate())
return false;
if (!capBelow.isPresent())
capBelow = grabCapability(Direction.DOWN);
@ -417,7 +419,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
private boolean handleUpwardOutput(boolean simulate) {
BlockState stateAbove = level.getBlockState(worldPosition.above());
if (level == null || !this.canOutputItems())
if (level == null || !this.canActivate())
return false;
if (AbstractChuteBlock.isOpenChute(getBlockState())) {
@ -492,11 +494,7 @@ public class ChuteBlockEntity extends SmartBlockEntity implements IHaveGoggleInf
return ExtractionCountMode.UPTO;
}
protected boolean canCollectItemsFromBelow() {
return true;
}
protected boolean canOutputItems() {
protected boolean canActivate() {
return true;
}

View file

@ -22,7 +22,7 @@ public class SmartChuteBlockEntity extends ChuteBlockEntity {
@Override
protected boolean canAcceptItem(ItemStack stack) {
return super.canAcceptItem(stack) && canCollectItemsFromBelow() && filtering.test(stack);
return super.canAcceptItem(stack) && canActivate() && filtering.test(stack);
}
@Override
@ -37,17 +37,11 @@ public class SmartChuteBlockEntity extends ChuteBlockEntity {
}
@Override
protected boolean canCollectItemsFromBelow() {
protected boolean canActivate() {
BlockState blockState = getBlockState();
return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED);
}
@Override
protected boolean canOutputItems() {
BlockState blockState = getBlockState();
return blockState.hasProperty(SmartChuteBlock.POWERED) && !blockState.getValue(SmartChuteBlock.POWERED);
}
@Override
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
behaviours.add(filtering =

View file

@ -57,7 +57,7 @@ public class DisplayLinkBlock extends WrenchableDirectionalBlock implements IBE<
placed = placed.setValue(FACING, context.getClickedFace());
return placed.setValue(POWERED, shouldBePowered(placed, context.getLevel(), context.getClickedPos()));
}
@Override
public void setPlacedBy(Level pLevel, BlockPos pPos, BlockState pState, LivingEntity pPlacer, ItemStack pStack) {
super.setPlacedBy(pLevel, pPos, pState, pPlacer, pStack);
@ -65,7 +65,7 @@ public class DisplayLinkBlock extends WrenchableDirectionalBlock implements IBE<
}
public static void notifyGatherers(LevelAccessor level, BlockPos pos) {
forEachAttachedGatherer(level, pos, DisplayLinkBlockEntity::updateGatheredData);
forEachAttachedGatherer(level, pos, DisplayLinkBlockEntity::tickSource);
}
@SuppressWarnings("unchecked")

View file

@ -35,7 +35,7 @@ public class SchematicProcessor extends StructureProcessor {
if (info.nbt != null && info.state.hasBlockEntity()) {
BlockEntity be = ((EntityBlock) info.state.getBlock()).newBlockEntity(info.pos, info.state);
if (be != null) {
CompoundTag nbt = NBTProcessors.process(be, info.nbt, false);
CompoundTag nbt = NBTProcessors.process(info.state, be, info.nbt, false);
if (nbt != info.nbt)
return new StructureTemplate.StructureBlockInfo(info.pos, info.state, nbt);
}

View file

@ -163,6 +163,8 @@ public class SchematicHandler {
try {
schematic.placeInWorld(w, pos, pos, placementSettings, w.getRandom(), Block.UPDATE_CLIENTS);
for (BlockEntity blockEntity : w.getBlockEntities())
blockEntity.setLevel(w);
} catch (Exception e) {
Minecraft.getInstance().player.displayClientMessage(Lang.translate("schematic.error")
.component(), false);

View file

@ -6,6 +6,7 @@ import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.simibubi.create.compat.framedblocks.FramedBlocksInSchematics;
import com.simibubi.create.foundation.data.recipe.Mods;
import com.simibubi.create.foundation.utility.NBTProcessors;
@ -70,7 +71,10 @@ public class ItemRequirement {
if (be instanceof ISpecialBlockEntityItemRequirement specialBE)
requirement = requirement.union(specialBE.getRequiredItems(state));
if (com.simibubi.create.compat.Mods.FRAMEDBLOCKS.contains(block))
requirement = requirement.union(FramedBlocksInSchematics.getRequiredItems(state, be));
return requirement;
}

View file

@ -1,10 +1,8 @@
package com.simibubi.create.foundation.data.recipe;
import java.util.function.Consumer;
import java.util.function.Supplier;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.ItemLike;
public enum Mods {

View file

@ -7,6 +7,7 @@ import com.simibubi.create.AllPackets;
import com.simibubi.create.Create;
import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.ContraptionHandler;
import com.simibubi.create.content.contraptions.actors.seat.ContraptionPlayerPassengerRotation;
import com.simibubi.create.content.contraptions.actors.trainControls.ControlsHandler;
import com.simibubi.create.content.contraptions.chassis.ChassisRangeDisplay;
import com.simibubi.create.content.contraptions.minecart.CouplingHandlerClient;
@ -166,6 +167,7 @@ public class ClientEvents {
CreateClient.VALUE_SETTINGS_HANDLER.tick();
ScrollValueHandler.tick();
NetheriteBacktankFirstPersonRenderer.clientTick();
ContraptionPlayerPassengerRotation.tick();
}
@SubscribeEvent
@ -218,6 +220,8 @@ public class ClientEvents {
buffer.draw();
RenderSystem.enableCull();
ms.popPose();
ContraptionPlayerPassengerRotation.frame();
}
@SubscribeEvent

View file

@ -6,6 +6,8 @@ import javax.annotation.Nullable;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllTags.AllBlockTags;
import com.simibubi.create.compat.Mods;
import com.simibubi.create.compat.framedblocks.FramedBlocksInSchematics;
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock;
import com.simibubi.create.content.processing.burner.BlazeBurnerBlock.HeatLevel;
@ -243,15 +245,18 @@ public class BlockHelper {
CompoundTag data = null;
if (blockEntity == null)
return data;
if (AllBlockTags.SAFE_NBT.matches(blockState)) {
data = blockEntity.saveWithFullMetadata();
data = NBTProcessors.process(blockEntity, data, true);
} else if (blockEntity instanceof IPartialSafeNBT) {
data = new CompoundTag();
((IPartialSafeNBT) blockEntity).writeSafe(data);
data = NBTProcessors.process(blockEntity, data, true);
}
return data;
} else if (Mods.FRAMEDBLOCKS.contains(blockState.getBlock()))
data = FramedBlocksInSchematics.prepareBlockEntityData(blockState, blockEntity);
return NBTProcessors.process(blockState, blockEntity, data, true);
}
public static void placeSchematicBlock(Level world, BlockState state, BlockPos target, ItemStack stack,

View file

@ -13,11 +13,13 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.item.EnchantedBookItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
public final class NBTProcessors {
@ -34,13 +36,6 @@ public final class NBTProcessors {
}
static {
addProcessor(BlockEntityType.SIGN, data -> {
for (int i = 0; i < 4; ++i) {
if (textComponentHasClickEvent(data.getString("Text" + (i + 1))))
return null;
}
return data;
});
addProcessor(BlockEntityType.LECTERN, data -> {
if (!data.contains("Book", Tag.TAG_COMPOUND))
return data;
@ -63,6 +58,14 @@ public final class NBTProcessors {
addProcessor(AllBlockEntityTypes.CREATIVE_CRATE.get(), itemProcessor("Filter"));
addProcessor(AllBlockEntityTypes.PLACARD.get(), itemProcessor("Item"));
}
// Triggered by block tag, not BE type
private static final UnaryOperator<CompoundTag> signProcessor = data -> {
for (int i = 0; i < 4; ++i)
if (textComponentHasClickEvent(data.getString("Text" + (i + 1))))
return null;
return data;
};
public static UnaryOperator<CompoundTag> itemProcessor(String tagKey) {
return data -> {
@ -117,7 +120,7 @@ public final class NBTProcessors {
private NBTProcessors() {}
@Nullable
public static CompoundTag process(BlockEntity blockEntity, CompoundTag compound, boolean survival) {
public static CompoundTag process(BlockState blockState, BlockEntity blockEntity, CompoundTag compound, boolean survival) {
if (compound == null)
return null;
BlockEntityType<?> type = blockEntity.getType();
@ -129,6 +132,8 @@ public final class NBTProcessors {
.apply(compound);
if (blockEntity instanceof SpawnerBlockEntity)
return compound;
if (blockState.is(BlockTags.SIGNS))
return signProcessor.apply(compound);
if (blockEntity.onlyOpCanSetNbt())
return null;
return compound;

View file

@ -33,6 +33,8 @@ public class CClient extends ConfigBase {
Comments.ingameMenuConfigButtonOffsetX);
public final ConfigBool ignoreFabulousWarning = b(false, "ignoreFabulousWarning",
Comments.ignoreFabulousWarning);
public final ConfigBool rotateWhenSeated = b(true, "rotateWhenSeated",
Comments.rotatewhenSeated);
// custom fluid fog
public final ConfigGroup fluidFogSettings = group(1, "fluidFogSettings", Comments.fluidFogSettings);
@ -125,6 +127,7 @@ public class CClient extends ConfigBase {
"The sign (-/+) of this value determines what side of the row the button appears on (left/right)"
};
static String ignoreFabulousWarning = "Setting this to true will prevent Create from sending you a warning when playing with Fabulous graphics enabled";
static String rotatewhenSeated = "Disable to prevent being rotated while seated on a Moving Contraption";
static String overlay = "Settings for the Goggle Overlay";
static String overlayOffset = "Offset the overlay from goggle- and hover- information by this many pixels on the respective axis; Use /create overlay";
static String overlayCustomColor = "Enable this to use your custom colors for the Goggle- and Hover- Overlay";