Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/zeta120' into zeta120
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/org/violetmoon/quark/base/client/config/QButtonHandler.java
  • Loading branch information
Siuolplex committed Dec 16, 2023
2 parents 09ba575 + fa7ae09 commit 8052cdc
Show file tree
Hide file tree
Showing 630 changed files with 8,583 additions and 7,542 deletions.
2 changes: 1 addition & 1 deletion spotless/eclipse.importorder
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
9=\#
8=java
7=javax
6=vazkii
6=org.violetmoon
5=top
4=org
3=net
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/violetmoon/quark/QuarkForgeCapabilities.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package org.violetmoon.quark;

import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken;

import org.violetmoon.quark.api.ICustomSorting;
import org.violetmoon.quark.api.IMagnetTracker;
import org.violetmoon.quark.api.IPistonCallback;
import org.violetmoon.quark.api.IRuneColorProvider;
import org.violetmoon.quark.api.ITransferManager;

import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken;

//TODO: put this somewhere in a Forge-only API package
// TODO: put this somewhere in a Forge-only API package
public class QuarkForgeCapabilities {
public static final Capability<ICustomSorting> SORTING = CapabilityManager.get(new CapabilityToken<>(){});
public static final Capability<ICustomSorting> SORTING = CapabilityManager.get(new CapabilityToken<>() {});

public static final Capability<ITransferManager> TRANSFER = CapabilityManager.get(new CapabilityToken<>(){});
public static final Capability<ITransferManager> TRANSFER = CapabilityManager.get(new CapabilityToken<>() {});

public static final Capability<IPistonCallback> PISTON_CALLBACK = CapabilityManager.get(new CapabilityToken<>(){});
public static final Capability<IPistonCallback> PISTON_CALLBACK = CapabilityManager.get(new CapabilityToken<>() {});

public static final Capability<IMagnetTracker> MAGNET_TRACKER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){});
public static final Capability<IMagnetTracker> MAGNET_TRACKER_CAPABILITY = CapabilityManager.get(new CapabilityToken<>() {});

public static final Capability<IRuneColorProvider> RUNE_COLOR = CapabilityManager.get(new CapabilityToken<>(){});
public static final Capability<IRuneColorProvider> RUNE_COLOR = CapabilityManager.get(new CapabilityToken<>() {});
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package org.violetmoon.quark.addons.oddities.block;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
Expand All @@ -28,6 +25,10 @@
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.network.NetworkHooks;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import org.violetmoon.quark.addons.oddities.block.be.CrateBlockEntity;
import org.violetmoon.quark.addons.oddities.module.CrateModule;
import org.violetmoon.zeta.block.ZetaBlock;
Expand Down Expand Up @@ -68,7 +69,6 @@ public MenuProvider getMenuProvider(@NotNull BlockState state, Level level, @Not
return be instanceof MenuProvider provider ? provider : null;
}


@NotNull
@Override
public InteractionResult use(@NotNull BlockState state, Level worldIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) {
Expand Down Expand Up @@ -100,7 +100,7 @@ public void setPlacedBy(@NotNull Level worldIn, @NotNull BlockPos pos, @NotNull
public void tick(@NotNull BlockState state, ServerLevel worldIn, @NotNull BlockPos pos, @NotNull RandomSource rand) {
BlockEntity tileentity = worldIn.getBlockEntity(pos);
if(tileentity instanceof CrateBlockEntity)
((CrateBlockEntity)tileentity).crateTick();
((CrateBlockEntity) tileentity).crateTick();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package org.violetmoon.quark.addons.oddities.block;

import java.util.List;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -29,13 +24,19 @@
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.material.PushReaction;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import org.violetmoon.quark.addons.oddities.block.be.MagnetBlockEntity;
import org.violetmoon.quark.addons.oddities.block.be.MagnetizedBlockBlockEntity;
import org.violetmoon.quark.addons.oddities.magnetsystem.MagnetSystem;
import org.violetmoon.quark.addons.oddities.module.MagnetsModule;
import org.violetmoon.zeta.block.ZetaBlock;
import org.violetmoon.zeta.module.ZetaModule;

import java.util.List;

public class MagnetBlock extends ZetaBlock implements EntityBlock {

public static final DirectionProperty FACING = BlockStateProperties.FACING;
Expand All @@ -52,7 +53,7 @@ public MagnetBlock(@Nullable ZetaModule module) {

@Override
public void appendHoverText(@NotNull ItemStack stack, @Nullable BlockGetter worldIn, @NotNull List<Component> tooltip, @NotNull TooltipFlag flagIn) {
if (stack.getHoverName().getString().equals("Q"))
if(stack.getHoverName().getString().equals("Q"))
tooltip.add(Component.literal("haha yes"));
}

Expand Down Expand Up @@ -81,28 +82,28 @@ public boolean triggerEvent(BlockState state, Level world, BlockPos pos, int act
BlockState targetState = world.getBlockState(targetPos);

BlockEntity tile = world.getBlockEntity(pos);
if (!(tile instanceof MagnetBlockEntity be))
if(!(tile instanceof MagnetBlockEntity be))
return false;

BlockPos endPos = targetPos.relative(moveDir);
PushReaction reaction = MagnetSystem.getPushAction(be, targetPos, targetState, moveDir);
if (reaction != PushReaction.IGNORE && reaction != PushReaction.DESTROY)
if(reaction != PushReaction.IGNORE && reaction != PushReaction.DESTROY)
return false;

BlockEntity tilePresent = world.getBlockEntity(targetPos);
CompoundTag tileData = new CompoundTag();
if (tilePresent != null && !(tilePresent instanceof MagnetizedBlockBlockEntity))
if(tilePresent != null && !(tilePresent instanceof MagnetizedBlockBlockEntity))
tileData = tilePresent.saveWithFullMetadata();

BlockState setState = MagnetsModule.magnetized_block.defaultBlockState().setValue(MovingMagnetizedBlock.FACING, moveDir);
MagnetizedBlockBlockEntity movingTile = new MagnetizedBlockBlockEntity(endPos, setState, targetState, tileData, moveDir);

if (!world.isClientSide && reaction == PushReaction.DESTROY) {
if(!world.isClientSide && reaction == PushReaction.DESTROY) {
BlockState blockstate = world.getBlockState(endPos);
Block.dropResources(blockstate, world, endPos, tilePresent);
}

if (tilePresent != null)
if(tilePresent != null)
tilePresent.setRemoved();

world.setBlock(endPos, setState, 68);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
package org.violetmoon.quark.addons.oddities.block;

import java.util.function.BooleanSupplier;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;
import org.violetmoon.quark.addons.oddities.block.be.MatrixEnchantingTableBlockEntity;
import org.violetmoon.quark.addons.oddities.module.MatrixEnchantingModule;
import org.violetmoon.quark.api.IEnchantmentInfluencer;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.zeta.block.IZetaBlock;
import org.violetmoon.zeta.module.ZetaModule;

import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.DustParticleOptions;
import net.minecraft.core.particles.ParticleOptions;
Expand All @@ -34,8 +22,21 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.network.NetworkHooks;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;

import org.violetmoon.quark.addons.oddities.block.be.MatrixEnchantingTableBlockEntity;
import org.violetmoon.quark.addons.oddities.module.MatrixEnchantingModule;
import org.violetmoon.quark.api.IEnchantmentInfluencer;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.zeta.block.IZetaBlock;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.util.BooleanSuppliers;

import java.util.function.BooleanSupplier;

public class MatrixEnchantingTableBlock extends EnchantmentTableBlock implements IZetaBlock {

private final ZetaModule module;
Expand Down Expand Up @@ -113,38 +114,38 @@ public void animateTick(@NotNull BlockState stateIn, @NotNull Level worldIn, @No
BlockPos blockpos = pos.offset(i, k, j);
BlockState state = worldIn.getBlockState(blockpos);
BlockPos test = pos.offset(i / 2, 0, j / 2);
if(!(worldIn.isEmptyBlock(test)
if(!(worldIn.isEmptyBlock(test)
|| (allowUnderwater && worldIn.getBlockState(test).getBlock() == Blocks.WATER)
|| (allowShort && MatrixEnchantingTableBlockEntity.isShortBlock(worldIn, test))))
break;

if(showInfluences) {
IEnchantmentInfluencer influencer = MatrixEnchantingTableBlockEntity.getInfluencerFromBlock(state, worldIn, blockpos);

if (influencer != null) {
if(influencer != null) {
float[] comp = influencer.getEnchantmentInfluenceColor(worldIn, blockpos, state);
ParticleOptions extra = influencer.getExtraParticleOptions(worldIn, blockpos, state);
double chance = influencer.getExtraParticleChance(worldIn, blockpos, state);

if (comp != null || extra != null) {
if(comp != null || extra != null) {
int steps = 20;
double dx = (double) (pos.getX() - blockpos.getX()) / steps;
double dy = (double) (pos.getY() - blockpos.getY()) / steps;
double dz = (double) (pos.getZ() - blockpos.getZ()) / steps;

for (int p = 0; p < steps; p++) {
for(int p = 0; p < steps; p++) {
boolean doDust = comp != null && rand.nextDouble() < 0.5;
boolean doExtra = extra != null && rand.nextDouble() < chance;
if (!doDust && !doExtra)
if(!doDust && !doExtra)
continue;

double px = blockpos.getX() + 0.5 + dx * p + rand.nextDouble() * 0.2 - 0.1;
double py = blockpos.getY() + 0.5 + dy * p + Math.sin((double) p / steps * Math.PI) * 0.5 + rand.nextDouble() * 0.2 - 0.1;
double pz = blockpos.getZ() + 0.5 + dz * p + rand.nextDouble() * 0.2 - 0.1;

if (doDust)
if(doDust)
worldIn.addParticle(new DustParticleOptions(new Vector3f(comp[0], comp[1], comp[2]), 1F), px, py, pz, 0, 0, 0);
if (doExtra)
if(doExtra)
worldIn.addParticle(extra, px, py, pz, 0, 0, 0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import org.violetmoon.quark.addons.oddities.block.be.MagnetizedBlockBlockEntity;
import org.violetmoon.quark.addons.oddities.module.MagnetsModule;
import org.violetmoon.zeta.block.OldMaterials;
Expand All @@ -36,7 +38,7 @@

/**
* @author WireSegal
* Created at 3:05 PM on 2/26/20.
* Created at 3:05 PM on 2/26/20.
*/
public class MovingMagnetizedBlock extends ZetaBlock implements EntityBlock {
public static final DirectionProperty FACING = PistonHeadBlock.FACING;
Expand All @@ -54,9 +56,9 @@ public RenderShape getRenderShape(@NotNull BlockState state) {

@Override
public void onRemove(BlockState state, @NotNull Level worldIn, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) {
if (state.getBlock() != newState.getBlock()) {
if(state.getBlock() != newState.getBlock()) {
MagnetizedBlockBlockEntity tile = getMagnetTileEntity(worldIn, pos);
if (tile != null)
if(tile != null)
tile.clearMagnetTileEntity();
}
}
Expand All @@ -69,7 +71,7 @@ public boolean useShapeForLightOcclusion(@NotNull BlockState state) {
@NotNull
@Override
public InteractionResult use(@NotNull BlockState state, Level worldIn, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand handIn, @NotNull BlockHitResult hit) {
if (!worldIn.isClientSide && worldIn.getBlockEntity(pos) == null) {
if(!worldIn.isClientSide && worldIn.getBlockEntity(pos) == null) {
worldIn.removeBlock(pos, false);
return InteractionResult.SUCCESS;
} else
Expand Down Expand Up @@ -99,7 +101,7 @@ public VoxelShape getCollisionShape(@NotNull BlockState state, @NotNull BlockGet
@Nullable
private MagnetizedBlockBlockEntity getMagnetTileEntity(BlockGetter world, BlockPos pos) {
BlockEntity tile = world.getBlockEntity(pos);
return tile instanceof MagnetizedBlockBlockEntity ? (MagnetizedBlockBlockEntity)tile : null;
return tile instanceof MagnetizedBlockBlockEntity ? (MagnetizedBlockBlockEntity) tile : null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package org.violetmoon.quark.addons.oddities.block;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
Expand All @@ -29,7 +26,6 @@
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
Expand All @@ -41,6 +37,10 @@
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import org.violetmoon.quark.addons.oddities.block.be.TinyPotatoBlockEntity;
import org.violetmoon.quark.addons.oddities.item.TinyPotatoBlockItem;
import org.violetmoon.quark.addons.oddities.module.TinyPotatoModule;
Expand All @@ -52,7 +52,7 @@

/**
* @author WireSegal
* Created at 10:16 AM on 3/14/22.
* Created at 10:16 AM on 3/14/22.
*/
public class TinyPotatoBlock extends ZetaBlock implements SimpleWaterloggedBlock, EntityBlock, IZetaBlockItemProvider {

Expand Down Expand Up @@ -102,9 +102,9 @@ public FluidState getFluidState(BlockState state) {

@Override
public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) {
if (!state.is(newState.getBlock())) {
if(!state.is(newState.getBlock())) {
BlockEntity be = world.getBlockEntity(pos);
if (be instanceof TinyPotatoBlockEntity inventory) {
if(be instanceof TinyPotatoBlockEntity inventory) {
Containers.dropContents(world, pos, inventory);
}
super.onRemove(state, world, pos, newState, isMoving);
Expand All @@ -116,11 +116,11 @@ public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull B
public ItemStack getCloneItemStack(BlockGetter level, BlockPos pos, BlockState state) {
ItemStack stack = super.getCloneItemStack(level, pos, state);
BlockEntity be = level.getBlockEntity(pos);
if (be instanceof TinyPotatoBlockEntity tater) {
if (tater.hasCustomName())
if(be instanceof TinyPotatoBlockEntity tater) {
if(tater.hasCustomName())
stack.setHoverName(tater.getCustomName());

if (tater.angry)
if(tater.angry)
ItemNBTHelper.setBoolean(stack, ANGRY, true);
}
return stack;
Expand All @@ -136,13 +136,13 @@ public VoxelShape getShape(@NotNull BlockState state, @NotNull BlockGetter world
@Override
public InteractionResult use(@NotNull BlockState state, Level world, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand hand, @NotNull BlockHitResult hit) {
BlockEntity be = world.getBlockEntity(pos);
if (be instanceof TinyPotatoBlockEntity tater) {
if(be instanceof TinyPotatoBlockEntity tater) {
tater.interact(player, hand, player.getItemInHand(hand), hit.getDirection());

if(player instanceof ServerPlayer sp)
TinyPotatoModule.patPotatoTrigger.trigger(sp);

if (!world.isClientSide) {
if(!world.isClientSide) {
AABB box = SHAPE.bounds();
((ServerLevel) world).sendParticles(ParticleTypes.HEART, pos.getX() + box.minX + Math.random() * (box.maxX - box.minX), pos.getY() + box.maxY, pos.getZ() + box.minZ + Math.random() * (box.maxZ - box.minZ), 1, 0, 0, 0, 0);
}
Expand All @@ -161,7 +161,7 @@ public BlockState getStateForPlacement(@NotNull BlockPlaceContext ctx) {
@NotNull
@Override
public BlockState updateShape(BlockState state, @NotNull Direction facing, @NotNull BlockState facingState, @NotNull LevelAccessor level, @NotNull BlockPos pos, @NotNull BlockPos facingPos) {
if (state.getValue(WATERLOGGED)) {
if(state.getValue(WATERLOGGED)) {
level.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
}

Expand All @@ -172,10 +172,10 @@ public BlockState updateShape(BlockState state, @NotNull Direction facing, @NotN
public void setPlacedBy(@NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity living, ItemStack stack) {
boolean hasCustomName = stack.hasCustomHoverName();
boolean isAngry = isAngry(stack);
if (hasCustomName || isAngry) {
if(hasCustomName || isAngry) {
BlockEntity be = world.getBlockEntity(pos);
if (be instanceof TinyPotatoBlockEntity tater) {
if (hasCustomName)
if(be instanceof TinyPotatoBlockEntity tater) {
if(hasCustomName)
tater.name = stack.getHoverName();
tater.angry = isAngry(stack);
}
Expand Down
Loading

0 comments on commit 8052cdc

Please sign in to comment.