Skip to content

Commit

Permalink
Merge branch 'Sollace:1.20.1' into 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
LingVarr authored Mar 28, 2024
2 parents e8a70bc + 7cf32cc commit 9eeeea0
Show file tree
Hide file tree
Showing 40 changed files with 538 additions and 198 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 17
- name: Prepare Datagen
uses: eskatos/gradle-command-action@v1
with:
arguments: rundatagen
- name: Publish Modrinth Jar
env:
MODRINTH_KEY: ${{ secrets.MODRINTH_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion BlockusAddon
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}
plugins {
id 'java-library'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'com.modrinth.minotaur' version '2.+'
id 'org.ajoberstar.reckon' version '0.13.0'
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;

public class InteractionManager {
Expand Down Expand Up @@ -90,4 +92,8 @@ public PlayerEntity createPlayer(World world, GameProfile profile) {
public void sendPlayerLookAngles(PlayerEntity player) {

}

public void addBlockBreakingParticles(BlockPos pos, Direction direction) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.World;
Expand Down Expand Up @@ -89,8 +90,10 @@ public Optional<Pos> prepare(Pony player) {
return trace.getBlockOrEntityPos().map(pos -> {
final BlockPos originalPos = pos;

Direction globalUp = player.getPhysics().isGravityNegative() ? Direction.DOWN : Direction.UP;

boolean originalPosHasSupport = exception(w, pos, player.asEntity());
boolean originalPosValid = enterable(w, pos.up()) && enterable(w, pos.up(2));
boolean originalPosValid = enterable(w, pos.offset(globalUp)) && enterable(w, pos.offset(globalUp, 2));

if (w.getBlockState(pos).isOf(Blocks.POWDER_SNOW) && !PowderSnowBlock.canWalkOnPowderSnow(player.asEntity())) {
return null;
Expand All @@ -111,11 +114,11 @@ public Optional<Pos> prepare(Pony player) {
if (pos.getX() != originalPos.getX() || pos.getZ() != originalPos.getZ()) {
// check support
int steps = 0;
while (enterable(w, pos.down())) {
pos = pos.down();
while (enterable(w, pos.offset(globalUp.getOpposite()))) {
pos = pos.offset(globalUp.getOpposite());
if (++steps > 2) {
if (originalPosValid) {
pos = originalPos.up();
pos = originalPos.offset(globalUp);
break;
} else {
return null;
Expand All @@ -125,7 +128,7 @@ public Optional<Pos> prepare(Pony player) {
}

if ((!enterable(w, pos) && exception(w, pos, player.asEntity()))
|| (!enterable(w, pos.up()) && exception(w, pos.up(), player.asEntity()))) {
|| (!enterable(w, pos.offset(globalUp)) && exception(w, pos.offset(globalUp), player.asEntity()))) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ static void bootstrap() {
FlammableBlockRegistry.getDefaultInstance().add(BANANAS, 5, 20);
FlammableBlockRegistry.getDefaultInstance().add(CURING_JOKE, 60, 100);

CompostingChanceRegistry.INSTANCE.add(WORM_BLOCK, 8F);
CompostingChanceRegistry.INSTANCE.add(WORM_BLOCK, 1F);

UBlockEntities.bootstrap();
EdibleBlock.bootstrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;

Expand Down Expand Up @@ -161,4 +163,9 @@ public void sendPlayerLookAngles(PlayerEntity player) {
c.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(player.getYaw(), player.getPitch(), player.isOnGround()));
}
}

@Override
public void addBlockBreakingParticles(BlockPos pos, Direction direction) {
client.particleManager.addBlockBreakingParticles(pos, direction);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,43 +175,39 @@ private boolean onLivingRender(Living<?> pony,

boolean negative = pony.getPhysics().isGravityNegative();

float roll = negative ? 180 : 0;

roll = pony instanceof Pony ? ((Pony)pony).getInterpolator().interpolate("g_roll", roll, 15) : roll;

matrices.translate(x, y + owner.getHeight() / 2, z);

matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(roll));
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(roll));

if (pony instanceof Pony p) {
roll = p.getCamera().calculateRoll();
if (negative) {
roll -= 180;
}
float sidewaysRoll = p.getCamera().calculateRoll();

if (p.getAcrobatics().isFloppy()) {
matrices.translate(0, -0.5, 0);
p.asEntity().setBodyYaw(0);
p.asEntity().setYaw(0);
matrices.multiply(RotationAxis.NEGATIVE_X.rotationDegrees(90));
sidewaysRoll += 90;
}

matrices.multiply(RotationAxis.NEGATIVE_Y.rotationDegrees(yaw));
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(roll));
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(90));
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(sidewaysRoll));
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-90));

float diveAngle = p.getInterpolator().interpolate("g_kdive", p.getMotion().isDiving() ? 80 : 0, 15);
float forwardPitch = p.getInterpolator().interpolate("g_kdive", p.getMotion().isDiving() ? 80 : 0, 15);

matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(diveAngle));
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(yaw));
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(forwardPitch));

if (p.getCompositeRace().includes(Race.SEAPONY)
&& pony.asEntity().isSubmergedInWater()
&& MineLPDelegate.getInstance().getPlayerPonyRace(p.asEntity()) != Race.SEAPONY) {
ModelPartHooks.startCollecting();
}
} else if (pony instanceof Creature creature && smittenEyesRenderer.isSmitten(creature)) {
ModelPartHooks.startCollecting();
} else {
float roll = negative ? 180 : 0;

matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(roll));

if (pony instanceof Creature creature && smittenEyesRenderer.isSmitten(creature)) {
ModelPartHooks.startCollecting();
}
}

matrices.translate(-x, -y - owner.getHeight() / 2, -z);
Expand All @@ -224,7 +220,7 @@ private boolean onLivingRender(Living<?> pony,
}

private void flipAngles(Entity entity) {
if (entity instanceof PlayerEntity) {
if (entity instanceof PlayerEntity player) {
entity.prevYaw *= -1;
entity.setYaw(entity.getYaw() * -1);

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

import java.io.IOException;

import javax.annotation.Nullable;

import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;

import com.google.common.collect.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.minelittlepony.unicopia.command;

import java.util.Arrays;
import java.util.stream.Stream;

import com.google.common.collect.Streams;
import com.minelittlepony.unicopia.entity.player.Pony;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import com.minelittlepony.unicopia.entity.Living;
import com.mojang.brigadier.arguments.FloatArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;

import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
Expand All @@ -22,45 +22,48 @@ static LiteralArgumentBuilder<ServerCommandSource> create() {
return CommandManager.literal("gravity").requires(s -> s.hasPermissionLevel(2))
.then(CommandManager.literal("get")
.executes(context -> get(context.getSource(), context.getSource().getPlayer(), true))
.then(CommandManager.argument("target", EntityArgumentType.player())
.executes(context -> get(context.getSource(), EntityArgumentType.getPlayer(context, "target"), false))
.then(CommandManager.argument("target", EntityArgumentType.entity())
.executes(context -> get(context.getSource(), EntityArgumentType.getEntity(context, "target"), false))
))
.then(CommandManager.literal("set")
.then(CommandManager.argument("gravity", FloatArgumentType.floatArg(-99, 99))
.executes(context -> set(context.getSource(), context.getSource().getPlayer(), FloatArgumentType.getFloat(context, "gravity"), true))
.then(CommandManager.argument("target", EntityArgumentType.player())
.executes(context -> set(context.getSource(), EntityArgumentType.getPlayer(context, "target"), FloatArgumentType.getFloat(context, "gravity"), false))
.executes(context -> set(context.getSource(), List.of(context.getSource().getPlayer()), FloatArgumentType.getFloat(context, "gravity"), true))
.then(CommandManager.argument("target", EntityArgumentType.entities())
.executes(context -> set(context.getSource(), EntityArgumentType.getEntities(context, "target"), FloatArgumentType.getFloat(context, "gravity"), false))
)));
}

static int get(ServerCommandSource source, PlayerEntity player, boolean isSelf) throws CommandSyntaxException {
sendFeedback(source, player, "get", false, Pony.of(player).getPhysics().getGravityModifier());
return 0;
}

static int set(ServerCommandSource source, PlayerEntity player, float gravity, boolean isSelf) {
static int get(ServerCommandSource source, Entity target, boolean isSelf) throws CommandSyntaxException {
Living<?> l = Living.living(target);

Pony iplayer = Pony.of(player);

iplayer.getPhysics().setBaseGravityModifier(gravity);
iplayer.setDirty();

sendFeedback(source, player, "set", true, gravity);
float gravity = l == null ? 1 : l.getPhysics().getGravityModifier();
if (source.getEntity() == target) {
source.sendFeedback(() -> Text.translatable("commands.gravity.get.self", gravity), true);
} else {
source.sendFeedback(() -> Text.translatable("commands.gravity.get.other", target.getDisplayName(), gravity), true);
}
return 0;
}


static void sendFeedback(ServerCommandSource source, PlayerEntity player, String key, boolean notifyTarget, Object...arguments) {
String translationKey = "commands.gravity." + key;

if (source.getEntity() == player) {
source.sendFeedback(() -> Text.translatable(translationKey + ".self", arguments), true);
} else {
if (notifyTarget && source.getWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(Text.translatable(translationKey, arguments));
static int set(ServerCommandSource source, Collection<? extends Entity> targets, float gravity, boolean isSelf) {
List<Entity> affected = targets.stream().map(Living::living).filter(Objects::nonNull).map(l -> {
l.getPhysics().setBaseGravityModifier(gravity);
l.setDirty();
if (l.asEntity() instanceof PlayerEntity player) {
if (source.getEntity() == player) {
player.sendMessage(Text.translatable("commands.gravity.set.self", gravity));
} else if (source.getWorld().getGameRules().getBoolean(GameRules.SEND_COMMAND_FEEDBACK)) {
player.sendMessage(Text.translatable("commands.gravity.set.other", l.asEntity().getDisplayName(), gravity));
}
}
return (Entity)l.asEntity();
}).toList();

source.sendFeedback(() -> Text.translatable(translationKey + ".other", Streams.concat(Stream.of(player.getDisplayName()), Arrays.stream(arguments)).toArray()), true);
if (affected.size() == 1) {
source.sendFeedback(() -> Text.translatable("commands.gravity.set.other", affected.get(0).getDisplayName()), true);
} else {
source.sendFeedback(() -> Text.translatable("commands.gravity.set.multiple", affected.size()), true);
}
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public CompletableFuture<?> run(DataWriter writer) {
public void generateItemModels(ItemModelGenerator itemModelGenerator) {
ItemModels.register(itemModelGenerator,
UItems.ACORN, UItems.APPLE_PIE_HOOF, UItems.APPLE_PIE_SLICE, UItems.APPLE_PIE,
UItems.BANANA, UItems.BOTCHED_GEM, UItems.BROKEN_SUNGLASSES, UItems.BURNED_JUICE, UItems.BURNED_TOAST,
UItems.BANANA, UItems.BOTCHED_GEM, UItems.BOWL_OF_NUTS, UItems.BROKEN_SUNGLASSES, UItems.BURNED_JUICE, UItems.BURNED_TOAST,
UItems.CARAPACE, UItems.CLAM_SHELL, UItems.COOKED_ZAP_APPLE, UItems.CLOUD_LUMP, UItems.CRISPY_HAY_FRIES, UItems.CRYSTAL_HEART, UItems.CRYSTAL_SHARD,
UItems.DAFFODIL_DAISY_SANDWICH, UItems.DRAGON_BREATH_SCROLL,
UItems.EMPTY_JAR,
Expand All @@ -69,8 +69,8 @@ public void generateItemModels(ItemModelGenerator itemModelGenerator) {
UItems.JAM_TOAST, UItems.JUICE,
UItems.LIGHTNING_JAR,
UItems.MANGO, UItems.MUFFIN,
UItems.OATMEAL,
UItems.PEBBLES, UItems.PEGASUS_FEATHER, UItems.PINECONE, UItems.PINEAPPLE_CROWN,
UItems.OATMEAL, UItems.OATMEAL_COOKIE,
UItems.PEBBLES, UItems.PEGASUS_FEATHER, UItems.PINECONE, UItems.PINECONE_COOKIE, UItems.PINEAPPLE_CROWN,
UItems.RAIN_CLOUD_JAR, UItems.ROCK_STEW, UItems.ROCK, UItems.ROTTEN_APPLE,
UItems.SALT_CUBE, UItems.SCALLOP_SHELL, UItems.SHELLY, UItems.SOUR_APPLE_SEEDS, UItems.SOUR_APPLE, UItems.SPELLBOOK, UItems.STORM_CLOUD_JAR,
UItems.SWEET_APPLE_SEEDS, UItems.SWEET_APPLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.block.Blocks;
import net.minecraft.data.server.loottable.BlockLootTableGenerator;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemConvertible;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.condition.LootCondition;
Expand Down Expand Up @@ -54,18 +55,29 @@ public void generate() {
addVanillaDrop(Blocks.PODZOL, block -> wormDrops(block, 4, 0.06F, 0.062222223F, 0.065F, 0.077777776F, 0.2F));
addVanillaDrop(Blocks.DIAMOND_ORE, this::crystalShardDrops);
addVanillaDrop(Blocks.DEEPSLATE_DIAMOND_ORE, this::crystalShardDrops);
addVanillaDrop(Blocks.OAK_LEAVES, block -> chanceDropWithShears(block, UItems.ACORN, GEMSTONES_FORTUNE_CHANCE));
addVanillaDrop(Blocks.SPRUCE_LEAVES, block -> chanceDropWithShears(block, UItems.PINECONE, GEMSTONES_FORTUNE_CHANCE));
}

private void addVanillaDrop(Block block, Function<Block, LootTable.Builder> lootTableFunction) {
lootTables.put(new Identifier("unicopiamc", block.getLootTableId().getPath()), lootTableFunction.apply(block));
}

public LootTable.Builder chanceDropWithShears(Block block, ItemConvertible drop, float...chance) {
return LootTable.builder()
.pool(LootPool.builder()
.rolls(ConstantLootNumberProvider.create(1))
.conditionally(WITHOUT_SILK_TOUCH.and(WITH_SHEARS))
.with(chanceDrops(block, drop, 1, chance))
);
}

public LootTable.Builder wormDrops(Block block, int max, float...chance) {
return LootTable.builder()
.pool(LootPool.builder()
.rolls(ConstantLootNumberProvider.create(1))
.conditionally(WITHOUT_SILK_TOUCH)
.with(wheatwormDrops(block, max, chance))
.with(chanceDrops(block, UItems.WHEAT_WORMS, max, chance))
);
}

Expand All @@ -75,7 +87,7 @@ public LootTable.Builder gemstoneAndWormDrops(Block block, int max, float...chan
.rolls(ConstantLootNumberProvider.create(1))
.conditionally(WITHOUT_SILK_TOUCH)
.with(gemstoneDrops(block, 0.1F))
.with(wheatwormDrops(block, max, chance))
.with(chanceDrops(block, UItems.WHEAT_WORMS, max, chance))
);
}

Expand Down Expand Up @@ -111,16 +123,14 @@ public LootPoolEntry.Builder<?> gemstoneDrops(Block block, float chance) {
.conditionally(TableBonusLootCondition.builder(Enchantments.FORTUNE, GEMSTONES_FORTUNE_CHANCE));
}

public LootPoolEntry.Builder<?> wheatwormDrops(Block block, int max, float...chance) {
return applyExplosionDecay(block, ItemEntry.builder(UItems.WHEAT_WORMS)
public LootPoolEntry.Builder<?> chanceDrops(Block block, ItemConvertible drop, int max, float...chance) {
return applyExplosionDecay(block, ItemEntry.builder(drop)
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, max)))
)
.conditionally(TableBonusLootCondition.builder(Enchantments.FORTUNE, chance));
}


public static LootTable.Builder dropsWithGemfinding(Block drop, LootPoolEntry.Builder<?> child) {
return BlockLootTableGenerator.drops(drop, WITHOUT_SILK_TOUCH_AND_GEM_FINDER, child);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ private void offerFoodRecipes(Consumer<RecipeJsonProvider> exporter) {
.input(UItems.ROCK, 3).criterion(hasItem(UItems.ROCK), conditionsFromItem(UItems.ROCK))
.input(Items.BOWL)
.offerTo(exporter);
ShapelessRecipeJsonBuilder.create(RecipeCategory.FOOD, UItems.BOWL_OF_NUTS)
.input(UItems.ACORN, 3).criterion(hasItem(UItems.ACORN), conditionsFromItem(UItems.ACORN))
.input(Items.BOWL)
.offerTo(exporter);
ShapelessRecipeJsonBuilder.create(RecipeCategory.FOOD, UItems.OATMEAL_COOKIE)
.input(UItems.OATS, 3).criterion(hasItem(UItems.OATS), conditionsFromItem(UItems.OATS))
.offerTo(exporter);
ShapelessRecipeJsonBuilder.create(RecipeCategory.FOOD, UItems.PINECONE_COOKIE)
.input(UItems.PINECONE).criterion(hasItem(UItems.PINECONE), conditionsFromItem(UItems.PINECONE))
.input(Items.WHEAT, 2)
.offerTo(exporter);
ShapelessRecipeJsonBuilder.create(RecipeCategory.FOOD, UItems.ROCK_CANDY, 3)
.input(Items.SUGAR, 6).criterion(hasItem(Items.SUGAR), conditionsFromItem(Items.SUGAR))
.input(UItems.PEBBLES, 3)
Expand Down
Loading

0 comments on commit 9eeeea0

Please sign in to comment.