Merge branch 'main' of github.com:paulevsGitch/BCLib

This commit is contained in:
Frank Bauer 2021-07-20 00:44:49 +02:00
commit 65b70f57ad
134 changed files with 3347 additions and 1210 deletions

View file

@ -34,7 +34,15 @@ public abstract class EnchantingTableBlockMixin extends Block {
if (!world.isEmptyBlock(pos.offset(px / 2, 0, pz / 2))) {
break;
}
world.addParticle(ParticleTypes.ENCHANT, pos.getX() + 0.5, pos.getY() + 2.0, pos.getZ() + 0.5, px + random.nextFloat() - 0.5, py - random.nextFloat() - 1.0, pz + random.nextFloat() - 0.5);
world.addParticle(
ParticleTypes.ENCHANT,
pos.getX() + 0.5,
pos.getY() + 2.0,
pos.getZ() + 0.5,
px + random.nextFloat() - 0.5,
py - random.nextFloat() - 1.0,
pz + random.nextFloat() - 0.5
);
}
}
}

View file

@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.bclib.interfaces.IColorProvider;
import ru.bclib.interfaces.CustomColorProvider;
@Mixin(Minecraft.class)
public class MinecraftMixin {
@ -26,8 +26,8 @@ public class MinecraftMixin {
@Inject(method = "<init>*", at = @At("TAIL"))
private void bclib_onMCInit(GameConfig args, CallbackInfo info) {
Registry.BLOCK.forEach(block -> {
if (block instanceof IColorProvider) {
IColorProvider provider = (IColorProvider) block;
if (block instanceof CustomColorProvider) {
CustomColorProvider provider = (CustomColorProvider) block;
blockColors.register(provider.getProvider(), block);
itemColors.register(provider.getItemProvider(), block.asItem());
}

View file

@ -20,8 +20,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.bclib.BCLib;
import ru.bclib.client.models.BlockModelProvider;
import ru.bclib.client.models.ItemModelProvider;
import ru.bclib.interfaces.BlockModelProvider;
import ru.bclib.interfaces.ItemModelProvider;
import java.util.List;
import java.util.Map;
@ -81,13 +81,26 @@ public abstract class ModelBakeryMixin {
Block block = Registry.BLOCK.get(clearLoc);
if (block instanceof BlockModelProvider) {
List<BlockState> possibleStates = block.getStateDefinition().getPossibleStates();
Optional<BlockState> possibleState = possibleStates.stream().filter(state -> modelId.equals(BlockModelShaper.stateToModelLocation(clearLoc, state))).findFirst();
Optional<BlockState> possibleState = possibleStates.stream()
.filter(state -> modelId.equals(
BlockModelShaper.stateToModelLocation(
clearLoc,
state
)))
.findFirst();
if (possibleState.isPresent()) {
UnbakedModel modelVariant = ((BlockModelProvider) block).getModelVariant(modelId, possibleState.get(), unbakedCache);
UnbakedModel modelVariant = ((BlockModelProvider) block).getModelVariant(
modelId,
possibleState.get(),
unbakedCache
);
if (modelVariant != null) {
if (modelVariant instanceof MultiPart) {
possibleStates.forEach(state -> {
ResourceLocation stateId = BlockModelShaper.stateToModelLocation(clearLoc, state);
ResourceLocation stateId = BlockModelShaper.stateToModelLocation(
clearLoc,
state
);
cacheAndQueueDependencies(stateId, modelVariant);
});
}

View file

@ -29,12 +29,18 @@ public class TextureAtlasMixin {
private void bclib_loadSprite(ResourceManager resourceManager, TextureAtlasSprite.Info spriteInfo, int atlasWidth, int atlasHeight, int maxLevel, int posX, int posY, CallbackInfoReturnable<TextureAtlasSprite> info) {
ResourceLocation location = spriteInfo.name();
if (bclib_modifyAtlas && location.getPath().startsWith("block")) {
ResourceLocation emissiveLocation = new ResourceLocation(location.getNamespace(), "textures/" + location.getPath() + "_e.png");
ResourceLocation emissiveLocation = new ResourceLocation(
location.getNamespace(),
"textures/" + location.getPath() + "_e.png"
);
if (resourceManager.hasResource(emissiveLocation)) {
NativeImage sprite = null;
NativeImage emission = null;
try {
ResourceLocation spriteLocation = new ResourceLocation(location.getNamespace(), "textures/" + location.getPath() + ".png");
ResourceLocation spriteLocation = new ResourceLocation(
location.getNamespace(),
"textures/" + location.getPath() + ".png"
);
Resource resource = resourceManager.getResource(spriteLocation);
sprite = NativeImage.read(resource.getInputStream());
resource.close();
@ -65,7 +71,16 @@ public class TextureAtlasMixin {
}
}
TextureAtlas self = (TextureAtlas) (Object) this;
FabricSprite result = new FabricSprite(self, spriteInfo, maxLevel, atlasWidth, atlasHeight, posX, posY, sprite);
FabricSprite result = new FabricSprite(
self,
spriteInfo,
maxLevel,
atlasWidth,
atlasHeight,
posX,
posY,
sprite
);
info.setReturnValue(result);
}
}

View file

@ -99,7 +99,8 @@ public class BoneMealItemMixin {
for (int y = y1; y >= y2; y--) {
bclib_BLOCK_POS.setY(y);
BlockPos down = bclib_BLOCK_POS.below();
if (BlocksHelper.isFluid(world.getBlockState(bclib_BLOCK_POS)) && !BlocksHelper.isFluid(world.getBlockState(down))) {
if (BlocksHelper.isFluid(world.getBlockState(bclib_BLOCK_POS)) && !BlocksHelper.isFluid(world.getBlockState(
down))) {
BlockState grass = bclib_getWaterGrassState(world, down);
if (grass != null) {
BlocksHelper.setWithoutUpdate(world, bclib_BLOCK_POS, grass);

View file

@ -66,7 +66,11 @@ public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
int j;
for (j = -1; j <= 1; ++j) {
for (int k = -1; k <= 1; ++k) {
if ((j != 0 || k != 0) && world.isEmptyBlock(blockPos.offset(k, 0, j)) && world.isEmptyBlock(blockPos.offset(k, 1, j))) {
if ((j != 0 || k != 0) && world.isEmptyBlock(blockPos.offset(
k,
0,
j
)) && world.isEmptyBlock(blockPos.offset(k, 1, j))) {
if (world.getBlockState(blockPos.offset(k * 2, 0, j * 2)).is(TagAPI.BOOKSHELVES)) {
++i;
}
@ -111,7 +115,8 @@ public abstract class EnchantmentMenuMixin extends AbstractContainerMenu {
if (this.costs[j] > 0) {
List<EnchantmentInstance> list = this.getEnchantmentList(itemStack, j, this.costs[j]);
if (list != null && !list.isEmpty()) {
EnchantmentInstance enchantmentLevelEntry = (EnchantmentInstance) list.get(this.random.nextInt(list.size()));
EnchantmentInstance enchantmentLevelEntry = (EnchantmentInstance) list.get(this.random.nextInt(
list.size()));
enchantClue[j] = Registry.ENCHANTMENT.getId(enchantmentLevelEntry.enchantment);
levelClue[j] = enchantmentLevelEntry.level;
}