Skip to content

Commit

Permalink
Merge branch '1.20.1' of https://github.com/LingVarr/Unicopia_RU into…
Browse files Browse the repository at this point in the history
… 1.20.1
  • Loading branch information
LingVarr committed Mar 28, 2024
2 parents 515ac58 + 55cc580 commit 18d8ba4
Show file tree
Hide file tree
Showing 34 changed files with 719 additions and 424 deletions.
2 changes: 1 addition & 1 deletion BlockusAddon
23 changes: 5 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@ archivesBaseName = project.name
loom {
mixin.defaultRefmapName = 'unicopia.mixin.refmap.json'
accessWidenerPath = file('src/main/resources/unicopia.aw')
runs {
datagen {
server()
name "Data Generation"
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.modid=unicopia"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/main/generated")}"
runDir "build/datagen"
}
}

fabricApi {
configureDataGeneration {
modId = 'unicopia'
}
}
//assemble.dependsOn(runDatagen)

reckon {
scopeFromProp()
Expand Down Expand Up @@ -108,14 +103,6 @@ dependencies {
}
}

sourceSets {
main {
resources {
srcDirs += [ "src/main/generated" ]
}
}
}

processResources {
inputs.property "version", project.version.toString()

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/minelittlepony/unicopia/EquineContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ default boolean collidesWithClouds() {
return getCompositeRace().canInteractWithClouds();
}

default boolean hasFeatherTouch() {
return false;
}

static EquineContext of(ShapeContext context) {
if (context == ShapeContext.absent()) {
return Unicopia.SIDE.getPony().map(EquineContext.class::cast).orElse(ABSENT);
}
return context instanceof EquineContext c ? c : ABSENT;
EquineContext result = context instanceof Container c ? c.get() : ABSENT;
return result == null ? ABSENT : result;
}

static EquineContext of(ItemUsageContext context) {
Expand All @@ -42,4 +47,8 @@ static EquineContext of(Entity entity) {
}
return MoreObjects.firstNonNull(Equine.of(entity).orElse(null), ABSENT);
}

interface Container {
EquineContext get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface UConventionalTags {
TagKey<Item> MUSHROOMS = item("mushrooms");
TagKey<Item> MUFFINS = item("muffins");
TagKey<Item> MANGOES = item("mangoes");
TagKey<Item> OEATMEALS = item("oatmeals");
TagKey<Item> OATMEALS = item("oatmeals");

TagKey<Item> FRUITS = item("fruits");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.advancement.UCriteria;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.FriendshipBraceletItem;

Expand Down Expand Up @@ -79,6 +80,7 @@ public boolean apply(Pony player, Hit data) {
Race actualRace = isTransforming ? target.getSpecies() : Race.UNSET;
target.setSpecies(supressed.or(player.getCompositeRace().potential()));
target.setSuppressedRace(actualRace);
UCriteria.SEAPONY_TRANSITION.trigger(target.asEntity());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import com.minelittlepony.unicopia.particle.ParticleSource;
import com.minelittlepony.unicopia.server.world.Ether;
import com.minelittlepony.unicopia.server.world.ModificationType;
import com.minelittlepony.unicopia.server.world.OfflinePlayerCache;
import com.minelittlepony.unicopia.util.SoundEmitter;
import com.minelittlepony.unicopia.util.VecHelper;

import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameRules;
Expand Down Expand Up @@ -67,10 +69,18 @@ default boolean canModifyAt(BlockPos pos, ModificationType mod) {
}

if (getMaster() instanceof PlayerEntity player) {
if (!asWorld().canPlayerModifyAt(player, pos)) {
if (!player.canModifyBlocks() || !asWorld().canPlayerModifyAt(player, pos)) {
return false;
}
} else {
if (asWorld() instanceof ServerWorld sw) {
@Nullable
PlayerEntity player = OfflinePlayerCache.getOfflinePlayer(sw, getMasterId().orElse(null));
if (player != null && !player.canModifyBlocks() || !sw.canPlayerModifyAt(player, pos)) {
return false;
}
}

if (!asWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public boolean tick(Caster<?> source, Situation situation) {

storedFluidPositions.removeIf(entry -> {
if (!area.isPointInside(Vec3d.ofCenter(entry.pos()))) {
entry.restore(world);
if (source.canModifyAt(entry.pos())) {
entry.restore(world);
}
return true;
}

Expand All @@ -72,7 +74,7 @@ public boolean tick(Caster<?> source, Situation situation) {
pos = new BlockPos(pos);
BlockState state = world.getBlockState(pos);

if (state.getFluidState().isIn(affectedFluid)) {
if (source.canModifyAt(pos) && state.getFluidState().isIn(affectedFluid)) {
Block block = state.getBlock();

if (block instanceof FluidBlock) {
Expand All @@ -95,7 +97,7 @@ public boolean tick(Caster<?> source, Situation situation) {

source.spawnParticles(new Sphere(true, range), 10, pos -> {
BlockPos bp = BlockPos.ofFloored(pos);
if (source.asWorld().getFluidState(bp.up()).isIn(affectedFluid)) {
if (source.canModifyAt(bp) && source.asWorld().getFluidState(bp.up()).isIn(affectedFluid)) {
source.addParticle(UParticles.RAIN_DROPS, pos, Vec3d.ZERO);
}
});
Expand All @@ -116,7 +118,9 @@ public boolean tick(Caster<?> source, Situation situation) {
protected void onDestroyed(Caster<?> caster) {
Ether.get(caster.asWorld()).remove(this, caster);
storedFluidPositions.removeIf(entry -> {
entry.restore(caster.asWorld());
if (caster.canModifyAt(entry.pos())) {
entry.restore(caster.asWorld());
}
return true;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public boolean tick(Caster<?> source, Situation situation) {
for (int i = 0; i < radius * 2; i++) {
if (w.random.nextInt(12) == 0) {
Vec3d vec = shape.computePoint(w.random).add(origin);
BlockPos pos = BlockPos.ofFloored(vec);

if (!applyBlocks(w, BlockPos.ofFloored(vec))) {
if (source.canModifyAt(pos) && !applyBlocks(w, pos)) {
applyEntities(source, vec);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public interface UCriteria {
CustomEventCriterion.Trigger RIDE_BALLOON = CUSTOM_EVENT.createTrigger("ride_balloon");
CustomEventCriterion.Trigger CONSTRUCT_BALLOON = CUSTOM_EVENT.createTrigger("construct_balloon");
CustomEventCriterion.Trigger TELEPORT_ABOVE_WORLD = CUSTOM_EVENT.createTrigger("teleport_above_world");
CustomEventCriterion.Trigger SEAPONY_TRANSITION = CUSTOM_EVENT.createTrigger("seapony_transition");

static void bootstrap() { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos
}

protected boolean canInteract(BlockState state, BlockView world, BlockPos pos, EquineContext context) {
return context.collidesWithClouds();
return context.collidesWithClouds() || context.hasFeatherTouch();
}

@SuppressWarnings("deprecation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,7 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> builder)

@Override
protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, EquineContext equineContext) {
var axis = state.get(AXIS);

int[] offsets = { axis.choose(1, 0, 0), axis.choose(0, 1, 0), axis.choose(0, 0, 1) };
float capOffset = 11F / 16F;
VoxelShape core = Block.createCuboidShape(
axis.choose(0, 1, 1), axis.choose(1, 0, 1), axis.choose(1, 1, 0),
16 - axis.choose(0, 1, 1), 16 - axis.choose(1, 0, 1), 16 - axis.choose(1, 1, 0)
);
VoxelShape foot = Block.createCuboidShape(0, 0, 0, 16 - (11 * offsets[0]), 16 - (11 * offsets[1]), 16 - (11 * offsets[2]));
VoxelShape cap = foot.offset(capOffset * offsets[0], capOffset * offsets[1], capOffset * offsets[2]);
var temp = new VoxelShape[] {
core,
VoxelShapes.union(core, foot),
VoxelShapes.union(core, cap),
VoxelShapes.union(core, cap, foot)
};
return temp[(state.get(TOP) ? 0 : 2) + (state.get(BOTTOM) ? 0 : 1)];
//return SHAPES.apply(state.get(AXIS))[(state.get(TOP) ? 0 : 2) + (state.get(BOTTOM) ? 0 : 1)];
return SHAPES.apply(state.get(AXIS))[(state.get(TOP) ? 0 : 2) + (state.get(BOTTOM) ? 0 : 1)];
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ private boolean onLivingRender(Living<?> pony,
return true;
}

pony.updateSupportingEntity();

matrices.push();

Entity owner = pony.asEntity();
Expand Down
Loading

0 comments on commit 18d8ba4

Please sign in to comment.