gambling 1 - slot machine

This commit is contained in:
2026-02-28 18:52:39 +01:00
parent ab2c60db79
commit 5a79447622
48 changed files with 1159 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10 yarn_mappings=1.20.1+build.10
loader_version=0.18.3 loader_version=0.18.3
# Mod Properties # Mod Properties
mod_version=26.2.27.1 mod_version=26.2.28
maven_group=dev.tggamesyt maven_group=dev.tggamesyt
archives_base_name=szar archives_base_name=szar
# Dependencies # Dependencies

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,149 @@
package dev.tggamesyt.szar.client;
import com.mojang.blaze3d.systems.RenderSystem;
import dev.tggamesyt.szar.SlotMachineBlockEntity;
import dev.tggamesyt.szar.SlotMachineScreenHandler;
import dev.tggamesyt.szar.Szar;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import dev.tggamesyt.szar.SlotSymbol;
public class SlotMachineScreen extends HandledScreen<SlotMachineScreenHandler> {
private static final Identifier BG_TEXTURE =
new Identifier(Szar.MOD_ID, "textures/gui/slot_machine.png");
private static final Identifier HANDLE_1 =
new Identifier(Szar.MOD_ID, "textures/gui/handle1.png");
private static final Identifier HANDLE_2 =
new Identifier(Szar.MOD_ID, "textures/gui/handle2.png");
private static final Identifier HANDLE_3 =
new Identifier(Szar.MOD_ID, "textures/gui/handle3.png");
private final int handleX = 120;
private final int handleY = 20;
private boolean handleClicked = false;
private int handleAnimTicks = 0;
private Identifier currentHandleTexture = HANDLE_1;
public SlotMachineScreen(SlotMachineScreenHandler handler,
PlayerInventory inventory,
Text title) {
super(handler, inventory, title);
this.backgroundWidth = 176;
this.backgroundHeight = 166;
}
// ----------------------------
// BACKGROUND
// ----------------------------
@Override
protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) {
int guiLeft = (width - backgroundWidth) / 2;
int guiTop = (height - backgroundHeight) / 2;
context.drawTexture(BG_TEXTURE, guiLeft, guiTop,
0, 0, backgroundWidth, backgroundHeight);
drawReels(context, guiLeft, guiTop);
}
private void drawReels(DrawContext context, int guiLeft, int guiTop) {
SlotMachineBlockEntity be = handler.blockEntity;
if (be == null) return;
int reelX = guiLeft + 70;
int reelY = guiTop + 35;
for (int i = 0; i < 3; i++) {
int idx = be.getSymbol(i);
if (idx < 0 || idx >= SlotSymbol.values().length)
idx = 0;
SlotSymbol symbol = SlotSymbol.values()[idx];
ItemStack stack = new ItemStack(symbol.item);
context.drawItem(stack, reelX + i * 18, reelY);
}
}
// ----------------------------
// RENDER
// ----------------------------
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context);
super.render(context, mouseX, mouseY, delta);
if (client != null && client.player != null) {
handler.tick(client.player);
}
drawMouseoverTooltip(context, mouseX, mouseY);
int guiLeft = (width - backgroundWidth) / 2;
int guiTop = (height - backgroundHeight) / 2;
// Handle animation
if (handleClicked) {
handleAnimTicks++;
if (handleAnimTicks < 5) {
currentHandleTexture = HANDLE_2;
} else if (handleAnimTicks < 10) {
currentHandleTexture = HANDLE_3;
} else {
currentHandleTexture = HANDLE_1;
handleClicked = false;
handleAnimTicks = 0;
// CALL SCREEN HANDLER LOGIC HERE
if (client != null && client.player != null && client.interactionManager != null) {
client.interactionManager.clickButton(handler.syncId, 0);
}
}
}
// Draw handle
context.drawTexture(currentHandleTexture,
guiLeft + handleX,
guiTop + handleY,
0, 0,
32, 32,
32, 32);
}
// ----------------------------
// MOUSE
// ----------------------------
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
int guiLeft = (width - backgroundWidth) / 2;
int guiTop = (height - backgroundHeight) / 2;
double relX = mouseX - (guiLeft + handleX);
double relY = mouseY - (guiTop + handleY);
if (relX >= 0 && relX <= 32 && relY >= 0 && relY <= 32) {
handleClicked = true;
handleAnimTicks = 0;
return true;
}
return super.mouseClicked(mouseX, mouseY, button);
}
}

View File

@@ -9,12 +9,15 @@ import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallba
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry; import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry; import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.HandledScreens;
import net.minecraft.client.option.KeyBinding; import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.render.entity.FlyingItemEntityRenderer; import net.minecraft.client.render.entity.FlyingItemEntityRenderer;
import net.minecraft.client.render.entity.animation.Animation; import net.minecraft.client.render.entity.animation.Animation;
@@ -86,6 +89,7 @@ public class SzarClient implements ClientModInitializer {
}); });
ThirdpersonModelRegisterer.register(new Identifier(MOD_ID, "weed_joint"), new Identifier(MOD_ID, "weed_joint_in_hand")); ThirdpersonModelRegisterer.register(new Identifier(MOD_ID, "weed_joint"), new Identifier(MOD_ID, "weed_joint_in_hand"));
ThirdpersonModelRegisterer.register(new Identifier(MOD_ID, "fasz"), new Identifier(MOD_ID, "fasz_in_hand")); ThirdpersonModelRegisterer.register(new Identifier(MOD_ID, "fasz"), new Identifier(MOD_ID, "fasz_in_hand"));
ThirdpersonModelRegisterer.register(new Identifier(MOD_ID, "slot_machine"), new Identifier(MOD_ID, "slot_machine_3d"));
ClientTickEvents.END_CLIENT_TICK.register(client -> { ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (client.player == null) return; if (client.player == null) return;
@@ -224,6 +228,12 @@ public class SzarClient implements ClientModInitializer {
}); });
} }
); );
/*BlockEntityRendererRegistry.register(
SLOT_MACHINE_BLOCKENTITY,
SlotMachineRenderer::new
);*/
HandledScreens.register(Szar.SLOT_MACHINE_SCREEN_HANDLER_TYPE, SlotMachineScreen::new);
EntityRendererRegistry.register( EntityRendererRegistry.register(
Szar.NiggerEntityType, Szar.NiggerEntityType,
NiggerEntityRenderer::new NiggerEntityRenderer::new

View File

@@ -0,0 +1,165 @@
package dev.tggamesyt.szar;
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
import net.minecraft.block.*;
import net.minecraft.block.entity.*;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.text.Text;
import net.minecraft.util.*;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.*;
import net.minecraft.util.shape.*;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
public class SlotMachineBlock extends Block implements BlockEntityProvider {
public static final DirectionProperty FACING = Properties.HORIZONTAL_FACING;
public SlotMachineBlock(Settings settings) {
super(settings);
setDefaultState(getStateManager().getDefaultState().with(FACING, Direction.NORTH));
}
// ===== YOUR SHAPES =====
VoxelShape shape0 = VoxelShapes.cuboid(0.25f, 0f, 0.625f, 1f, 1.5f, 1f);
VoxelShape shape1 = VoxelShapes.cuboid(0.25f, 0f, 0.25f, 1f, 0.75f, 0.625f);
VoxelShape shape2 = VoxelShapes.cuboid(0.25f, 1.375f, 0.5625f, 1f, 1.5f, 0.625f);
VoxelShape shape3 = VoxelShapes.cuboid(0.75f, 0.75f, 0.3125f, 0.875f, 0.8125f, 0.4375f);
VoxelShape shape4 = VoxelShapes.cuboid(0.5f, 0.75f, 0.3125f, 0.625f, 0.8125f, 0.4375f);
VoxelShape shape5 = VoxelShapes.cuboid(0.0625f, 1f, 0.5f, 0.25f, 1.1875f, 0.6875f);
VoxelShape shape6 = VoxelShapes.cuboid(0.125f, 0.5625f, 0.5625f, 0.1875f, 1f, 0.625f);
VoxelShape shape7 = VoxelShapes.cuboid(0.125f, 0.4375f, 0.5625f, 0.25f, 0.5625f, 0.625f);
VoxelShape BASE_SHAPE = VoxelShapes.union(shape0, shape1, shape2, shape3, shape4, shape5, shape6, shape7);
private static VoxelShape rotateShape(Direction from, Direction to, VoxelShape shape) {
VoxelShape[] buffer = new VoxelShape[]{shape, VoxelShapes.empty()};
int times = (to.getHorizontal() - from.getHorizontal() + 4) % 4;
for (int i = 0; i < times; i++) {
buffer[0].forEachBox((minX, minY, minZ, maxX, maxY, maxZ) ->
buffer[1] = VoxelShapes.union(buffer[1],
VoxelShapes.cuboid(1 - maxZ, minY, minX, 1 - minZ, maxY, maxX))
);
buffer[0] = buffer[1];
buffer[1] = VoxelShapes.empty();
}
return buffer[0];
}
@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return rotateShape(Direction.NORTH, state.get(FACING), BASE_SHAPE);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return getCollisionShape(state, world, pos, context);
}
// ===== ROTATION =====
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return getDefaultState().with(FACING, ctx.getHorizontalPlayerFacing().getOpposite());
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(FACING);
}
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new SlotMachineBlockEntity(pos, state);
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos,
PlayerEntity player, Hand hand, BlockHitResult hit) {
if (hand != Hand.MAIN_HAND) return ActionResult.PASS;
BlockEntity blockEntity = world.getBlockEntity(pos);
if (!(blockEntity instanceof SlotMachineBlockEntity be)) {
return ActionResult.PASS;
}
Vec3d hitVec = hit.getPos().subtract(pos.getX(), pos.getY(), pos.getZ());
Direction facing = state.get(FACING);
double x = hitVec.x;
double y = hitVec.y;
double z = hitVec.z;
// Rotate based on facing (proper Minecraft rotation logic)
switch (facing) {
case NORTH -> {
// no change
}
case SOUTH -> {
x = 1 - x;
z = 1 - z;
}
case WEST -> {
double temp = x;
x = z;
z = 1 - temp;
}
case EAST -> {
double temp = x;
x = 1 - z;
z = temp;
}
}
boolean isHandle =
x >= 0.0625 && x <= 0.25 &&
y >= 0.5 && y <= 0.6875 &&
z >= 0.4375 && z <= 1.1875;
if (!world.isClient) {
// Open the GUI (client will receive block position)
player.openHandledScreen(state.createScreenHandlerFactory(world, pos));
}
return ActionResult.SUCCESS;
}
@Override
public NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) {
BlockEntity be = world.getBlockEntity(pos);
if (!(be instanceof SlotMachineBlockEntity slotBe)) return null;
// Return an ExtendedScreenHandlerFactory that sends the BlockPos to the client
return new ExtendedScreenHandlerFactory() {
@Override
public void writeScreenOpeningData(ServerPlayerEntity player, PacketByteBuf buf) {
buf.writeBlockPos(pos); // send the block pos to client for the constructor
}
@Override
public Text getDisplayName() {
return Text.literal("Slot Machine");
}
@Override
public ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player) {
return new SlotMachineScreenHandler(syncId, inv, slotBe);
}
};
}
}

View File

@@ -0,0 +1,68 @@
package dev.tggamesyt.szar;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import java.util.Random;
public class SlotMachineBlockEntity extends BlockEntity {
public final int[] currentSymbol = new int[3];
public static final int TOTAL_SYMBOLS = 7;
public SlotMachineBlockEntity(BlockPos pos, BlockState state) {
super(Szar.SLOT_MACHINE_BLOCKENTITY, pos, state);
}
public void setSymbols(int s0, int s1, int s2) {
currentSymbol[0] = s0;
currentSymbol[1] = s1;
currentSymbol[2] = s2;
markDirty();
if (world != null && !world.isClient) {
world.updateListeners(pos, getCachedState(), getCachedState(), 3);
}
}
public int getSymbol(int i) {
return currentSymbol[i];
}
@Override
public void writeNbt(NbtCompound nbt) {
super.writeNbt(nbt);
for (int i = 0; i < 3; i++) {
nbt.putInt("Symbol" + i, currentSymbol[i]);
}
}
@Override
public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);
for (int i = 0; i < 3; i++) {
currentSymbol[i] = nbt.getInt("Symbol" + i);
}
}
@Override
public Packet<ClientPlayPacketListener> toUpdatePacket() {
return BlockEntityUpdateS2CPacket.create(this);
}
@Override
public NbtCompound toInitialChunkDataNbt() {
NbtCompound nbt = new NbtCompound();
writeNbt(nbt);
return nbt;
}
}

View File

@@ -0,0 +1,246 @@
package dev.tggamesyt.szar;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import java.util.Random;
public class SlotMachineScreenHandler extends ScreenHandler {
public final SlotMachineBlockEntity blockEntity;
private final SimpleInventory betInventory = new SimpleInventory(1);
private final Random random = new Random();
private final PlayerInventory playerInventory;
private int currentBetAmount = 0;
private ItemStack currentBetStack = ItemStack.EMPTY;
private boolean spinning = false;
private int spinTicks = 0;
private SlotSymbol final0, final1, final2;
public SlotMachineScreenHandler(int syncId, PlayerInventory playerInv, SlotMachineBlockEntity blockEntity) {
super(Szar.SLOT_MACHINE_SCREEN_HANDLER_TYPE, syncId);
this.playerInventory = playerInv;
this.blockEntity = blockEntity;
this.addSlot(new Slot(betInventory, 0, 44, 35) {
@Override
public boolean canInsert(ItemStack stack) {
return !spinning;
}
@Override
public boolean canTakeItems(PlayerEntity playerEntity) {
return !spinning;
}
});
for (int y = 0; y < 3; y++)
for (int x = 0; x < 9; x++)
this.addSlot(new Slot(playerInv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));
for (int x = 0; x < 9; x++)
this.addSlot(new Slot(playerInv, x, 8 + x * 18, 142));
}
@Override
public boolean canUse(PlayerEntity player) {
return true;
}
@Override
public boolean onButtonClick(PlayerEntity player, int id) {
if (id != 0) return false;
if (spinning) return false;
ItemStack bet = betInventory.getStack(0);
if (bet.isEmpty()) return false;
// TAKE BET IMMEDIATELY
currentBetAmount = bet.getCount();
currentBetStack = bet.copy();
betInventory.setStack(0, ItemStack.EMPTY);
spinning = true;
spinTicks = 60;
final0 = SlotSymbol.roll(random);
final1 = rollWithBias(final0);
final2 = rollWithBias(final0, final1);
return true;
}
public void tick(PlayerEntity player) {
if (!spinning) return;
spinTicks--;
// Animate random symbols during spin
if (spinTicks > 40) {
blockEntity.setSymbols(
random.nextInt(7),
random.nextInt(7),
random.nextInt(7)
);
}
// Lock first reel
if (spinTicks == 40) {
blockEntity.setSymbols(
final0.ordinal(),
random.nextInt(7),
random.nextInt(7)
);
}
// Lock second reel
if (spinTicks == 20) {
blockEntity.setSymbols(
final0.ordinal(),
final1.ordinal(),
random.nextInt(7)
);
}
// Lock third reel
if (spinTicks == 0) {
blockEntity.setSymbols(
final0.ordinal(),
final1.ordinal(),
final2.ordinal()
);
finishSpin(player);
spinning = false;
}
}
private SlotSymbol rollWithBias(SlotSymbol... biasToward) {
float bonusChance = 0.20f; // 20% bonus chance toward existing symbol
float r = random.nextFloat();
if (r < bonusChance) {
return biasToward[random.nextInt(biasToward.length)];
}
return SlotSymbol.roll(random);
}
private void finishSpin(PlayerEntity player) {
int payout = 0;
if (final0 == final1 && final1 == final2) {
payout = switch (final0) {
case SEVEN -> currentBetAmount * 100;
case BELL -> currentBetAmount * 15;
default -> currentBetAmount * 2;
};
}
if (payout > 0) {
Direction facing = blockEntity.getCachedState().get(SlotMachineBlock.FACING);
BlockPos drop = blockEntity.getPos().offset(facing);
ItemScatterer.spawn(
player.getWorld(),
drop.getX(),
drop.getY(),
drop.getZ(),
new ItemStack(currentBetStack.getItem(), payout)
);
}
currentBetAmount = 0;
currentBetStack = ItemStack.EMPTY;
}
@Override
public ItemStack quickMove(PlayerEntity player, int index) {
ItemStack newStack = ItemStack.EMPTY;
Slot slot = this.slots.get(index);
if (slot.hasStack()) {
ItemStack original = slot.getStack();
newStack = original.copy();
// Prevent shift-click while spinning
if (spinning) {
return ItemStack.EMPTY;
}
// If clicking bet slot → move to player inventory
if (index == 0) {
if (!this.insertItem(original, 1, this.slots.size(), true)) {
return ItemStack.EMPTY;
}
}
// If clicking player inventory → move to bet slot
else {
if (!this.insertItem(original, 0, 1, false)) {
return ItemStack.EMPTY;
}
}
if (original.isEmpty()) {
slot.setStack(ItemStack.EMPTY);
} else {
slot.markDirty();
}
}
return newStack;
}
@Override
public void sendContentUpdates() {
super.sendContentUpdates();
if (!spinning) return;
spinTicks--;
int reel0;
int reel1;
int reel2;
if (spinTicks > 40) {
reel0 = random.nextInt(7);
} else {
reel0 = final0.ordinal();
}
if (spinTicks > 20) {
reel1 = random.nextInt(7);
} else {
reel1 = final1.ordinal();
}
// Reel 3 stops at tick 0
if (spinTicks > 0) {
reel2 = random.nextInt(7);
} else {
reel2 = final2.ordinal();
}
blockEntity.setSymbols(reel0, reel1, reel2);
if (spinTicks <= 0) {
finishSpin(playerInventory.player);
spinning = false;
}
}
}

View File

@@ -0,0 +1,39 @@
package dev.tggamesyt.szar;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
public enum SlotSymbol {
SEVEN(Items.ENCHANTED_GOLDEN_APPLE),
BELL(Items.GOLDEN_APPLE),
APPLE(Items.APPLE),
SWEET_BERRIES(Items.SWEET_BERRIES),
GLOW_BERRIES(Items.GLOW_BERRIES),
MELON_SLICE(Items.MELON_SLICE),
CHORUS_FRUIT(Items.CHORUS_FRUIT);
public final Item item;
SlotSymbol(Item item) {
this.item = item;
}
// Roll a random symbol according to the specified probabilities
public static SlotSymbol roll(java.util.Random random) {
float r = random.nextFloat();
if (r < 0.0255f) return SEVEN; // 2.55%
else if (r < 0.0255f + 0.101f) return BELL; // 10.1%
else {
// 5 fruits, equally likely
int fruitIndex = random.nextInt(5);
switch (fruitIndex) {
case 0: return APPLE;
case 1: return SWEET_BERRIES;
case 2: return GLOW_BERRIES;
case 3: return MELON_SLICE;
default: return CHORUS_FRUIT;
}
}
}
}

View File

@@ -22,6 +22,7 @@ import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRe
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper; import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
import net.fabricmc.fabric.api.object.builder.v1.world.poi.PointOfInterestHelper; import net.fabricmc.fabric.api.object.builder.v1.world.poi.PointOfInterestHelper;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.advancement.Advancement; import net.minecraft.advancement.Advancement;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
@@ -41,6 +42,7 @@ import net.minecraft.registry.*;
import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.registry.tag.BiomeTags; import net.minecraft.registry.tag.BiomeTags;
import net.minecraft.registry.tag.BlockTags; import net.minecraft.registry.tag.BlockTags;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@@ -284,6 +286,7 @@ public class Szar implements ModInitializer {
entries.add(Szar.BAITER_DISK); entries.add(Szar.BAITER_DISK);
entries.add(Szar.MERL_SPAWNEGG); entries.add(Szar.MERL_SPAWNEGG);
entries.add(Szar.EFN_DISK); entries.add(Szar.EFN_DISK);
entries.add(Szar.SLOT_MACHINE);
// nsfw // nsfw
entries.add(Szar.FASZITEM); entries.add(Szar.FASZITEM);
entries.add(Szar.CNDM); entries.add(Szar.CNDM);
@@ -681,11 +684,7 @@ public class Szar implements ModInitializer {
}) })
); );
}); });
Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "towers"),
new BlockItem(OBELISK_CORE, new Item.Settings())
);
} }
public static ObeliskCoreBlockEntity findNearestObelisk(ServerWorld world, BlockPos center, int radius) { public static ObeliskCoreBlockEntity findNearestObelisk(ServerWorld world, BlockPos center, int radius) {
ObeliskCoreBlockEntity closest = null; ObeliskCoreBlockEntity closest = null;
@@ -774,10 +773,45 @@ public class Szar implements ModInitializer {
OBELISK_CORE // block(s) this BE is linked to OBELISK_CORE // block(s) this BE is linked to
).build(null) ).build(null)
); );
public static final Item TOWERS_ITEM = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "towers"),
new BlockItem(OBELISK_CORE, new Item.Settings())
);
public static final ScreenHandlerType<SlotMachineScreenHandler> SLOT_MACHINE_SCREEN_HANDLER_TYPE =
ScreenHandlerRegistry.registerExtended(
new Identifier(Szar.MOD_ID, "slot_machine"),
(syncId, inv, buf) -> {
BlockPos pos = buf.readBlockPos();
BlockEntity be = inv.player.getWorld().getBlockEntity(pos);
if (!(be instanceof SlotMachineBlockEntity blockEntity)) {
throw new IllegalStateException("BlockEntity is not a SlotMachineBlockEntity");
}
return new SlotMachineScreenHandler(syncId, inv, blockEntity);
}
);
public static final Block SLOT_MACHINE_BLOCK = Registry.register(
Registries.BLOCK,
new Identifier(MOD_ID, "slot_machine"),
new SlotMachineBlock(
AbstractBlock.Settings
.copy(Blocks.IRON_BLOCK)
)
);
public static final BlockEntityType<SlotMachineBlockEntity> SLOT_MACHINE_BLOCKENTITY = Registry.register(
Registries.BLOCK_ENTITY_TYPE,
new Identifier(MOD_ID, "slot_machine"),
FabricBlockEntityTypeBuilder.create(
SlotMachineBlockEntity::new,
SLOT_MACHINE_BLOCK // block(s) this BE is linked to
).build(null)
);
public static final Item SLOT_MACHINE = Registry.register(
Registries.ITEM,
new Identifier(MOD_ID, "slot_machine"),
new BlockItem(SLOT_MACHINE_BLOCK, new Item.Settings())
);
public static final Feature<CannabisPatchFeatureConfig> CANNABIS_PATCH = public static final Feature<CannabisPatchFeatureConfig> CANNABIS_PATCH =
Registry.register( Registry.register(
Registries.FEATURE, Registries.FEATURE,

View File

@@ -0,0 +1,8 @@
{
"variants": {
"facing=north": { "model": "szar:block/slot_machine", "y": 0 },
"facing=south": { "model": "szar:block/slot_machine", "y": 180 },
"facing=west": { "model": "szar:block/slot_machine", "y": 270 },
"facing=east": { "model": "szar:block/slot_machine", "y": 90 }
}
}

View File

@@ -79,5 +79,6 @@
"death.attack.fck": "%1$s got fucked too hard by %2$s", "death.attack.fck": "%1$s got fucked too hard by %2$s",
"item.szar.white_liquid": "...", "item.szar.white_liquid": "...",
"item.szar.plane": "Plane", "item.szar.plane": "Plane",
"item.szar.wheel": "Wheel" "item.szar.wheel": "Wheel",
"block.szar.slot_machine": "Slot Machine"
} }

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,348 @@
{
"format_version": "1.9.0",
"credit": "Made with Blockbench",
"texture_size": [4, 4],
"textures": {
"0": "szar:block/slot_machine",
"1": "szar:block/lower_screen_info",
"2": "szar:block/texture",
"3": "szar:block/slot_1",
"4": "szar:block/slot_1_up",
"5": "szar:block/slot_1_down",
"6": "szar:block/slot_2",
"7": "szar:block/slot_2_down",
"8": "szar:block/slot_2_up",
"9": "szar:block/slot_3",
"10": "szar:block/slot_3_up",
"11": "szar:block/slot_3_down",
"particle": "szar:block/slot_machine_particle"
},
"elements": [
{
"from": [4, 0, 10],
"to": [16, 24, 16],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 14]},
"faces": {
"north": {"uv": [0, 0, 3, 6], "texture": "#0"},
"east": {"uv": [0, 6, 1.5, 12], "texture": "#0"},
"south": {"uv": [3, 0, 6, 6], "texture": "#0"},
"west": {"uv": [6, 0, 7.5, 6], "texture": "#0"},
"up": {"uv": [10.5, 1.5, 7.5, 0], "texture": "#0"},
"down": {"uv": [10.5, 1.5, 7.5, 3], "texture": "#0"}
}
},
{
"from": [4, 0, 4],
"to": [16, 12, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 8]},
"faces": {
"north": {"uv": [1.5, 6, 4.5, 9], "texture": "#0"},
"east": {"uv": [7.5, 3, 9, 6], "texture": "#0"},
"south": {"uv": [4.5, 6, 7.5, 9], "texture": "#0"},
"west": {"uv": [7.5, 6, 9, 9], "texture": "#0"},
"up": {"uv": [4.5, 10.5, 1.5, 9], "texture": "#0"},
"down": {"uv": [12, 3, 9, 4.5], "texture": "#0"}
}
},
{
"from": [4, 19, 8],
"to": [16, 24, 9],
"rotation": {"angle": -22.5, "axis": "x", "origin": [10, 24, 9]},
"faces": {
"north": {"uv": [4.5, 9, 7.5, 10.25], "texture": "#0"},
"east": {"uv": [8.25, 10, 8.5, 11.25], "texture": "#0"},
"south": {"uv": [9, 4.5, 12, 5.75], "texture": "#0"},
"west": {"uv": [8.5, 10, 8.75, 11.25], "texture": "#0"},
"up": {"uv": [12, 7, 9, 6.75], "texture": "#0"},
"down": {"uv": [12, 7, 9, 7.25], "texture": "#0"}
}
},
{
"from": [4, 22, 9],
"to": [16, 24, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [10, 24, 10]},
"faces": {
"north": {"uv": [9, 5.75, 12, 6.25], "texture": "#0"},
"east": {"uv": [5, 10.25, 5.25, 10.75], "texture": "#0"},
"south": {"uv": [9, 6.25, 12, 6.75], "texture": "#0"},
"west": {"uv": [5.25, 10.25, 5.5, 10.75], "texture": "#0"},
"up": {"uv": [12, 7.5, 9, 7.25], "texture": "#0"},
"down": {"uv": [10.5, 9, 7.5, 9.25], "texture": "#0"}
}
},
{
"from": [12, 12, 5],
"to": [14, 13, 7],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 1, 8]},
"faces": {
"north": {"uv": [9.75, 8.75, 10.25, 9], "texture": "#0"},
"east": {"uv": [5.5, 10.25, 6, 10.5], "texture": "#0"},
"south": {"uv": [6, 10.25, 6.5, 10.5], "texture": "#0"},
"west": {"uv": [6.5, 10.25, 7, 10.5], "texture": "#0"},
"up": {"uv": [10.25, 8.75, 9.75, 8.25], "texture": "#0"},
"down": {"uv": [9.25, 10, 8.75, 10.5], "texture": "#0"}
}
},
{
"from": [8, 12, 5],
"to": [10, 13, 7],
"rotation": {"angle": 0, "axis": "y", "origin": [-4, 1, 8]},
"faces": {
"north": {"uv": [7, 10.25, 7.5, 10.5], "texture": "#0"},
"east": {"uv": [10.25, 8.25, 10.75, 8.5], "texture": "#0"},
"south": {"uv": [10.25, 8.5, 10.75, 8.75], "texture": "#0"},
"west": {"uv": [10.25, 8.75, 10.75, 9], "texture": "#0"},
"up": {"uv": [9.75, 10.5, 9.25, 10], "texture": "#0"},
"down": {"uv": [10.5, 9.25, 10, 9.75], "texture": "#0"}
}
},
{
"from": [1, 16, 8],
"to": [4, 19, 11],
"rotation": {"angle": 0, "axis": "y", "origin": [4, 8, 10]},
"faces": {
"north": {"uv": [9, 7.5, 9.75, 8.25], "texture": "#0"},
"east": {"uv": [9, 8.25, 9.75, 9], "texture": "#0"},
"south": {"uv": [7.5, 9.25, 8.25, 10], "texture": "#0"},
"west": {"uv": [8.25, 9.25, 9, 10], "texture": "#0"},
"up": {"uv": [9.75, 10, 9, 9.25], "texture": "#0"},
"down": {"uv": [10.5, 7.5, 9.75, 8.25], "texture": "#0"}
}
},
{
"from": [2, 9, 9],
"to": [3, 16, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [4, 8, 10]},
"faces": {
"north": {"uv": [9.75, 9.25, 10, 11], "texture": "#0"},
"east": {"uv": [7.5, 10, 7.75, 11.75], "texture": "#0"},
"south": {"uv": [7.75, 10, 8, 11.75], "texture": "#0"},
"west": {"uv": [8, 10, 8.25, 11.75], "texture": "#0"},
"up": {"uv": [10.75, 0.75, 10.5, 0.5], "texture": "#0"},
"down": {"uv": [10.75, 0.75, 10.5, 1], "texture": "#0"}
}
},
{
"from": [2, 7, 9],
"to": [4, 9, 10],
"rotation": {"angle": 0, "axis": "y", "origin": [4, 8, 10]},
"faces": {
"north": {"uv": [10, 9.75, 10.5, 10.25], "texture": "#0"},
"east": {"uv": [10, 10.25, 10.25, 10.75], "texture": "#0"},
"south": {"uv": [4.5, 10.25, 5, 10.75], "texture": "#0"},
"west": {"uv": [10.25, 10.25, 10.5, 10.75], "texture": "#0"},
"up": {"uv": [11, 0.25, 10.5, 0], "texture": "#0"},
"down": {"uv": [11, 0.25, 10.5, 0.5], "texture": "#0"}
}
},
{
"name": "lower_screen",
"from": [6, 2, 3.99],
"to": [14, 10, 3.99],
"rotation": {"angle": 0, "axis": "y", "origin": [-6, 2, 5]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#1"},
"east": {"uv": [0, 0, 0, 8], "texture": "#1"},
"south": {"uv": [0, 16, 0, 16], "texture": "#1"},
"west": {"uv": [0, 0, 0, 8], "texture": "#1"},
"up": {"uv": [8, 0, 0, 0], "texture": "#1"},
"down": {"uv": [8, 0, 0, 0], "texture": "#1"}
}
},
{
"name": "upper_screen",
"from": [4, 19, 7.99],
"to": [16, 24, 7.99],
"rotation": {"angle": -22.5, "axis": "x", "origin": [10, 24, 8.99]},
"faces": {
"north": {"uv": [0, 0, 12, 5], "texture": "#2"},
"east": {"uv": [0, 0, 0, 5], "texture": "#2"},
"south": {"uv": [0, 5, 12, 10], "texture": "#2"},
"west": {"uv": [0, 0, 0, 5], "texture": "#2"},
"up": {"uv": [12, 0, 0, 0], "texture": "#2"},
"down": {"uv": [12, 0, 0, 0], "texture": "#2"}
}
},
{
"name": "slot_1_up",
"from": [12, 17, 9.99],
"to": [14, 19, 9.99],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 6, 11]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#4"},
"east": {"uv": [12, 12, 12, 20], "texture": "#4"},
"south": {"uv": [48, 12, 56, 20], "texture": "#4"},
"west": {"uv": [20, 12, 20, 20], "texture": "#4"},
"up": {"uv": [48, 20, 56, 20], "texture": "#4"},
"down": {"uv": [48, 12, 56, 12], "texture": "#4"}
}
},
{
"name": "slot_1",
"from": [12, 15, 9.99],
"to": [14, 17, 9.99],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 4, 11]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#3"},
"east": {"uv": [0, 0, 0, 8], "texture": "#3"},
"south": {"uv": [0, 0, 0, 0], "texture": "#3"},
"west": {"uv": [0, 0, 0, 8], "texture": "#3"},
"up": {"uv": [8, 0, 0, 0], "texture": "#3"},
"down": {"uv": [8, 0, 0, 0], "texture": "#3"}
}
},
{
"name": "slot_1_down",
"from": [12, 13, 9.99],
"to": [14, 15, 9.99],
"rotation": {"angle": 0, "axis": "y", "origin": [0, 2, 11]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#5"},
"east": {"uv": [12, 12, 12, 20], "texture": "#5"},
"south": {"uv": [48, 12, 56, 20], "texture": "#5"},
"west": {"uv": [20, 12, 20, 20], "texture": "#5"},
"up": {"uv": [48, 20, 56, 20], "texture": "#5"},
"down": {"uv": [48, 12, 56, 12], "texture": "#5"}
}
},
{
"name": "slot_2",
"from": [9, 15, 9.99],
"to": [11, 17, 9.99],
"rotation": {"angle": 0, "axis": "y", "origin": [-3, 4, 11]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#6"},
"east": {"uv": [12, 12, 12, 20], "texture": "#6"},
"south": {"uv": [48, 12, 56, 20], "texture": "#6"},
"west": {"uv": [20, 12, 20, 20], "texture": "#6"},
"up": {"uv": [48, 20, 56, 20], "texture": "#6"},
"down": {"uv": [48, 12, 56, 12], "texture": "#6"}
}
},
{
"name": "slot_2_down",
"from": [9, 13, 9.99],
"to": [11, 15, 9.99],
"rotation": {"angle": 0, "axis": "y", "origin": [-3, 2, 11]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#7"},
"east": {"uv": [12, 12, 12, 20], "texture": "#7"},
"south": {"uv": [48, 12, 56, 20], "texture": "#7"},
"west": {"uv": [20, 12, 20, 20], "texture": "#7"},
"up": {"uv": [48, 20, 56, 20], "texture": "#7"},
"down": {"uv": [48, 12, 56, 12], "texture": "#7"}
}
},
{
"name": "slot_2_up",
"from": [9, 17, 9.99],
"to": [11, 19, 9.99],
"rotation": {"angle": 0, "axis": "y", "origin": [-3, 6, 11]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#8"},
"east": {"uv": [12, 12, 12, 20], "texture": "#8"},
"south": {"uv": [48, 12, 56, 20], "texture": "#8"},
"west": {"uv": [20, 12, 20, 20], "texture": "#8"},
"up": {"uv": [48, 20, 56, 20], "texture": "#8"},
"down": {"uv": [48, 12, 56, 12], "texture": "#8"}
}
},
{
"name": "slot_3",
"from": [6, 15, 9.99],
"to": [8, 17, 9.99],
"rotation": {"angle": 0, "axis": "y", "origin": [-6, 4, 11]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#9"},
"east": {"uv": [12, 12, 12, 20], "texture": "#9"},
"south": {"uv": [48, 12, 56, 20], "texture": "#9"},
"west": {"uv": [20, 12, 20, 20], "texture": "#9"},
"up": {"uv": [48, 20, 56, 20], "texture": "#9"},
"down": {"uv": [48, 12, 56, 12], "texture": "#9"}
}
},
{
"name": "slot_3_up",
"from": [6, 17, 9.99],
"to": [8, 19, 9.99],
"rotation": {"angle": 0, "axis": "y", "origin": [-6, 6, 11]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#10"},
"east": {"uv": [12, 12, 12, 20], "texture": "#10"},
"south": {"uv": [48, 12, 56, 20], "texture": "#10"},
"west": {"uv": [20, 12, 20, 20], "texture": "#10"},
"up": {"uv": [48, 20, 56, 20], "texture": "#10"},
"down": {"uv": [48, 12, 56, 12], "texture": "#10"}
}
},
{
"name": "slot_3_down",
"from": [6, 13, 9.99],
"to": [8, 15, 9.99],
"rotation": {"angle": 0, "axis": "y", "origin": [-6, 2, 11]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#11"},
"east": {"uv": [12, 12, 12, 20], "texture": "#11"},
"south": {"uv": [48, 12, 56, 20], "texture": "#11"},
"west": {"uv": [20, 12, 20, 20], "texture": "#11"},
"up": {"uv": [48, 20, 56, 20], "texture": "#11"},
"down": {"uv": [48, 12, 56, 12], "texture": "#11"}
}
}
],
"display": {
"thirdperson_righthand": {
"translation": [0, -1.5, -3.75],
"scale": [0.5, 0.5, 0.5]
},
"thirdperson_lefthand": {
"translation": [2, -1.5, -3.75],
"scale": [0.5, 0.5, 0.5]
},
"firstperson_righthand": {
"rotation": [0, 160, 0],
"translation": [4, 0, -2],
"scale": [0.5, 0.5, 0.5]
},
"firstperson_lefthand": {
"rotation": [0, 160, 0],
"translation": [1.5, 0, -2],
"scale": [0.5, 0.5, 0.5]
},
"ground": {
"translation": [-1, 2.5, 0],
"scale": [0.5, 0.5, 0.5]
},
"head": {
"translation": [-2, 3, -1.75]
},
"fixed": {
"translation": [0, 0, -1],
"scale": [0.5, 0.5, 0.5]
},
"on_shelf": {
"rotation": [0, -180, 0],
"translation": [0, 0, 2.5]
}
},
"groups": [
{
"name": "main_body",
"origin": [0, 0, 14],
"color": 0,
"children": [0, 1, 2, 3, 4, 5]
},
{
"name": "handle",
"origin": [2, 18, 9],
"color": 0,
"children": [6, 7, 8]
},
{
"name": "dynamic",
"origin": [0, 6, 11],
"color": 0,
"children": [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
}
]
}

View File

@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "szar:item/slot_machine"
}
}

View File

@@ -0,0 +1,3 @@
{
"parent": "szar:block/slot_machine"
}

View File

@@ -66,5 +66,21 @@
"stream": true "stream": true
} }
] ]
},
"slot_machine_base": {
"sounds": [
{
"name": "szar:slot_machine_base",
"stream": true
}
]
},
"slot_machine_win": {
"sounds": [
{
"name": "szar:slot_machine_win",
"stream": true
}
]
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -0,0 +1,6 @@
{
"animation": {
"interpolate": false,
"frametime": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -0,0 +1,6 @@
{
"animation": {
"interpolate": false,
"frametime": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -0,0 +1,6 @@
{
"animation": {
"interpolate": false,
"frametime": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -0,0 +1,6 @@
{
"animation": {
"interpolate": false,
"frametime": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -0,0 +1,6 @@
{
"animation": {
"interpolate": false,
"frametime": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -0,0 +1,6 @@
{
"animation": {
"interpolate": false,
"frametime": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -0,0 +1,6 @@
{
"animation": {
"interpolate": false,
"frametime": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -0,0 +1,6 @@
{
"animation": {
"interpolate": false,
"frametime": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -0,0 +1,6 @@
{
"animation": {
"interpolate": false,
"frametime": 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 595 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB