Skip to content

Commit

Permalink
chore: spotlessApply
Browse files Browse the repository at this point in the history
  • Loading branch information
Rover656 committed Dec 29, 2024
1 parent 6e12e81 commit 4ab02b7
Show file tree
Hide file tree
Showing 28 changed files with 752 additions and 619 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.enderio.base.api.integration;

import com.enderio.base.api.glider.GliderMovementInfo;
import java.util.Optional;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.data.event.GatherDataEvent;

import java.util.Optional;

/**
* These are all the methods a Integration can override or call.
* Please make sure that all methods only reference API of the integrated mod or Minecraft classes, so that this can be part of the API, after stable release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.enderio.core.client.RenderUtil;
import com.enderio.core.data.model.ModelHelper;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.model.BakedQuad;
Expand All @@ -14,17 +15,17 @@
import net.neoforged.neoforge.client.model.data.ModelData;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public record PaintingQuadTransformer(BlockState paint, @Nullable RenderType type) implements IQuadTransformer {

@Override
public void processInPlace(BakedQuad quad) {
TextureAtlasSprite sprite = getSpriteForDirection(quad.getDirection());
for (int i = 0; i < 4; i++) {
float[] uv0 = RenderUtil.unpackVertices(quad.getVertices(), i, IQuadTransformer.UV0, 2);
uv0[0] = (uv0[0] - quad.getSprite().getU0()) * sprite.contents().width() / quad.getSprite().contents().width() + sprite.getU0();
uv0[1] = (uv0[1] - quad.getSprite().getV0()) * sprite.contents().height() / quad.getSprite().contents().height() + sprite.getV0();
uv0[0] = (uv0[0] - quad.getSprite().getU0()) * sprite.contents().width()
/ quad.getSprite().contents().width() + sprite.getU0();
uv0[1] = (uv0[1] - quad.getSprite().getV0()) * sprite.contents().height()
/ quad.getSprite().contents().height() + sprite.getV0();
int[] packedTextureData = RenderUtil.packUV(uv0[0], uv0[1]);
quad.getVertices()[IQuadTransformer.UV0 + i * IQuadTransformer.STRIDE] = packedTextureData[0];
quad.getVertices()[IQuadTransformer.UV0 + 1 + i * IQuadTransformer.STRIDE] = packedTextureData[1];
Expand All @@ -33,8 +34,9 @@ public void processInPlace(BakedQuad quad) {
}

private TextureAtlasSprite getSpriteForDirection(Direction direction) {
List<BakedQuad> quads = getModel(paint).getQuads(paint, direction, RandomSource.create(), ModelData.EMPTY, type);
return quads.isEmpty() ? ModelHelper.getMissingTexture() :quads.get(0).getSprite();
List<BakedQuad> quads = getModel(paint).getQuads(paint, direction, RandomSource.create(), ModelData.EMPTY,
type);
return quads.isEmpty() ? ModelHelper.getMissingTexture() : quads.get(0).getSprite();
}

private BakedModel getModel(BlockState state) {
Expand Down
410 changes: 229 additions & 181 deletions enderio-base/src/main/java/com/enderio/base/common/init/EIOItems.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.enderio.base.common.blockentity.Wrenchable;
import com.enderio.base.common.init.EIOCapabilities;
import com.mojang.datafixers.util.Either;
import java.util.Optional;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionResult;
Expand All @@ -17,8 +18,6 @@
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.block.state.properties.Property;

import java.util.Optional;

public class YetaWrenchItem extends Item {

public YetaWrenchItem(Properties pProperties) {
Expand All @@ -30,7 +29,7 @@ public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext pContext)
Level level = pContext.getLevel();
BlockPos pos = pContext.getClickedPos();

if(!level.isClientSide && level.getBlockEntity(pos) instanceof Wrenchable wrenchable) {
if (!level.isClientSide && level.getBlockEntity(pos) instanceof Wrenchable wrenchable) {
return wrenchable.onWrenched(pContext.getPlayer(), pContext.getClickedFace()).result();
}

Expand All @@ -50,38 +49,38 @@ public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext pContext)
Optional<Either<DirectionProperty, EnumProperty<Direction.Axis>>> property = getRotationProperty(state);
if (property.isPresent()) {
BlockState newState = getNextState(pContext, state, property.get());
pContext.getLevel().setBlock(
pContext.getClickedPos(),
newState,
Block.UPDATE_NEIGHBORS + Block.UPDATE_CLIENTS);
pContext.getLevel()
.setBlock(pContext.getClickedPos(), newState, Block.UPDATE_NEIGHBORS + Block.UPDATE_CLIENTS);
return InteractionResult.SUCCESS;
}
return super.onItemUseFirst(stack,pContext);
return super.onItemUseFirst(stack, pContext);
}

@SuppressWarnings("unchecked")
private static Optional<Either<DirectionProperty, EnumProperty<Direction.Axis>>> getRotationProperty(BlockState state) {
private static Optional<Either<DirectionProperty, EnumProperty<Direction.Axis>>> getRotationProperty(
BlockState state) {
for (Property<?> property : state.getProperties()) {
if (property instanceof DirectionProperty directionProperty
&& directionProperty.getName().equals("facing")) {
&& directionProperty.getName().equals("facing")) {

return Optional.of(Either.left(directionProperty));
}
if (property instanceof EnumProperty enumProperty
&& enumProperty.getName().equals("axis")
&& enumProperty.getValueClass().equals(Direction.Axis.class)) {
if (property instanceof EnumProperty enumProperty && enumProperty.getName().equals("axis")
&& enumProperty.getValueClass().equals(Direction.Axis.class)) {

return Optional.of(Either.right(enumProperty));
}
}
return Optional.empty();
}

private static BlockState getNextState(UseOnContext pContext, BlockState state, Either<DirectionProperty, EnumProperty<Direction.Axis>> property) {
private static BlockState getNextState(UseOnContext pContext, BlockState state,
Either<DirectionProperty, EnumProperty<Direction.Axis>> property) {
return handleProperties(pContext, state, property.left(), property.right());
}

private static BlockState handleProperties(UseOnContext pContext, BlockState state, Optional<DirectionProperty> directionProperty, Optional<EnumProperty<Direction.Axis>> axisProperty) {
private static BlockState handleProperties(UseOnContext pContext, BlockState state,
Optional<DirectionProperty> directionProperty, Optional<EnumProperty<Direction.Axis>> axisProperty) {
if (directionProperty.isPresent()) {
return handleProperty(pContext, state, directionProperty.get());
}
Expand All @@ -93,18 +92,20 @@ private static BlockState handleProperties(UseOnContext pContext, BlockState sta
throw new IllegalArgumentException("At least one Optional should be set");
}

private static <T extends Comparable<T>> BlockState handleProperty(UseOnContext pContext, BlockState state, Property<T> property) {
private static <T extends Comparable<T>> BlockState handleProperty(UseOnContext pContext, BlockState state,
Property<T> property) {
int noValidStateIndex = 0;
do {
state = getNextBlockState(state, property);
noValidStateIndex++;
} while (noValidStateIndex != property.getPossibleValues().size()
&& !state.canSurvive(pContext.getLevel(), pContext.getClickedPos()));
&& !state.canSurvive(pContext.getLevel(), pContext.getClickedPos()));

return state;
}

private static <T extends Comparable<T>> BlockState getNextBlockState(BlockState currentState, Property<T> property) {
private static <T extends Comparable<T>> BlockState getNextBlockState(BlockState currentState,
Property<T> property) {
return currentState.setValue(property, getNextValue(currentState.getValue(property), property));
}

Expand Down
33 changes: 18 additions & 15 deletions enderio-base/src/main/java/com/enderio/base/common/tag/EIOTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.enderio.base.common.block.glass.GlassCollisionPredicate;
import com.enderio.base.common.block.glass.GlassIdentifier;
import com.enderio.base.common.block.glass.GlassLighting;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
Expand All @@ -15,9 +17,6 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.material.Fluid;

import java.util.HashMap;
import java.util.Map;

public class EIOTags {

public static final String COMMON = "c";
Expand All @@ -31,7 +30,8 @@ public static void register() {

public static class Items {

private static void init() {}
private static void init() {
}

// TODO: use these for slot filtering again.
public static final TagKey<Item> ENTITY_STORAGE = tag("entity_storage");
Expand Down Expand Up @@ -89,7 +89,7 @@ private static void init() {}
public static final TagKey<Item> NUGGETS_VIBRANT_ALLOY = commonTag("nuggets/vibrant_alloy");

public static final TagKey<Item> INSULATION_METAL = tag("insulation_metals");

public static final TagKey<Item> SILICON = commonTag("silicon");
public static final TagKey<Item> GEARS = commonTag("gears");
public static final TagKey<Item> GEARS_WOOD = commonTag("gears/wood");
Expand Down Expand Up @@ -124,33 +124,34 @@ private static void init() {}

public static Map<GlassIdentifier, TagKey<Item>> createGlassTags() {
Map<GlassIdentifier, TagKey<Item>> map = new HashMap<>();
for (GlassLighting lighting: GlassLighting.values()) {
for (GlassCollisionPredicate collisionPredicate: GlassCollisionPredicate.values()) {
for (Boolean isFused: new boolean[]{false, true}) {
for (GlassLighting lighting : GlassLighting.values()) {
for (GlassCollisionPredicate collisionPredicate : GlassCollisionPredicate.values()) {
for (Boolean isFused : new boolean[] { false, true }) {
GlassIdentifier identifier = new GlassIdentifier(lighting, collisionPredicate, isFused);
map.put(identifier, tag(identifier.glassName()));
}
}
}
return map;
}

private static TagKey<Item> commonTag(String name) {
return ItemTags.create(ResourceLocation.fromNamespaceAndPath(COMMON, name));
}

private static TagKey<Item> tag(String name) {
return ItemTags.create(EnderIOBase.loc(name));
}
}

public static class Blocks {

private static void init() {}
private static void init() {
}

public static final TagKey<Block> FUSED_QUARTZ = commonTag("glass_blocks/fused_quartz");
public static final TagKey<Block> CLEAR_GLASS = tag("glass_blocks/clear_glass");

public static final TagKey<Block> BLOCKS_CONDUCTIVE_ALLOY = commonTag("storage_blocks/conductive_alloy");
public static final TagKey<Block> BLOCKS_COPPER_ALLOY = commonTag("storage_blocks/copper_alloy");
public static final TagKey<Block> BLOCKS_DARK_STEEL = commonTag("storage_blocks/dark_steel");
Expand All @@ -169,9 +170,10 @@ private static TagKey<Block> tag(String name) {
return BlockTags.create(EnderIOBase.loc(name));
}
}

public static class Fluids {
private static void init() {}
private static void init() {
}

public static final TagKey<Fluid> COLD_FIRE_IGNITER_FUEL = tag("fluid_fuel/cold_fire_igniter");
public static final TagKey<Fluid> STAFF_OF_LEVITY_FUEL = tag("fluid_fuel/staff_of_levity");
Expand All @@ -188,7 +190,8 @@ private static TagKey<Fluid> tag(String name) {
}

public static class EntityTypes {
private static void init() {}
private static void init() {
}

public static TagKey<EntityType<?>> SOUL_VIAL_BLACKLIST = tag("soul_vial_blacklist");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;

public interface FacadeItem {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.enderio.conduits.client;

import com.enderio.EnderIOBase;
import com.enderio.conduits.EnderIOConduits;
import com.enderio.conduits.api.model.RegisterConduitCoreModelModifiersEvent;
import com.enderio.conduits.api.screen.RegisterConduitScreenExtensionsEvent;
import com.enderio.conduits.EnderIOConduits;
import com.enderio.conduits.client.gui.conduit.ConduitScreenExtensions;
import com.enderio.conduits.client.gui.conduit.FluidConduitScreenExtension;
import com.enderio.conduits.client.gui.conduit.ItemConduitScreenExtension;
Expand All @@ -13,6 +13,10 @@
import com.enderio.conduits.client.model.conduit.modifier.ConduitCoreModelModifiers;
import com.enderio.conduits.client.model.conduit.modifier.FluidConduitCoreModelModifier;
import com.enderio.conduits.common.init.ConduitTypes;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.neoforged.api.distmarker.Dist;
Expand All @@ -21,11 +25,6 @@
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.ModelEvent;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@EventBusSubscriber(modid = EnderIOConduits.MODULE_MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
public class ConduitClientSetup {

Expand All @@ -46,10 +45,11 @@ public class ConduitClientSetup {
public static final ModelResourceLocation CONDUIT_FACADE = loc("block/conduit_facade");
public static final ModelResourceLocation CONDUIT_FACADE_HARDENED = loc("block/conduit_facade_hardened");
public static final ModelResourceLocation CONDUIT_FACADE_TRANSLUCENT = loc("block/conduit_facade_translucent");
public static final ModelResourceLocation CONDUIT_FACADE_TRANSLUCENT_HARDENED = loc("block/conduit_facade_translucent_hardened");

public static final ModelResourceLocation CONDUIT_FACADE_TRANSLUCENT_HARDENED = loc(
"block/conduit_facade_translucent_hardened");

private ConduitClientSetup() {}
private ConduitClientSetup() {
}

@SubscribeEvent
public static void clientSetup(FMLClientSetupEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.enderio.base.common.init.EIODataComponents;
import com.enderio.conduits.client.model.conduit.facades.FacadeHelper;
import com.enderio.conduits.common.conduit.block.ConduitBundleBlockEntity;
import java.util.Optional;
import net.minecraft.client.Minecraft;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.item.ItemColor;
Expand All @@ -15,8 +16,6 @@
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;

public class ConduitFacadeColor implements BlockColor, ItemColor {
@Override
public int getColor(BlockState state, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos, int tintIndex) {
Expand All @@ -31,7 +30,9 @@ public int getColor(BlockState state, @Nullable BlockAndTintGetter level, @Nulla
Optional<Block> facade = conduitBundleBlock.getBundle().facade();

if (facade.isPresent() && FacadeHelper.areFacadesVisible()) {
int color = Minecraft.getInstance().getBlockColors().getColor(facade.get().defaultBlockState(), level, pos, tintIndex);
int color = Minecraft.getInstance()
.getBlockColors()
.getColor(facade.get().defaultBlockState(), level, pos, tintIndex);
if (color != -1) {
return color;
}
Expand Down
Loading

0 comments on commit 4ab02b7

Please sign in to comment.