added magnifier
This commit is contained in:
@@ -91,17 +91,10 @@ public class BlockDrill extends FallingBlock implements EntityBlock {
|
||||
loadings.put(QuicklyItems.CANOLABOTTLE, 8);
|
||||
loadings.put(QuicklyItems.CANOLABOTTLESTACK, 72);
|
||||
Item item = itemStack.getItem();
|
||||
if (itemStack.isEmpty()) {
|
||||
if (QuicklyItems.MAGNIFIER.equals(item)) {
|
||||
if (!level.isClientSide() && player instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.sendSystemMessage(Component.translatable("info.block.drillfuel", state.getValue(FUEL)), false);
|
||||
}
|
||||
} else if (QuicklyItems.COPPERSTICK.equals(item)) {
|
||||
Direction newDirection = hitResult.getDirection();
|
||||
newDirection = newDirection.equals(Direction.UP) ? Direction.DOWN : newDirection;
|
||||
Integer fuelLeft = state.getValue(FUEL);
|
||||
level.addFreshEntity(
|
||||
new ItemEntity(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(QuicklyItems.CANOLABOTTLE, fuelLeft)));
|
||||
level.setBlockAndUpdate(pos, QuicklyBlocks.DRILL.defaultBlockState().setValue(FACING, newDirection));
|
||||
} else if (loadings.containsKey(item)) {
|
||||
Integer fuelWeight = loadings.get(item);
|
||||
if (fuelWeight != null) {
|
||||
@@ -119,6 +112,13 @@ public class BlockDrill extends FallingBlock implements EntityBlock {
|
||||
}
|
||||
player.getActiveItem().shrink(1);
|
||||
}
|
||||
} else {
|
||||
Direction newDirection = hitResult.getDirection();
|
||||
newDirection = newDirection.equals(Direction.UP) ? Direction.DOWN : newDirection;
|
||||
Integer fuelLeft = state.getValue(FUEL);
|
||||
level.addFreshEntity(
|
||||
new ItemEntity(level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(QuicklyItems.CANOLABOTTLE, fuelLeft)));
|
||||
level.setBlockAndUpdate(pos, QuicklyBlocks.DRILL.defaultBlockState().setValue(FACING, newDirection));
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ import java.util.List;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import de.jottyfan.minecraft.blockentity.ItemHoarderBlockEntity;
|
||||
import de.jottyfan.minecraft.item.QuicklyItems;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -52,21 +54,22 @@ public class Itemhoarder extends Block implements EntityBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player,
|
||||
BlockHitResult hitResult) {
|
||||
MutableComponent message = Component.empty();
|
||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
if (blockEntity instanceof ItemHoarderBlockEntity) {
|
||||
ItemHoarderBlockEntity ihbe = (ItemHoarderBlockEntity) blockEntity;
|
||||
for (ItemStack stack : ihbe.getStacks().values()) {
|
||||
MutableComponent line = Component.literal(stack.getCount() + "x ").append(stack.getHoverName());
|
||||
message.append(Component.literal("\n")).append(line);
|
||||
}
|
||||
}
|
||||
|
||||
Component complete = Component.translatable("info.block.itemhoarder", message);
|
||||
protected InteractionResult useItemOn(ItemStack itemStack, BlockState state, Level level, BlockPos pos, Player player,
|
||||
InteractionHand hand, BlockHitResult hitResult) {
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.displayClientMessage(complete, false);
|
||||
if (QuicklyItems.MAGNIFIER.equals(itemStack.getItem())) {
|
||||
MutableComponent message = Component.empty();
|
||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
if (blockEntity instanceof ItemHoarderBlockEntity) {
|
||||
ItemHoarderBlockEntity ihbe = (ItemHoarderBlockEntity) blockEntity;
|
||||
for (ItemStack stack : ihbe.getStacks().values()) {
|
||||
MutableComponent line = Component.literal(stack.getCount() + "x ").append(stack.getHoverName());
|
||||
message.append(Component.literal("\n")).append(line);
|
||||
}
|
||||
}
|
||||
Component complete = Component.translatable("info.block.itemhoarder", message);
|
||||
serverPlayer.displayClientMessage(complete, false);
|
||||
}
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ public class QuicklyItems {
|
||||
public static final Item QUICKIEPOWDER = registerItem("quickiepowder");
|
||||
public static final Item SPEEDINGOT = registerItem("speedingot");
|
||||
public static final Item QUICKIEINGOT = registerItem("quickieingot");
|
||||
public static final Item MAGNIFIER = registerItem("magnifier");
|
||||
|
||||
// TODO: salpeter, sulfor
|
||||
// TODO: carrot stack
|
||||
@@ -98,6 +99,7 @@ public class QuicklyItems {
|
||||
item.accept(COPPERSTRING);
|
||||
item.accept(COPPERSTICK);
|
||||
item.accept(COPPERSTUB);
|
||||
item.accept(MAGNIFIER);
|
||||
item.accept(ARMOR_TURQUOISE_HELMET);
|
||||
item.accept(ARMOR_TURQUOISE_CHESTPLATE);
|
||||
item.accept(ARMOR_TURQUOISE_LEGGINGS);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class QuicklyTab {
|
||||
|
||||
public static final void registerItemGroup() {
|
||||
Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, QUICKLY_TAB,
|
||||
FabricItemGroup.builder().icon(() -> new ItemStack(QuicklyItems.STUB))
|
||||
FabricItemGroup.builder().icon(() -> new ItemStack(QuicklyItems.QUICKIEPOWDER))
|
||||
.title(Component.translatable("tab." + Quickly.MOD_ID)).build());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user