Skip to content

Commit

Permalink
miscellaniest
Browse files Browse the repository at this point in the history
  • Loading branch information
TropheusJ committed Jul 16, 2023
1 parent 45667e2 commit cb249bd
Show file tree
Hide file tree
Showing 75 changed files with 232 additions and 175 deletions.
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ archivesBaseName = "create-fabric"
repositories {
maven { url = "https://maven.quiltmc.org/repository/release" } // QM
maven { url = "https://maven.parchmentmc.org" } // Parchment

maven { url = "https://maven.ladysnake.org/releases" } // CCA, for Trinkets
maven { url = "https://maven.fabricmc.net/" } // FAPI, Loader
maven { url = "https://mvn.devos.one/snapshots/" } // Registrate, Porting Lib, Forge Tags, Milk Lib
maven { url = "https://jitpack.io/" } // for Porting Lib: Mixin Extras, Fabric ASM
Expand Down Expand Up @@ -105,8 +105,10 @@ def compat(DependencyHandler deps) {
deps.modCompileOnly("maven.modrinth:sandwichable:$sandwichable_version")
deps.modCompileOnly("maven.modrinth:sodium:$sodium_version")

deps.modCompileOnly("dev.emi:trinkets:$trinkets_version") { transitive = false }
deps.modCompileOnly("maven.modrinth:cardinal-components-api:$cca_version") // for trinkets
deps.modCompileOnly("dev.emi:trinkets:$trinkets_version")
// for Trinkets
deps.modCompileOnly("dev.onyxstudios.cardinal-components-api:cardinal-components-base:$cca_version")
deps.modCompileOnly("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:$cca_version")

recipeViewers(deps)
}
Expand Down Expand Up @@ -213,7 +215,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = Integer.parseInt(sourceCompatibility)
it.options.release.set(17)
}

java {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ reach_entity_attributes_version = 2.4.0
registrate_version = 1.3.59-MC1.20
milk_lib_version = 1.2.60

port_lib_version = 2.1.1051+1.20
port_lib_version = 2.1.1053+1.20
# adding a module also requires adding a dependency to the FMJ
port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer,models,tool_actions
port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer,models,tool_actions,client_events

night_config_version = 3.6.3
jsr305_version = 3.0.2
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/com/simibubi/create/CreateClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,20 @@ private static void initCompat() {
}

private static void registerOverlays() {
OverlayRenderCallback.EVENT.register(((stack, partialTicks, window, type) -> {
OverlayRenderCallback.EVENT.register(((graphics, partialTicks, window, type) -> {
if (type == OverlayRenderCallback.Types.AIR) {
RemainingAirOverlay.render(stack, window.getGuiScaledWidth(), window.getGuiScaledHeight()); // Create's Remaining Air
RemainingAirOverlay.render(graphics, window.getGuiScaledWidth(), window.getGuiScaledHeight()); // Create's Remaining Air
} else {
TrainHUD.renderOverlay(stack, partialTicks, window); // Create's Train Driver HUD
GoggleOverlayRenderer.renderOverlay(stack, partialTicks, window); // Create's Goggle Information
BlueprintOverlayRenderer.renderOverlay(stack, partialTicks, window); // Create's Blueprints
LinkedControllerClientHandler.renderOverlay(stack, partialTicks, window); // Create's Linked Controller
SCHEMATIC_HANDLER.renderOverlay(stack, partialTicks, window); // Create's Schematics
ToolboxHandlerClient.renderOverlay(stack, partialTicks, window); // Create's Toolboxes
VALUE_SETTINGS_HANDLER.render(stack, window.getGuiScaledWidth(), window.getGuiScaledHeight()); // Create's Value Settings
TrackPlacementOverlay.renderOverlay(Minecraft.getInstance().gui, stack); // Create's Track Placement

PlacementHelpers.afterRenderOverlayLayer(stack, partialTicks, window, type);
TrainHUD.renderOverlay(graphics, partialTicks, window); // Create's Train Driver HUD
GoggleOverlayRenderer.renderOverlay(graphics, partialTicks, window); // Create's Goggle Information
BlueprintOverlayRenderer.renderOverlay(graphics, partialTicks, window); // Create's Blueprints
LinkedControllerClientHandler.renderOverlay(graphics, partialTicks, window); // Create's Linked Controller
SCHEMATIC_HANDLER.renderOverlay(graphics, partialTicks, window); // Create's Schematics
ToolboxHandlerClient.renderOverlay(graphics, partialTicks, window); // Create's Toolboxes
VALUE_SETTINGS_HANDLER.render(graphics, window.getGuiScaledWidth(), window.getGuiScaledHeight()); // Create's Value Settings
TrackPlacementOverlay.renderOverlay(Minecraft.getInstance().gui, graphics); // Create's Track Placement

PlacementHelpers.afterRenderOverlayLayer(graphics, partialTicks, window, type);
}
return false;
}));
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/simibubi/create/compat/Mods.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ private static boolean savePlayerFromClipping(Player entity, AbstractContraption
AABB bb = entity.getBoundingBox()
.deflate(1 / 4f, 0, 1 / 4f);
double shortestDistance = Double.MAX_VALUE;
double yStart = entity.getStepHeight() + contraptionEntity.getY() + yStartOffset;
double yStart = entity.maxUpStep() + contraptionEntity.getY() + yStartOffset;
double rayLength = Math.max(5, Math.abs(entity.getY() - yStart));

for (int rayIndex = 0; rayIndex < 4; rayIndex++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.simibubi.create.infrastructure.config.AllConfigs;

import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public int getContainerSize() {

@Override
public boolean isEmpty() {
boolean primaryEmpty = Iterators.size(primary.nonEmptyViews()) == 0;
boolean secondaryEmpty = secondary == null || Iterators.size(secondary.nonEmptyViews()) == 0;
boolean primaryEmpty = Iterators.size(primary.nonEmptyIterator()) == 0;
boolean secondaryEmpty = secondary == null || Iterators.size(secondary.nonEmptyIterator()) == 0;
return primaryEmpty && secondaryEmpty;
}

Expand Down Expand Up @@ -134,13 +134,6 @@ public void setItem(int slot, ItemStack stack) {

@Override
public void setChanged() {
// invoke onFinalCommit
try (Transaction t = TransferUtil.getTransaction()) {
primary.updateSnapshots(t);
if (secondary != null)
secondary.updateSnapshots(t);
t.commit();
}
}

@Override
Expand All @@ -152,7 +145,7 @@ public boolean stillValid(Player player) {
public boolean canPlaceItem(int slot, ItemStack stack) {
ItemStackHandler handler = handlerForSlot(slot);
slot = actualSlot(slot);
return handler.isItemValid(slot, ItemVariant.of(stack), stack.getCount());
return handler.isItemValid(slot, ItemVariant.of(stack));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -412,7 +414,7 @@ protected BlockState getStateToPaveWithAsSlab(MovementContext context) {
possibleSlabLocations.add(blockName.substring(0, nameLength - 7) + "_slab");

for (String locationAttempt : possibleSlabLocations) {
ResourceKey<Block> key = ResourceKey.create(BuiltInRegistries.BLOCK_REGISTRY, new ResourceLocation(namespace, locationAttempt));
ResourceKey<Block> key = ResourceKey.create(Registries.BLOCK, new ResourceLocation(namespace, locationAttempt));
Optional<Block> result = BuiltInRegistries.BLOCK.getHolder(key)
.map(slabHolder -> slabHolder.value());
if (result.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected void renderWindow(GuiGraphics graphics, int mouseX, int mouseY, float

FormattedCharSequence formattedcharsequence = title.getVisualOrderText();
graphics.drawString(font, formattedcharsequence,
(float) (x + (background.width - 8) / 2 - font.width(formattedcharsequence) / 2), (float) y + 6, 0x2F3738, false);
x + (background.width - 8) / 2 - font.width(formattedcharsequence) / 2, y + 6, 0x2F3738, false);

GuiGameElement.of(AllBlocks.ELEVATOR_CONTACT.asStack()).<GuiGameElement
.GuiRenderBuilder>at(x + background.width + 6, y + background.height - 56, -200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@

public class CouplingHandler {

public static InteractionResult preventEntitiesFromMoutingOccupiedCart(Entity e, Entity mounting, boolean isMounting) {
if (e instanceof AbstractMinecart cart) {
public static boolean preventEntitiesFromMoutingOccupiedCart(Entity vehicle, Entity passenger) {
if (vehicle instanceof AbstractMinecart cart) {
LazyOptional<MinecartController> optional = cart.lazyController();
if (!optional.isPresent())
return InteractionResult.PASS;
if (mounting instanceof AbstractContraptionEntity)
return InteractionResult.PASS;
return true;
if (passenger instanceof AbstractContraptionEntity)
return true;
MinecartController controller = optional.orElse(null);
if (controller.isCoupledThroughContraption()) {
return InteractionResult.FAIL;
return false;
}
}
return InteractionResult.PASS;
return true;
}

public static void forEachLoadedCoupling(Level world, Consumer<Couple<MinecartController>> consumer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static void setupModelViewPartial(Matrix4f matrix, Matrix4f modelMatrix,
float x = (float) (Mth.lerp(pt, entity.xOld, entity.getX()) - camX);
float y = (float) (Mth.lerp(pt, entity.yOld, entity.getY()) - camY);
float z = (float) (Mth.lerp(pt, entity.zOld, entity.getZ()) - camZ);
Matrix4fHelper.setTranslation(matrix, x, y, z);
matrix.setTranslation(x, y, z);
matrix.mul(modelMatrix);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.Iterate;

import io.github.fabricators_of_create.porting_lib.model.CustomParticleIconModel;
import io.github.fabricators_of_create.porting_lib.models.CustomParticleIconModel;
import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

public class AllPaletteBlocks {

static { REGISTRATE.useCreativeTab(AllCreativeModeTabs.BUILDING_BLOCKS_TAB); }
static { REGISTRATE.useCreativeTab(AllCreativeModeTabs.BUILDING_BLOCKS_TAB.key()); }

// Windows and Glass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.tterrag.registrate.util.nullness.NonNullSupplier;

import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.util.Mth;
import net.minecraft.world.level.block.DoorBlock;
import net.minecraft.world.level.block.state.BlockState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.world.inventory.CraftingContainer;
Expand Down Expand Up @@ -322,13 +323,11 @@ private static ItemStack[] getItemsMatchingFilter(ItemStack filter) {
if (whitelistMode == WhitelistMode.WHITELIST_DISJ && attributes.size() == 1) {
ItemAttribute fromNBT = ItemAttribute.fromNBT((CompoundTag) attributes.get(0));
if (fromNBT instanceof ItemAttribute.InTag inTag) {
if (BuiltInRegistries.ITEM.isKnownTagName(inTag.tag)) {
List<ItemStack> stacks = new ArrayList<>();
for (Holder<Item> holder : BuiltInRegistries.ITEM.getTagOrEmpty(inTag.tag)) {
stacks.add(new ItemStack(holder.value()));
}
return stacks.toArray(ItemStack[]::new);
List<ItemStack> stacks = new ArrayList<>();
for (Holder<Item> holder : BuiltInRegistries.ITEM.getTagOrEmpty(inTag.tag)) {
stacks.add(new ItemStack(holder.value()));
}
return stacks.toArray(ItemStack[]::new);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ private void renderCursor(GuiGraphics graphics, Pos2i pCursorPos, boolean pIsEnd
if (!pIsEndOfText) {
graphics.fill(pCursorPos.x, pCursorPos.y - 1, pCursorPos.x + 1, pCursorPos.y + 9, -16777216);
} else {
graphics.drawString(font, "_", (float) pCursorPos.x, (float) pCursorPos.y, 0, false);
graphics.drawString(font, "_", pCursorPos.x, pCursorPos.y, 0, false);
}
}

Expand Down Expand Up @@ -574,7 +574,7 @@ public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) {
return true;
if (pButton != 0)
return true;

if (hoveredEntry != -1) {
if (hoveredCheck) {
editingIndex = -1;
Expand Down Expand Up @@ -607,7 +607,7 @@ public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) {
editingIndex = -1;
return false;
}

long i = Util.getMillis();
DisplayCache cache = getDisplayCache();
int j = cache.getIndexAtPosition(font, convertScreenToLocal(new Pos2i((int) pMouseX, (int) pMouseY)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.infrastructure.config.AllConfigs;

import io.github.fabricators_of_create.porting_lib.entity.events.living.LivingEntityDamageEvents.HurtEvent;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -213,17 +214,16 @@ private static int maxUses() {
return AllConfigs.server().equipment.maxExtendoGripActions.get();
}

public static float bufferLivingAttackEvent(DamageSource source, LivingEntity damaged, float amount) {
public static void bufferLivingAttackEvent(HurtEvent event) {
// Workaround for removed patch to get the attacking entity.
lastActiveDamageSource = source;
lastActiveDamageSource = event.damageSource;

Entity trueSource = source.getEntity();
Entity trueSource = event.damageSource.getEntity();
if (trueSource instanceof Player)
findAndDamageExtendoGrip((Player) trueSource);
return amount;
}

public static double attacksByExtendoGripHaveMoreKnockback(double strength, Player player) {
public static double attacksByExtendoGripHaveMoreKnockback(LivingEntity attacked, double strength) {
if (lastActiveDamageSource == null)
return strength;
Entity entity = lastActiveDamageSource.getDirectEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.simibubi.create.content.contraptions.piston.PistonExtensionPoleBlock;
import com.simibubi.create.content.trains.entity.TrainRelocator;
import com.simibubi.create.foundation.blockEntity.behaviour.ValueBox;
import com.simibubi.create.foundation.gui.RemovedGuiUtils;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.element.GuiGameElement;
import com.simibubi.create.foundation.outliner.Outline;
Expand Down Expand Up @@ -198,7 +199,7 @@ public static void renderOverlay(GuiGraphics graphics, float partialTicks, Windo
colorBorderBot.scaleAlpha(fade);
}

ScreenUtils.drawHoveringText(graphics, tooltip, posX, posY, mc.getWindow().getGuiScaledWidth(), mc.getWindow().getGuiScaledHeight(), -1, colorBackground.getRGB(),
RemovedGuiUtils.drawHoveringText(graphics, tooltip, posX, posY, mc.getWindow().getGuiScaledWidth(), mc.getWindow().getGuiScaledHeight(), -1, colorBackground.getRGB(),
colorBorderTop.getRGB(), colorBorderBot.getRGB(), mc.font);

ItemStack item = AllItems.GOGGLES.asStack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.Random;

import com.jozufozu.flywheel.fabric.model.DefaultLayerFilteringBakedModel;

import org.joml.Vector3f;

import com.mojang.blaze3d.vertex.PoseStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllRecipeTypes;
import io.github.fabricators_of_create.porting_lib.util.TagUtil;
import me.alphamode.forgetags.Tags;

import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public FluidStackParticle(ClientLevel world, FluidStack fluid, double x, double
this.rCol = 0.8F;
this.gCol = 0.8F;
this.bCol = 0.8F;
int color = handler.getColor(fluid.getType(), world, new BlockPos(x, y, z));
int color = handler.getColor(fluid.getType(), world, BlockPos.containing(x, y, z));
multiplyColor(color);

this.xd = vx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import me.shedaniel.rei.plugin.common.displays.brewing.BrewingRecipe;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.simibubi.create.foundation.utility.AttachedRegistry;

import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.simibubi.create.content.kinetics.belt.BeltBlockEntity.RenderData;
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;

import io.github.fabricators_of_create.porting_lib.model.CustomParticleIconModel;
import io.github.fabricators_of_create.porting_lib.models.CustomParticleIconModel;
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel;
import net.fabricmc.fabric.api.renderer.v1.model.SpriteFinder;
Expand Down
Loading

0 comments on commit cb249bd

Please sign in to comment.