Skip to content

Commit

Permalink
Fixes, bumped versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Faboslav committed Dec 27, 2022
1 parent a58c6f8 commit 35420de
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 115 deletions.
6 changes: 3 additions & 3 deletions .github/versions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"1.19.2": "1.6.5",
"1.19.1": "1.6.5",
"1.19": "1.6.5",
"1.19.2": "1.6.6",
"1.19.1": "1.6.6",
"1.19": "1.6.6",
"1.18.2": "1.4.6",
"1.18.1": "1.2.5",
"1.18": "1.2.5"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## mc1.19.2-1.6.6, December 27, 2022

- Fixed custom lightning rods not working as the vanilla one
- Fixed moobloom child having random variant
- Fixed zombie horse trap thunderstorm spawn event

## mc1.19.2-1.6.5, December 22, 2022

- Fixed moobloom transform sound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.block.PlantBlock;
import net.minecraft.block.TallFlowerBlock;
import net.minecraft.block.TallPlantBlock;
import net.minecraft.block.enums.DoubleBlockHalf;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -55,7 +54,7 @@ public void render(
float scaleFactor = 0.8F;
float yOffset = -0.5F;

if(flower instanceof TallPlantBlock) {
if (flower instanceof TallPlantBlock) {
scaleFactor = 0.6F;
yOffset = -0.666F;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,15 @@ public MoobloomEntity createChild(
ServerWorld serverWorld,
PassiveEntity entity
) {
return FriendsAndFoesEntityTypes.MOOBLOOM.get().create(serverWorld);
MoobloomVariant moobloomVariant = this.getVariant();
if (RandomGenerator.generateInt(0, 1) == 0) {
moobloomVariant = ((MoobloomEntity) entity).getVariant();
}

MoobloomEntity moobloom = FriendsAndFoesEntityTypes.MOOBLOOM.get().create(serverWorld);
moobloom.setVariant(moobloomVariant);

return moobloom;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

import com.faboslav.friendsandfoes.FriendsAndFoes;
import com.faboslav.friendsandfoes.platform.RegistryHelper;
import net.minecraft.block.Block;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.poi.PointOfInterestType;
import net.minecraft.world.poi.PointOfInterestTypes;

import java.util.HashMap;
import java.util.function.Supplier;

/**
* @see PointOfInterestTypes
*/
public final class FriendsAndFoesPointOfInterestTypes
{
private static final HashMap<String, Supplier<PointOfInterestType>> REGISTERED_POINT_OF_INTEREST_TYPES;

public final static Supplier<PointOfInterestType> ACACIA_BEEHIVE;
public final static Supplier<PointOfInterestType> BIRCH_BEEHIVE;
public final static Supplier<PointOfInterestType> CRIMSON_BEEHIVE;
Expand All @@ -22,16 +26,31 @@ public final class FriendsAndFoesPointOfInterestTypes
public final static Supplier<PointOfInterestType> MANGROVE_BEEHIVE;
public final static Supplier<PointOfInterestType> SPRUCE_BEEHIVE;
public final static Supplier<PointOfInterestType> WARPED_BEEHIVE;
public static final Supplier<PointOfInterestType> EXPOSED_LIGHTNING_ROD;
public static final Supplier<PointOfInterestType> WEATHERED_LIGHTNING_ROD;
public static final Supplier<PointOfInterestType> OXIDIZED_LIGHTNING_ROD;
public static final Supplier<PointOfInterestType> WAXED_LIGHTNING_ROD;
public static final Supplier<PointOfInterestType> WAXED_EXPOSED_LIGHTNING_ROD;
public static final Supplier<PointOfInterestType> WAXED_WEATHERED_LIGHTNING_ROD;
public static final Supplier<PointOfInterestType> WAXED_OXIDIZED_LIGHTNING_ROD;

static {
ACACIA_BEEHIVE = RegistryHelper.registerPointOfInterestType("acacia_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.ACACIA_BEEHIVE.get()), 1, 1));
BIRCH_BEEHIVE = RegistryHelper.registerPointOfInterestType("birch_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.BIRCH_BEEHIVE.get()), 1, 1));
CRIMSON_BEEHIVE = RegistryHelper.registerPointOfInterestType("crimson_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.CRIMSON_BEEHIVE.get()), 1, 1));
DARK_OAK_BEEHIVE = RegistryHelper.registerPointOfInterestType("dark_oak_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.DARK_OAK_BEEHIVE.get()), 1, 1));
JUNGLE_BEEHIVE = RegistryHelper.registerPointOfInterestType("jungle_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.JUNGLE_BEEHIVE.get()), 1, 1));
MANGROVE_BEEHIVE = RegistryHelper.registerPointOfInterestType("mangrove_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.MANGROVE_BEEHIVE.get()), 1, 1));
SPRUCE_BEEHIVE = RegistryHelper.registerPointOfInterestType("spruce_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.SPRUCE_BEEHIVE.get()), 1, 1));
WARPED_BEEHIVE = RegistryHelper.registerPointOfInterestType("warped_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.WARPED_BEEHIVE.get()), 1, 1));
REGISTERED_POINT_OF_INTEREST_TYPES = new HashMap<>();
ACACIA_BEEHIVE = registerPointOfInterest("acacia_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.ACACIA_BEEHIVE.get()), 1, 1));
BIRCH_BEEHIVE = registerPointOfInterest("birch_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.BIRCH_BEEHIVE.get()), 1, 1));
CRIMSON_BEEHIVE = registerPointOfInterest("crimson_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.CRIMSON_BEEHIVE.get()), 1, 1));
DARK_OAK_BEEHIVE = registerPointOfInterest("dark_oak_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.DARK_OAK_BEEHIVE.get()), 1, 1));
JUNGLE_BEEHIVE = registerPointOfInterest("jungle_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.JUNGLE_BEEHIVE.get()), 1, 1));
MANGROVE_BEEHIVE = registerPointOfInterest("mangrove_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.MANGROVE_BEEHIVE.get()), 1, 1));
SPRUCE_BEEHIVE = registerPointOfInterest("spruce_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.SPRUCE_BEEHIVE.get()), 1, 1));
WARPED_BEEHIVE = registerPointOfInterest("warped_beehive", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.WARPED_BEEHIVE.get()), 1, 1));
EXPOSED_LIGHTNING_ROD = registerPointOfInterest("exposed_lightning_rod", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.EXPOSED_LIGHTNING_ROD.get()), 0, 1));
WEATHERED_LIGHTNING_ROD = registerPointOfInterest("weathered_lightning_rod", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.WEATHERED_LIGHTNING_ROD.get()), 0, 1));
OXIDIZED_LIGHTNING_ROD = registerPointOfInterest("oxidized_lightning_rod", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.OXIDIZED_LIGHTNING_ROD.get()), 0, 1));
WAXED_LIGHTNING_ROD = registerPointOfInterest("waxed_lightning_rod", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.WAXED_LIGHTNING_ROD.get()), 0, 1));
WAXED_EXPOSED_LIGHTNING_ROD = registerPointOfInterest("waxed_exposed_lightning_rod", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.WAXED_EXPOSED_LIGHTNING_ROD.get()), 0, 1));
WAXED_WEATHERED_LIGHTNING_ROD = registerPointOfInterest("waxed_weathered_lightning_rod", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.WAXED_WEATHERED_LIGHTNING_ROD.get()), 0, 1));
WAXED_OXIDIZED_LIGHTNING_ROD = registerPointOfInterest("waxed_oxidized_lightning_rod", () -> new PointOfInterestType(PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.WAXED_OXIDIZED_LIGHTNING_ROD.get()), 0, 1));
}

public static void init() {
Expand All @@ -41,106 +60,32 @@ public static void postInit() {
fillMissingPointOfInterestMapValues();
}

private static void fillMissingPointOfInterestMapValues() {
var acaciaBeehiveStates = PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.ACACIA_BEEHIVE.get());
PointOfInterestTypes.POI_STATES.addAll(acaciaBeehiveStates);
acaciaBeehiveStates.forEach((state) -> {
PointOfInterestTypes.POI_STATES_TO_TYPE.put(
state,
Registry.POINT_OF_INTEREST_TYPE.getEntry(
RegistryKey.of(
Registry.POINT_OF_INTEREST_TYPE_KEY, FriendsAndFoes.makeID("acacia_beehive")
)
).get()
);
});

var birchBeehiveStates = PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.BIRCH_BEEHIVE.get());
PointOfInterestTypes.POI_STATES.addAll(birchBeehiveStates);
birchBeehiveStates.forEach((state) -> {
PointOfInterestTypes.POI_STATES_TO_TYPE.put(
state,
Registry.POINT_OF_INTEREST_TYPE.getEntry(
RegistryKey.of(
Registry.POINT_OF_INTEREST_TYPE_KEY, FriendsAndFoes.makeID("birch_beehive")
)
).get()
);
});

var crimsonBeehiveStates = PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.CRIMSON_BEEHIVE.get());
PointOfInterestTypes.POI_STATES.addAll(crimsonBeehiveStates);
crimsonBeehiveStates.forEach((state) -> {
PointOfInterestTypes.POI_STATES_TO_TYPE.put(
state,
Registry.POINT_OF_INTEREST_TYPE.getEntry(
RegistryKey.of(
Registry.POINT_OF_INTEREST_TYPE_KEY, FriendsAndFoes.makeID("crimson_beehive")
)
).get()
);
});

var darkOakBeehiveStates = PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.DARK_OAK_BEEHIVE.get());
PointOfInterestTypes.POI_STATES.addAll(darkOakBeehiveStates);
darkOakBeehiveStates.forEach((state) -> {
PointOfInterestTypes.POI_STATES_TO_TYPE.put(
state,
Registry.POINT_OF_INTEREST_TYPE.getEntry(
RegistryKey.of(
Registry.POINT_OF_INTEREST_TYPE_KEY, FriendsAndFoes.makeID("dark_oak_beehive")
)
).get()
);
});

var jungleBeehiveStates = PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.JUNGLE_BEEHIVE.get());
PointOfInterestTypes.POI_STATES.addAll(jungleBeehiveStates);
jungleBeehiveStates.forEach((state) -> {
PointOfInterestTypes.POI_STATES_TO_TYPE.put(
state,
Registry.POINT_OF_INTEREST_TYPE.getEntry(
RegistryKey.of(
Registry.POINT_OF_INTEREST_TYPE_KEY, FriendsAndFoes.makeID("jungle_beehive")
)
).get()
);
});

var mangroveBeehiveStates = PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.MANGROVE_BEEHIVE.get());
PointOfInterestTypes.POI_STATES.addAll(mangroveBeehiveStates);
mangroveBeehiveStates.forEach((state) -> {
PointOfInterestTypes.POI_STATES_TO_TYPE.put(
state,
Registry.POINT_OF_INTEREST_TYPE.getEntry(
RegistryKey.of(
Registry.POINT_OF_INTEREST_TYPE_KEY, FriendsAndFoes.makeID("mangrove_beehive")
)
).get()
);
});
private static Supplier<PointOfInterestType> registerPointOfInterest(
String name,
Supplier<PointOfInterestType> pointOfInterestType
) {
REGISTERED_POINT_OF_INTEREST_TYPES.put(name, pointOfInterestType);
return RegistryHelper.registerPointOfInterestType(name, pointOfInterestType);
}

var spruceBeehiveStates = PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.SPRUCE_BEEHIVE.get());
PointOfInterestTypes.POI_STATES.addAll(spruceBeehiveStates);
spruceBeehiveStates.forEach((state) -> {
PointOfInterestTypes.POI_STATES_TO_TYPE.put(
state,
Registry.POINT_OF_INTEREST_TYPE.getEntry(
RegistryKey.of(
Registry.POINT_OF_INTEREST_TYPE_KEY, FriendsAndFoes.makeID("spruce_beehive")
)
).get()
);
private static void fillMissingPointOfInterestMapValues() {
REGISTERED_POINT_OF_INTEREST_TYPES.forEach((name, pointOfInterestType) -> {
fillMissingPointOfInterestMapValueForBlock(name, pointOfInterestType.get().blockStates().iterator().next().getBlock());
});
}

var warpedBeehiveStates = PointOfInterestTypes.getStatesOfBlock(FriendsAndFoesBlocks.WARPED_BEEHIVE.get());
PointOfInterestTypes.POI_STATES.addAll(warpedBeehiveStates);
warpedBeehiveStates.forEach((state) -> {
private static void fillMissingPointOfInterestMapValueForBlock(
String name,
Block pointOfInterestBlock
) {
var blockStates = PointOfInterestTypes.getStatesOfBlock(pointOfInterestBlock);
PointOfInterestTypes.POI_STATES.addAll(blockStates);
blockStates.forEach((state) -> {
PointOfInterestTypes.POI_STATES_TO_TYPE.put(
state,
Registry.POINT_OF_INTEREST_TYPE.getEntry(
RegistryKey.of(
Registry.POINT_OF_INTEREST_TYPE_KEY, FriendsAndFoes.makeID("warped_beehive")
Registry.POINT_OF_INTEREST_TYPE_KEY, FriendsAndFoes.makeID(name)
)
).get()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private boolean friendsandfoes_expandPowerLightningRodIsLightningRodCondition(bo
ordinal = 0,
shift = At.Shift.AFTER
),
method = "Lnet/minecraft/entity/LightningEntity;tick()V"
method = "tick()V"
)
private void friendsandfoes_cleanLightningRodOxidation(CallbackInfo ci) {
BlockPos blockPos = this.getAffectedBlockPos();
Expand Down Expand Up @@ -89,7 +89,7 @@ private static boolean friendsandfoes_expandCleanOxidationRodIsLightningRodCondi
ordinal = 0,
shift = At.Shift.AFTER
),
method = "Lnet/minecraft/entity/LightningEntity;cleanOxidationAround(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Ljava/util/Optional;",
method = "cleanOxidationAround(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;)Ljava/util/Optional;",
locals = LocalCapture.CAPTURE_FAILSOFT
)
private static void friendsandfoes_decreaseCustomOxidationStates(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
import net.minecraft.world.*;
import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.poi.PointOfInterestStorage;
import org.spongepowered.asm.mixin.Mixin;
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Optional;
import java.util.function.Supplier;

@Mixin(ServerWorld.class)
Expand All @@ -45,8 +48,7 @@ protected ServerWorldMixin(

@Inject(
method = "tickChunk",
at = @At("TAIL"),
cancellable = true
at = @At("TAIL")
)
public void friendsandfoes_addZombieHorseSpawnEvent(
WorldChunk chunk, int randomTickSpeed, CallbackInfo ci
Expand Down Expand Up @@ -83,4 +85,29 @@ public void friendsandfoes_addZombieHorseSpawnEvent(
}
}
}

@Inject(
method = "getLightningRodPos",
at = @At("TAIL"),
cancellable = true
)
public void friendsandfoes_getLightningRodPos(
BlockPos pos,
CallbackInfoReturnable<Optional<BlockPos>> cir
) {
if (cir.getReturnValue().isEmpty()) {
ServerWorld serverWorld = (ServerWorld) (Object) this;

Optional<BlockPos> optional = serverWorld.getPointOfInterestStorage().getNearestPosition((registryEntry) -> {
return registryEntry.isIn(FriendsAndFoesTags.LIGHTNING_ROD_POI);
}, (posx) -> {
return posx.getY() == this.getTopY(Heightmap.Type.WORLD_SURFACE, posx.getX(), posx.getZ()) - 1;
}, pos, 128, PointOfInterestStorage.OccupationStatus.ANY);


if (optional.isPresent()) {
cir.setReturnValue(optional.map((posx) -> posx.up(1)));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.tag.TagKey;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.poi.PointOfInterestType;

/**
* @see BlockTags
Expand All @@ -16,6 +17,7 @@ public final class FriendsAndFoesTags
{
public static final TagKey<Block> COPPER_BUTTONS = blockTag("copper_buttons");
public static final TagKey<Block> LIGHTNING_RODS = blockTag("lightning_rods");
public static final TagKey<PointOfInterestType> LIGHTNING_ROD_POI = pointOfInterestTypeTag("lightning_rods");
public static final TagKey<Block> GLARES_SPAWNABLE_ON = blockTag("glares_spawnable_on");
public static final TagKey<Block> MAULERS_SPAWNABLE_ON = blockTag("maulers_spawnable_on");
public static final TagKey<Item> GLARE_FOOD_ITEMS = itemTag("glare_food_items");
Expand Down Expand Up @@ -46,4 +48,8 @@ private static TagKey<EntityType<?>> entityTypeTag(String name) {
private static TagKey<Biome> biomeTag(String name) {
return TagKey.of(Registry.BIOME_KEY, FriendsAndFoes.makeID(name));
}

private static TagKey<PointOfInterestType> pointOfInterestTypeTag(String name) {
return TagKey.of(Registry.POINT_OF_INTEREST_TYPE_KEY, FriendsAndFoes.makeID(name));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"replace": false,
"values": [
"friendsandfoes:exposed_lightning_rod",
"friendsandfoes:weathered_lightning_rod",
"friendsandfoes:oxidized_lightning_rod",
"friendsandfoes:waxed_lightning_rod",
"friendsandfoes:waxed_exposed_lightning_rod",
"friendsandfoes:waxed_oxidized_lightning_rod",
"friendsandfoes:waxed_weathered_lightning_rod"
]
}
4 changes: 1 addition & 3 deletions common/src/main/resources/friendsandfoes-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"RaidMemberMixin",
"RaidMixin",
"ServerWorldAccessor",
"ServerWorldMixin",
"SpawnRestrictionAccessor",
"StructurePoolMixin",
"VillagerEntityMixin",
Expand All @@ -38,8 +39,5 @@
"ClientPlayNetworkHandlerMixin",
"IllusionerEntityRendererMixin",
"ModelPartAccessor"
],
"server": [
"ServerWorldMixin"
]
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.configureondemand=false
# Mod
mod_name=Friends&Foes
mod_id=friendsandfoes
mod_version=1.6.5
mod_version=1.6.6
mod_author=Faboslav
mod_description=Adds outvoted and forgotten mobs from the mob votes in a believable vanilla plus style.
maven_group=com.faboslav.friendsandfoes
Expand Down

0 comments on commit 35420de

Please sign in to comment.