Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/VazkiiMods/Quark
Browse files Browse the repository at this point in the history
  • Loading branch information
MehVahdJukaar committed Jul 25, 2024
2 parents 849481a + 1e1175e commit 14769bd
Show file tree
Hide file tree
Showing 36 changed files with 90 additions and 156 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- Fallen logs can rarely spawn on water
- Fallen logs can no longer spawn on ice and other non terrain blocks (added tag for them)
- Fallen log decoration (moss and vines) are now biome temperature and humidify dependent. No more moss in snowy biomes
- Freestanding ladders will now break off the wall when you break the top block
- Matrix Enchanting Table appears in creative if automaticallyConvert is off
- Fixed Skull Pikes not functioning when there's a block on top, by lowering the detection point
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -47,6 +48,9 @@ public MatrixEnchantingTableBlock(ZetaModule module) {

this.module = module;
module.zeta.registry.registerBlock(this, "matrix_enchanter", true);

if(!MatrixEnchantingModule.automaticallyConvert)
setCreativeTab(CreativeModeTabs.FUNCTIONAL_BLOCKS, Blocks.ENCHANTING_TABLE, false);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class MatrixEnchantingPlusButton extends Button {

public MatrixEnchantingPlusButton(int x, int y, OnPress onPress) {
super(new Button.Builder(Component.literal(""), onPress).size(50, 12).pos(x, y));
super(Button.builder(Component.literal(""), onPress).size(50, 12).pos(x, y));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private static void celebrate(String name, int day, int end, Month month, int ti
private boolean showBubble;

public QButton(int x, int y) {
super(new Button.Builder(Component.literal("q"), QButton::click).size(20, 20).pos(x, y));
super(Button.builder(Component.literal("q"), QButton::click).size(20, 20).pos(x, y));

Calendar calendar = Calendar.getInstance();
int month = calendar.get(Calendar.MONTH) + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class SocialButton extends Button {
private final int socialId;

public SocialButton(int x, int y, Component text, int textColor, int socialId, OnPress onClick) {
super(new Button.Builder(Component.literal(""), onClick).size(20, 20).pos(x, y));
super(Button.builder(Component.literal(""), onClick).size(20, 20).pos(x, y));
this.textColor = textColor;
this.socialId = socialId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected void init() {
for(Map.Entry<String, double[]> entry : params.presetMap.entrySet()) {
String name = entry.getKey();
double[] preset = entry.getValue();
addRenderableWidget(new Button.Builder(Component.literal(name), __ -> setFromArray(preset)).size(w - p, 20).pos(x + (w * i), y + 115).build());
addRenderableWidget(Button.builder(Component.literal(name), __ -> setFromArray(preset)).size(w - p, 20).pos(x + (w * i), y + 115).build());
i++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public MiniInventoryButton(AbstractContainerScreen<?> parent, int spriteType, in
}

public MiniInventoryButton(AbstractContainerScreen<?> parent, int spriteType, int x, int y, Supplier<List<Component>> tooltip, OnPress onPress) {
super(new Button.Builder(Component.literal(""), onPress).size(10, 10).pos(parent.getGuiLeft() + x, parent.getGuiTop() + y));
super(Button.builder(Component.literal(""), onPress).size(10, 10).pos(parent.getGuiLeft() + x, parent.getGuiTop() + y));
this.parent = parent;
this.spriteType = spriteType;
this.tooltip = tooltip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void tick() {
}

public boolean isVisible(Entity entityIn) {
Vec3 vector3d = new Vec3(getX(), getY() + 1, getZ());
Vec3 vector3d = new Vec3(getX(), getEyeY(), getZ());
Vec3 vector3d1 = new Vec3(entityIn.getX(), entityIn.getEyeY(), entityIn.getZ());
return level().clip(new ClipContext(vector3d, vector3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.client.player.Input;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -21,13 +20,13 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LadderBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;
Expand Down Expand Up @@ -64,10 +63,12 @@ public class EnhancedLaddersModule extends ZetaModule {
@Config
public static boolean allowInventorySneak = true;

private static boolean staticEnabled;
public static boolean staticEnabled;
private static TagKey<Item> laddersTag;
private static TagKey<Block> laddersBlockTag;

private static final DirectionProperty FACING = LadderBlock.FACING;

@LoadEvent
public final void setup(ZCommonSetup event) {
laddersTag = ItemTags.create(new ResourceLocation(Quark.MOD_ID, "ladders"));
Expand Down Expand Up @@ -106,35 +107,23 @@ public void addAdditionalHints(ZGatherHints event) {
event.accept(item, comp);
}

private static boolean canAttachTo(BlockState state, Block ladder, LevelReader world, BlockPos pos, Direction facing) {
if(ladder instanceof LadderBlock) {
if(allowFreestanding)
return canLadderSurvive(state, world, pos);

BlockPos offset = pos.relative(facing);
BlockState blockstate = world.getBlockState(offset);
return !blockstate.isSignalSource() && blockstate.isFaceSturdy(world, offset, facing);
}
// see LadderBlockMixin
public static boolean canSurviveTweak(boolean vanillaSurvive, BlockState state, LevelReader world, BlockPos pos) {
//With the freestanding feature enabled, ladders can survive if they are supported by a block (vanillaSurvive),
//or if they are underneath a ladder on the same wall.
if(vanillaSurvive)
return true;

return false;
}

// replaces ladder survives logic
public static boolean canLadderSurvive(BlockState state, LevelReader world, BlockPos pos) {
if(!staticEnabled || !allowFreestanding)
if(!staticEnabled || !allowFreestanding || !state.is(laddersBlockTag) || !state.hasProperty(FACING))
return false;
if(!state.is(laddersBlockTag))return false;

Direction facing = state.getValue(LadderBlock.FACING);
Direction opposite = facing.getOpposite();
BlockPos oppositePos = pos.relative(opposite);
BlockState oppositeState = world.getBlockState(oppositePos);

boolean solid = oppositeState.isFaceSturdy(world, oppositePos, facing) && !(oppositeState.getBlock() instanceof LadderBlock);
BlockState topState = world.getBlockState(pos.above());
return solid || (topState.getBlock() instanceof LadderBlock && (facing.getAxis() == Axis.Y || topState.getValue(LadderBlock.FACING) == facing));
BlockState aboveState = world.getBlockState(pos.above());
return aboveState.is(laddersBlockTag) && aboveState.hasProperty(FACING) && aboveState.getValue(FACING) == state.getValue(FACING);
}

public static boolean shouldDoUpdateShapeTweak(BlockState state) {
return staticEnabled && allowFreestanding && state.is(laddersBlockTag);
}

@PlayEvent
public void onInteract(ZRightClickBlock event) {
Expand Down Expand Up @@ -164,8 +153,7 @@ public void onInteract(ZRightClickBlock event) {
if(water || stateDown.isAir()) {
BlockState copyState = world.getBlockState(pos);

Direction facing = copyState.getValue(LadderBlock.FACING);
if(canAttachTo(copyState, block, world, posDown, facing.getOpposite())) {
if(copyState.canSurvive(world, posDown)) {
world.setBlockAndUpdate(posDown, copyState.setValue(BlockStateProperties.WATERLOGGED, water));
world.playSound(null, posDown.getX(), posDown.getY(), posDown.getZ(), SoundEvents.LADDER_PLACE, SoundSource.BLOCKS, 1F, 1F);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.violetmoon.quark.mixin.mixins;

import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

/**
* Exists to be subclassed by LadderBlockMixin basically
*/
@Mixin(BlockBehaviour.class)
public class BlockBehaviourMixin {
@Inject(method = "tick", at = @At("HEAD"))
public void quark$tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom, CallbackInfo ci) {

}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
package org.violetmoon.quark.mixin.mixins;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.LadderBlock;
import net.minecraft.world.level.block.state.BlockState;

import org.spongepowered.asm.mixin.Mixin;
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 org.violetmoon.quark.content.tweaks.module.EnhancedLaddersModule;

@Mixin(LadderBlock.class)
public class LadderBlockMixin {

public class LadderBlockMixin extends BlockBehaviourMixin {
@ModifyReturnValue(method = "canSurvive", at = @At("RETURN"))
private boolean canSurviveTweak(boolean original, BlockState state, LevelReader level, BlockPos pos) {
return EnhancedLaddersModule.canSurviveTweak(original, state, level, pos);
}

@Inject(method = "canSurvive", at = @At("HEAD"), cancellable = true)
private void canSurvive(BlockState state, LevelReader level, BlockPos pos, CallbackInfoReturnable<Boolean> callbackInfoReturnable) {
if(EnhancedLaddersModule.canLadderSurvive(state, level, pos)) {
callbackInfoReturnable.setReturnValue(true);
callbackInfoReturnable.cancel();
/**
* In vanilla, the only way to break a ladder is to break the block behind it. So in updateShape,
* vanilla only does ladder canSurvive checks if the update came from behind. But with Quark's
* freestanding ladder feature, it's possible to break a ladder by breaking a block *above* it.
*/
@Inject(method = "updateShape", at = @At(value = "HEAD"), cancellable = true)
private void updateShapeTweak(BlockState pState, Direction pFacing, BlockState pFacingState, LevelAccessor pLevel, BlockPos pCurrentPos, BlockPos pFacingPos, CallbackInfoReturnable<BlockState> cir) {
if(EnhancedLaddersModule.shouldDoUpdateShapeTweak(pState) && pFacing == Direction.UP) {
//This is just for fun. Makes the ladders break like bamboo instead of instantly.
pLevel.scheduleTick(pCurrentPos, (LadderBlock) (Object) this, 1);
cir.setReturnValue(pState);
}
}

/**
* Override from BlockBehaviourMixin which does the actual injection
*/
@Override
public void quark$tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom, CallbackInfo ci) {
if(EnhancedLaddersModule.shouldDoUpdateShapeTweak(pState) && !pState.canSurvive(pLevel, pPos)) {
pLevel.destroyBlock(pPos, true);
}
}
}
4 changes: 0 additions & 4 deletions src/main/resources/assets/quark/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -922,14 +922,11 @@
"block.quark.lavender_blossom_sapling": "Ruheblütensetzling",
"block.quark.orange_blossom_leaves": "Warmblütenlaub",
"block.quark.orange_blossom_sapling": "Warmblütensetzling",
"block.quark.pink_blossom_leaves": "Süßblütenlaub",
"block.quark.pink_blossom_sapling": "Süßblütensetzling",
"block.quark.yellow_blossom_leaves": "Sonnenblütenlaub",
"block.quark.yellow_blossom_sapling": "Sonnenblütensetzling",
"block.quark.red_blossom_leaves": "Feuerblütenlaub",
"block.quark.red_blossom_sapling": "Feuerblütensetzling",
"block.quark.yellow_blossom_leaf_carpet": "Sonnenblütenlaubteppich",
"block.quark.pink_blossom_leaf_carpet": "Süßblütenlaubteppich",
"block.quark.orange_blossom_leaf_carpet": "Warmblütenlaubteppich",
"block.quark.lavender_blossom_leaf_carpet": "Ruheblütenlaubteppich",
"block.quark.blue_blossom_leaf_carpet": "Frostblütenlaubteppich",
Expand Down Expand Up @@ -1144,7 +1141,6 @@
"block.quark.potted_nether_wart": "Eingetopfte Netherwarze",
"block.quark.potted_orange_blossom_sapling": "Eingetopfter Warmblütensetzling",
"block.quark.potted_peony": "Eingetopfte Pfingstrose",
"block.quark.potted_pink_blossom_sapling": "Eingetopfter Süßblütensetzling",
"block.quark.potted_potato": "Eingetopfte Kartoffel",
"block.quark.potted_pumpkin": "Eingetopfter Kürbis",
"block.quark.potted_red_blossom_sapling": "Eingetopfter Feuerblütensetzling",
Expand Down
4 changes: 0 additions & 4 deletions src/main/resources/assets/quark/lang/en_gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -851,12 +851,9 @@
"block.quark.lavender_blossom_sapling": "Serene Blossom Sapling",
"block.quark.orange_blossom_leaves": "Warm Blossom Leaves",
"block.quark.orange_blossom_sapling": "Warm Blossom Sapling",
"block.quark.pink_blossom_leaves": "Sweet Blossom Leaves",
"block.quark.pink_blossom_sapling": "Sweet Blossom Sapling",
"block.quark.yellow_blossom_leaves": "Sunny Blossom Leaves",
"block.quark.yellow_blossom_sapling": "Sunny Blossom Sapling",
"block.quark.yellow_blossom_leaf_carpet": "Sunny Blossom Leaf Carpet",
"block.quark.pink_blossom_leaf_carpet": "Sweet Blossom Leaf Carpet",
"block.quark.orange_blossom_leaf_carpet": "Warm Blossom Leaf Carpet",
"block.quark.lavender_blossom_leaf_carpet": "Serene Blossom Leaf Carpet",
"block.quark.blue_blossom_leaf_carpet": "Frosty Blossom Leaf Carpet",
Expand Down Expand Up @@ -924,7 +921,6 @@
"block.quark.potted_nether_wart": "Potted Nether Wart",
"block.quark.potted_orange_blossom_sapling": "Potted Warm Blossom Sapling",
"block.quark.potted_peony": "Potted Peony",
"block.quark.potted_pink_blossom_sapling": "Potted Sweet Blossom Sapling",
"block.quark.potted_potato": "Potted Potatoes",
"block.quark.potted_pumpkin": "Potted Pumpkin",
"block.quark.potted_rose": "Potted Rose",
Expand Down
5 changes: 0 additions & 5 deletions src/main/resources/assets/quark/lang/en_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -787,14 +787,11 @@
"block.quark.lavender_blossom_sapling": "Serene Blossom Sapling",
"block.quark.orange_blossom_leaves": "Warm Blossom Leaves",
"block.quark.orange_blossom_sapling": "Warm Blossom Sapling",
"block.quark.pink_blossom_leaves": "Sweet Blossom Leaves",
"block.quark.pink_blossom_sapling": "Sweet Blossom Sapling",
"block.quark.yellow_blossom_leaves": "Sunny Blossom Leaves",
"block.quark.yellow_blossom_sapling": "Sunny Blossom Sapling",
"block.quark.red_blossom_leaves": "Fiery Blossom Leaves",
"block.quark.red_blossom_sapling": "Fiery Blossom Sapling",
"block.quark.yellow_blossom_leaf_carpet": "Sunny Blossom Leaf Carpet",
"block.quark.pink_blossom_leaf_carpet": "Sweet Blossom Leaf Carpet",
"block.quark.orange_blossom_leaf_carpet": "Warm Blossom Leaf Carpet",
"block.quark.lavender_blossom_leaf_carpet": "Serene Blossom Leaf Carpet",
"block.quark.blue_blossom_leaf_carpet": "Frosty Blossom Leaf Carpet",
Expand Down Expand Up @@ -932,7 +929,6 @@
"block.quark.blue_blossom_hedge": "Shrubbery o' Frosty Flowers",
"block.quark.lavender_blossom_hedge": "Shrubbery o' Lavenderrrrr Flowers",
"block.quark.orange_blossom_hedge": "Shrubbery o' Summer Flowers",
"block.quark.pink_blossom_hedge": "Shrubbery o' Hearty Flowers",
"block.quark.yellow_blossom_hedge": "Shrubbery o' Sunny Flowers",
"block.quark.red_blossom_hedge": "Shrubbery o' Flamin' Flowers",
"block.quark.matrix_enchanter": "Jigsawin' Witchcraft Bench",
Expand Down Expand Up @@ -1103,7 +1099,6 @@
"block.quark.potted_nether_wart": "Captive Wart",
"block.quark.potted_orange_blossom_sapling": "Captive Summer meager shrub",
"block.quark.potted_peony": "Captive Peony",
"block.quark.potted_pink_blossom_sapling": "Captive Hearty meager shrub",
"block.quark.potted_potato": "Captive Potatoes",
"block.quark.potted_pumpkin": "Captive Gourd",
"block.quark.potted_red_blossom_sapling": "Captive Flamin' meager shrub",
Expand Down
Loading

0 comments on commit 14769bd

Please sign in to comment.