Some refinements. Cloud block items now float on other cloud blocks

This commit is contained in:
Sollace 2023-10-21 20:30:13 +01:00
parent 2025d5af09
commit 23266d2f3a
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
13 changed files with 59 additions and 3 deletions

View file

@ -21,6 +21,10 @@ public interface EquineContext {
return 0; return 0;
} }
default boolean collidesWithClouds() {
return getCompositeRace().any(Race::canInteractWithClouds);
}
static EquineContext of(ShapeContext context) { static EquineContext of(ShapeContext context) {
if (context == ShapeContext.absent()) { if (context == ShapeContext.absent()) {
return Unicopia.SIDE.getPony().map(EquineContext.class::cast).orElse(ABSENT); return Unicopia.SIDE.getPony().map(EquineContext.class::cast).orElse(ABSENT);

View file

@ -26,6 +26,7 @@ public interface UTags {
TagKey<Item> CHANGELING_EDIBLE = item("food_types/changeling_edible"); TagKey<Item> CHANGELING_EDIBLE = item("food_types/changeling_edible");
TagKey<Item> SPOOKED_MOB_DROPS = item("spooked_mob_drops"); TagKey<Item> SPOOKED_MOB_DROPS = item("spooked_mob_drops");
TagKey<Item> IS_DELIVERED_AGGRESSIVELY = item("is_delivered_aggressively"); TagKey<Item> IS_DELIVERED_AGGRESSIVELY = item("is_delivered_aggressively");
TagKey<Item> FLOATS_ON_CLOUDS = item("floats_on_clouds");
TagKey<Item> POLEARMS = item("polearms"); TagKey<Item> POLEARMS = item("polearms");
TagKey<Item> APPLE_SEEDS = item("apple_seeds"); TagKey<Item> APPLE_SEEDS = item("apple_seeds");

View file

@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.block.cloud;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.EquineContext; import com.minelittlepony.unicopia.EquineContext;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -176,7 +175,7 @@ public class CloudBlock extends Block {
} }
protected boolean canInteract(BlockState state, BlockView world, BlockPos pos, EquineContext context) { protected boolean canInteract(BlockState state, BlockView world, BlockPos pos, EquineContext context) {
return context.getCompositeRace().any(Race::canInteractWithClouds); return context.collidesWithClouds();
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")

View file

@ -154,6 +154,11 @@ public class ItemImpl implements Equine<ItemEntity> {
entity.getDataTracker().set(ITEM_RACE, Race.REGISTRY.getId(race).toString()); entity.getDataTracker().set(ITEM_RACE, Race.REGISTRY.getId(race).toString());
} }
@Override
public boolean collidesWithClouds() {
return entity.getStack().isIn(UTags.FLOATS_ON_CLOUDS) || getSpecies().canInteractWithClouds();
}
@Override @Override
public void toNBT(NbtCompound compound) { public void toNBT(NbtCompound compound) {
compound.putString("owner_race", Race.REGISTRY.getId(getSpecies()).toString()); compound.putString("owner_race", Race.REGISTRY.getId(getSpecies()).toString());

View file

@ -458,9 +458,15 @@ public class AirBalloonEntity extends MobEntity implements EntityCollisions.Comp
@Override @Override
public Race getSpecies() { public Race getSpecies() {
return isAirworthy() && !isAscending() ? Race.PEGASUS : Race.UNSET; return Race.UNSET;
} }
@Override
public boolean collidesWithClouds() {
return isAirworthy() && !isAscending();
}
@Override @Override
public float getCloudWalkingStrength() { public float getCloudWalkingStrength() {
return isAirworthy() ? 2 : 0; return isAirworthy() ? 2 : 0;

View file

@ -39,4 +39,9 @@ abstract class MixinEntityShapeContext implements EquineContext {
public float getCloudWalkingStrength() { public float getCloudWalkingStrength() {
return equineContext.getCloudWalkingStrength(); return equineContext.getCloudWalkingStrength();
} }
@Override
public boolean collidesWithClouds() {
return equineContext.collidesWithClouds();
}
} }

View file

@ -5,6 +5,7 @@
"unicopia:cloud_planks", "unicopia:cloud_planks",
"unicopia:dense_cloud", "unicopia:dense_cloud",
"unicopia:compacted_cloud", "unicopia:compacted_cloud",
"unicopia:compacted_cloud_planks",
"unicopia:unstable_cloud", "unicopia:unstable_cloud",
"unicopia:soggy_cloud" "unicopia:soggy_cloud"
] ]

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"unicopia:cloud_bed"
]
}

View file

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"unicopia:cloud_slab",
"unicopia:dense_cloud_slab",
"unicopia:cloud_planks_slab"
]
}

View file

@ -0,0 +1,8 @@
{
"replace": false,
"values": [
"unicopia:cloud_stairs",
"unicopia:dense_cloud_stairs",
"unicopia:cloud_planks_stairs"
]
}

View file

@ -0,0 +1,9 @@
{
"replace": false,
"values": [
"unicopia:cloud",
"unicopia:cloud_planks",
"unicopia:dense_cloud",
"unicopia:unstable_cloud"
]
}

View file

@ -4,8 +4,12 @@
"unicopia:cloud", "unicopia:cloud",
"unicopia:cloud_slab", "unicopia:cloud_slab",
"unicopia:cloud_stairs", "unicopia:cloud_stairs",
"unicopia:cloud_planks",
"unicopia:cloud_planks_slab",
"unicopia:cloud_planks_stairs",
"unicopia:dense_cloud", "unicopia:dense_cloud",
"unicopia:dense_cloud_slab", "unicopia:dense_cloud_slab",
"unicopia:dense_cloud_stairs",
"unicopia:unstable_cloud", "unicopia:unstable_cloud",
"unicopia:cloud_pillar", "unicopia:cloud_pillar",
"#unicopia:food_types/raw_fish", "#unicopia:food_types/raw_fish",