Skip to content

Commit

Permalink
Merge branch 'master' into 1.19
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/resources/fabric.mod.json
  • Loading branch information
Treetrain1 committed Aug 17, 2022
2 parents 241abbe + a740b72 commit f675ed5
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 57 deletions.
20 changes: 10 additions & 10 deletions src/main/java/net/frozenblock/wilderwild/WilderWildClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public void onInitializeClient() {
}


public void receiveAncientHornProjectilePacket() {
private static void receiveAncientHornProjectilePacket() {
ClientPlayNetworking.registerGlobalReceiver(WilderWild.HORN_PROJECTILE_PACKET_ID, (ctx, handler, byteBuf, responseSender) -> {
EntityType<?> et = Registry.ENTITY_TYPE.get(byteBuf.readVarInt());
UUID uuid = byteBuf.readUuid();
Expand All @@ -200,7 +200,7 @@ public void receiveAncientHornProjectilePacket() {
});
}

public void receiveEasyEchoerBubblePacket() {
private static void receiveEasyEchoerBubblePacket() {
ClientPlayNetworking.registerGlobalReceiver(WilderWild.FLOATING_SCULK_BUBBLE_PACKET, (ctx, handler, byteBuf, responseSender) -> {
Vec3d pos = new Vec3d(byteBuf.readDouble(), byteBuf.readDouble(), byteBuf.readDouble());
int size = byteBuf.readVarInt();
Expand All @@ -217,7 +217,7 @@ public void receiveEasyEchoerBubblePacket() {
});
}

public void receiveSeedPacket() {
private static void receiveSeedPacket() {
ClientPlayNetworking.registerGlobalReceiver(WilderWild.SEED_PACKET, (ctx, handler, byteBuf, responseSender) -> {
Vec3d pos = new Vec3d(byteBuf.readDouble(), byteBuf.readDouble(), byteBuf.readDouble());
int count = byteBuf.readVarInt();
Expand All @@ -232,7 +232,7 @@ public void receiveSeedPacket() {
});
}

public void receiveControlledSeedPacket() {
private static void receiveControlledSeedPacket() {
ClientPlayNetworking.registerGlobalReceiver(WilderWild.CONTROLLED_SEED_PACKET, (ctx, handler, byteBuf, responseSender) -> {
Vec3d pos = new Vec3d(byteBuf.readDouble(), byteBuf.readDouble(), byteBuf.readDouble());
double velx = byteBuf.readDouble();
Expand All @@ -250,7 +250,7 @@ public void receiveControlledSeedPacket() {
});
}

public void receiveTermitePacket() {
private static void receiveTermitePacket() {
ClientPlayNetworking.registerGlobalReceiver(WilderWild.TERMITE_PARTICLE_PACKET, (ctx, handler, byteBuf, responseSender) -> {
Vec3d pos = new Vec3d(byteBuf.readDouble(), byteBuf.readDouble(), byteBuf.readDouble());
int count = byteBuf.readVarInt();
Expand All @@ -264,7 +264,7 @@ public void receiveTermitePacket() {
});
}

public void receiveSensorHiccupPacket() {
private static void receiveSensorHiccupPacket() {
ClientPlayNetworking.registerGlobalReceiver(WilderWild.SENSOR_HICCUP_PACKET, (ctx, handler, byteBuf, responseSender) -> {
Vec3d pos = new Vec3d(byteBuf.readDouble(), byteBuf.readDouble(), byteBuf.readDouble());
ctx.execute(() -> {
Expand All @@ -283,7 +283,7 @@ public void receiveSensorHiccupPacket() {
});
}

public void receiveFireflyCaptureInfoPacket() {
private static void receiveFireflyCaptureInfoPacket() {
ClientPlayNetworking.registerGlobalReceiver(WilderWild.CAPTURE_FIREFLY_NOTIFY_PACKET, (ctx, handler, byteBuf, responseSender) -> {
boolean creative = byteBuf.readBoolean();
boolean natural = byteBuf.readBoolean();
Expand All @@ -295,7 +295,7 @@ public void receiveFireflyCaptureInfoPacket() {
});
}

public void receiveAncientHornKillInfoPacket() {
private static void receiveAncientHornKillInfoPacket() {
ClientPlayNetworking.registerGlobalReceiver(WilderWild.ANCIENT_HORN_KILL_NOTIFY_PACKET, (ctx, handler, byteBuf, responseSender) -> {
boolean creative = byteBuf.readBoolean();
boolean natural = byteBuf.readBoolean();
Expand All @@ -307,7 +307,7 @@ public void receiveAncientHornKillInfoPacket() {
});
}

public void receiveMovingLoopingSoundPacket() {
private static void receiveMovingLoopingSoundPacket() {
ClientPlayNetworking.registerGlobalReceiver(WilderWild.MOVING_LOOPING_SOUND_PACKET, (ctx, handler, byteBuf, responseSender) -> {
int id = byteBuf.readVarInt();
SoundEvent sound = byteBuf.readRegistryValue(Registry.SOUND_EVENT);
Expand All @@ -331,7 +331,7 @@ public void receiveMovingLoopingSoundPacket() {
});
}

public void receiveFlybySoundPacket() {
private static void receiveFlybySoundPacket() {
ClientPlayNetworking.registerGlobalReceiver(WilderWild.FLYBY_SOUND_PACKET, (ctx, handler, byteBuf, responseSender) -> {
int id = byteBuf.readVarInt();
SoundEvent sound = byteBuf.readRegistryValue(Registry.SOUND_EVENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void useOnBlock(ItemUsageContext context, CallbackInfoReturnable<ActionRe
}
}
if (state.isOf(RegisterBlocks.ALGAE)) {
WilderWild.log("Floating Moss Bonemealed @ " + blockPos, WilderWild.DEV_LOGGING);
WilderWild.log("Algae Bonemealed @ " + blockPos, WilderWild.DEV_LOGGING);
if (!world.isClient) {
for (Direction offset : shuffleOffsets(world.getRandom())) {
BlockPos pos = blockPos.offset(offset);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.frozenblock.wilderwild.tag.WilderBlockTags;
import net.minecraft.block.*;
import net.minecraft.block.entity.SculkSpreadManager;
import net.minecraft.fluid.Fluids;
import net.minecraft.sound.SoundCategory;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
Expand All @@ -34,6 +33,11 @@ private static int getDecay(SculkSpreadManager spreadManager, BlockPos cursorPos
return Math.max(1, (int) ((float) charge * g * 0.5F));
}

@Shadow
private static boolean shouldNotDecay(WorldAccess world, BlockPos pos) {
return false;
}

private static final int HEIGHT_MULTIPLIER = 20; //The higher, the less short pillars you'll see.
private static final int MAX_HEIGHT = 15; //The rarest and absolute tallest height of pillars
private static final double RANDOMNESS = 0.9; //The higher, the more random. The lower, the more gradual the heights change.
Expand Down Expand Up @@ -172,7 +176,7 @@ private BlockState getExtraBlockState(WorldAccess world, BlockPos pos, Random ra
private static boolean shouldNotDecay(WorldAccess world, BlockPos pos, boolean isWorldGen) {
BlockState blockState = world.getBlockState(pos.up());
BlockState blockState1 = world.getBlockState(pos.down());
if (((blockState.isAir()) || (blockState.isOf(Blocks.WATER) && blockState.getFluidState().isOf(Fluids.WATER))) || ((isWorldGen || canPlaceOsseousSculk(pos, isWorldGen, world)) && ((blockState1.isAir()) || (blockState1.isOf(Blocks.WATER) && blockState1.getFluidState().isOf(Fluids.WATER))))) {
if (shouldNotDecay(world, pos) || ((isWorldGen || canPlaceOsseousSculk(pos, isWorldGen, world)) && shouldNotDecay(world, pos))) {
int i = 0;
Iterator<BlockPos> var4 = BlockPos.iterate(pos.add(-4, 0, -4), pos.add(4, 2, 4)).iterator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@
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.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Stream;

@Mixin(SculkSpreadManager.Cursor.class)
public class SculkSpreadManagerCursorMixin {
public abstract class SculkSpreadManagerCursorMixin {

@Final
@Shadow
private static final ObjectArrayList<Vec3i> OFFSETS = Util.make(new ObjectArrayList<>(18), (objectArrayList) -> {
private static ObjectArrayList<Vec3i> OFFSETS = Util.make(new ObjectArrayList<>(18), (objectArrayList) -> {
Stream<BlockPos> var10000 = BlockPos.stream(new BlockPos(-1, -1, -1), new BlockPos(1, 1, 1)).filter((pos) -> {
return (pos.getX() == 0 || pos.getY() == 0 || pos.getZ() == 0) && !pos.equals(BlockPos.ORIGIN);
}).map(BlockPos::toImmutable);
Expand Down Expand Up @@ -75,7 +76,7 @@ public void spread(WorldAccess world, BlockPos pos, Random random, SculkSpreadMa
if (this.charge <= 0) {
sculkSpreadable.spreadAtSamePosition(world, blockState, this.pos, random);
} else {
BlockPos blockPos = getSpreadPosNew(world, this.pos, random);
BlockPos blockPos = getSpreadPos(world, this.pos, random);
if (blockPos != null) {
sculkSpreadable.spreadAtSamePosition(world, blockState, this.pos, random);
this.pos = blockPos.toImmutable();
Expand All @@ -100,17 +101,10 @@ public void spread(WorldAccess world, BlockPos pos, Random random, SculkSpreadMa
}

private static SculkSpreadable getSpreadableNew(BlockState state, boolean isWorldGen) {
Block var2 = state.getBlock();
SculkSpreadable var10000;
if (var2 instanceof SculkSpreadable) {
var10000 = (SculkSpreadable) var2;
} else if (isWorldGen && (state.isIn(WilderBlockTags.SCULK_WALL_REPLACEABLE_WORLDGEN) || state.isIn(WilderBlockTags.SCULK_SLAB_REPLACEABLE_WORLDGEN) || state.isIn(WilderBlockTags.SCULK_STAIR_REPLACEABLE_WORLDGEN))) {
var10000 = new WilderSculkSpreader();
} else {
var10000 = SculkSpreadable.VEIN_ONLY_SPREADER;
if (isWorldGen && (state.isIn(WilderBlockTags.SCULK_WALL_REPLACEABLE_WORLDGEN) || state.isIn(WilderBlockTags.SCULK_SLAB_REPLACEABLE_WORLDGEN) || state.isIn(WilderBlockTags.SCULK_STAIR_REPLACEABLE_WORLDGEN))) {
return new WilderSculkSpreader();
}

return var10000;
return getSpreadable(state);
}

@Shadow
Expand All @@ -127,32 +121,16 @@ private boolean canSpread(WorldAccess world, BlockPos pos, boolean worldGen) {
}

private static boolean canSpreadNew(WorldAccess world, BlockPos sourcePos, BlockPos targetPos) {
if (sourcePos.getManhattanDistance(targetPos) == 1) {
return true;
} else {
if (sourcePos.getManhattanDistance(targetPos) != 1) {
BlockState cheatState = world.getBlockState(targetPos);
if (cheatState.isIn(WilderBlockTags.SCULK_STAIR_REPLACEABLE_WORLDGEN) || cheatState.isIn(WilderBlockTags.SCULK_WALL_REPLACEABLE_WORLDGEN) || cheatState.isIn(WilderBlockTags.SCULK_SLAB_REPLACEABLE_WORLDGEN)) {
return true;
}
BlockPos blockPos = targetPos.subtract(sourcePos);
Direction direction = Direction.from(Direction.Axis.X, blockPos.getX() < 0 ? Direction.AxisDirection.NEGATIVE : Direction.AxisDirection.POSITIVE);
Direction direction2 = Direction.from(Direction.Axis.Y, blockPos.getY() < 0 ? Direction.AxisDirection.NEGATIVE : Direction.AxisDirection.POSITIVE);
Direction direction3 = Direction.from(Direction.Axis.Z, blockPos.getZ() < 0 ? Direction.AxisDirection.NEGATIVE : Direction.AxisDirection.POSITIVE);
if (blockPos.getX() == 0) {
return canSpread(world, sourcePos, direction2) || canSpread(world, sourcePos, direction3);
} else if (blockPos.getY() == 0) {
return canSpread(world, sourcePos, direction) || canSpread(world, sourcePos, direction3);
} else {
return canSpread(world, sourcePos, direction) || canSpread(world, sourcePos, direction2);
}
}
return canSpread(world, sourcePos, targetPos);
}

private static boolean canSpread(WorldAccess world, BlockPos pos, Direction direction) {
BlockPos blockPos = pos.offset(direction);
return !world.getBlockState(blockPos).isSideSolidFullSquare(world, blockPos, direction.getOpposite());
}

@Shadow
private static SculkSpreadable getSpreadable(BlockState state) {
Block var2 = state.getBlock();
SculkSpreadable var10000;
Expand All @@ -170,22 +148,39 @@ private static List<Vec3i> shuffleOffsets(Random random) {
return Util.copyShuffled(OFFSETS, random);
}

private static BlockPos getSpreadPosNew(WorldAccess world, BlockPos pos, Random random) {
@Shadow
private static boolean canSpread(WorldAccess world, BlockPos sourcePos, BlockPos targetPos) {
return false;
}

@Shadow
@Nullable
private static BlockPos getSpreadPos(WorldAccess world, BlockPos pos, Random random) {
return null;
}

@Inject(method = "getSpreadPos", at = @At("HEAD"), cancellable = true)
private static void getSpreadPos(WorldAccess world, BlockPos pos, Random random, CallbackInfoReturnable<BlockPos> cir) {
BlockPos.Mutable mutable = pos.mutableCopy();
BlockPos.Mutable mutable2 = pos.mutableCopy();

boolean canReturn = false;
for (Vec3i vec3i : shuffleOffsets(random)) {
mutable2.set(pos, vec3i);
BlockState blockState = world.getBlockState(mutable2);
boolean isInTags = blockState.isIn(WilderBlockTags.SCULK_SLAB_REPLACEABLE_WORLDGEN) || blockState.isIn(WilderBlockTags.SCULK_WALL_REPLACEABLE_WORLDGEN) || blockState.isIn(WilderBlockTags.SCULK_STAIR_REPLACEABLE_WORLDGEN);
if ((blockState.getBlock() instanceof SculkSpreadable || isInTags) && canSpreadNew(world, pos, mutable2)) {
if (isInTags && canSpreadNew(world, pos, mutable2)) {
mutable.set(mutable2);
canReturn = true;
if (SculkVeinBlock.veinCoversSculkReplaceable(world, blockState, mutable2)) {
break;
}
}
}

return mutable.equals(pos) ? null : mutable;
if (canReturn) {
cir.setReturnValue(mutable.equals(pos) ? null : mutable);
cir.cancel();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ private static void canSpawn(EntityType<SlimeEntity> type, WorldAccess world, Sp
//if (world.getBiome(pos).isIn(WilderBiomeTags.SLIMES_SPAWN_ON_FLOATING_MOSS)) {
if (world.getLightLevel(LightType.BLOCK, pos) < random.nextInt(8)) {
boolean test = spawnReason == SpawnReason.SPAWNER || random.nextInt(5) == 0;
if (test && isFloatingMossNearby(world, pos, 1)) {
if (test && isAlgaeNearby(world, pos, 1)) {
info.setReturnValue(true);
info.cancel();
}
}
}
}

private static boolean isFloatingMossNearby(WorldAccess world, BlockPos blockPos, int x) {
private static boolean isAlgaeNearby(WorldAccess world, BlockPos blockPos, int x) {
Iterator<BlockPos> iterator = BlockPos.iterate(blockPos.add(-x, -x, -x), blockPos.add(x, x, x)).iterator();
int count = 0;
BlockPos pos;
Expand All @@ -54,7 +54,7 @@ private static boolean isFloatingMossNearby(WorldAccess world, BlockPos blockPos

@Override
public boolean canSpawn(WorldView world) {
return (!world.containsFluid(this.getBoundingBox()) || isFloatingMossNearby(this.getWorld(), this.getBlockPos(), 1)) && world.doesNotIntersectEntities(this);
return (!world.containsFluid(this.getBoundingBox()) || isAlgaeNearby(this.getWorld(), this.getBlockPos(), 1)) && world.doesNotIntersectEntities(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(SonicBoomTask.class)
@Mixin(value = SonicBoomTask.class, priority = 1001)
public class SonicBoomTaskMixin {
@Final
@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void init() {
tableBuilder.pool(pool);
}
});
//FLOATING MOSS
//ALGAE
LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> {
if (LootTables.SHIPWRECK_SUPPLY_CHEST.equals(id) && source.isBuiltin()) {
LootPool.Builder pool = LootPool.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
},
"elements": [
{
"name": "outer",
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
Expand All @@ -16,8 +17,9 @@
}
},
{
"from": [13, 16, 13],
"to": [3, 0, 3],
"name": "inner",
"from": [13.01, 16.01, 13.01],
"to": [2.99, -0.01, 2.99],
"faces": {
"north": {"uv": [13, 16, 3, 0], "texture": "#inner"},
"east": {"uv": [13, 16, 3, 0], "texture": "#inner"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
},
"elements": [
{
"name": "outer",
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
Expand All @@ -16,8 +17,9 @@
}
},
{
"from": [13, 16, 13],
"to": [3, 0, 3],
"name": "inner",
"from": [13.01, 16.01, 13.01],
"to": [2.99, -0.01, 2.99],
"faces": {
"north": {"uv": [13, 16, 3, 0], "texture": "#inner"},
"east": {"uv": [13, 16, 3, 0], "texture": "#inner"},
Expand Down

0 comments on commit f675ed5

Please sign in to comment.