Skip to content

Commit

Permalink
23w40a
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed Oct 5, 2023
1 parent 670b2ea commit 10292b9
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package net.fabricmc.fabric.test.lookup;

import com.mojang.serialization.MapCodec;
import org.jetbrains.annotations.Nullable;

import net.minecraft.block.BlockState;
Expand All @@ -31,6 +32,11 @@ public ChuteBlock(Settings settings) {
super(settings);
}

@Override
protected MapCodec<? extends BlockWithEntity> method_53969() {
throw new UnsupportedOperationException("not implemented yet");
}

@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package net.fabricmc.fabric.test.lookup;

import com.mojang.serialization.MapCodec;
import org.jetbrains.annotations.Nullable;

import net.minecraft.block.BlockState;
Expand All @@ -28,6 +29,11 @@ public CobbleGenBlock(Settings settings) {
super(settings);
}

@Override
protected MapCodec<? extends BlockWithEntity> method_53969() {
throw new UnsupportedOperationException("not implemented yet");
}

@Nullable
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public void interactItem(ServerPlayerEntity player, World world, ItemStack stack
}
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onBreak(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/player/PlayerEntity;)V"), method = "tryBreakBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void breakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir, BlockState state, BlockEntity entity, Block block) {
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onBreak(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/player/PlayerEntity;)Lnet/minecraft/block/BlockState;"), method = "tryBreakBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void breakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir, BlockEntity entity, Block block, BlockState state) {
boolean result = PlayerBlockBreakEvents.BEFORE.invoker().beforeBlockBreak(this.world, this.player, pos, state, entity);

if (!result) {
Expand All @@ -116,7 +116,7 @@ private void breakBlock(BlockPos pos, CallbackInfoReturnable<Boolean> cir, Block
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onBroken(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V"), method = "tryBreakBlock", locals = LocalCapture.CAPTURE_FAILHARD)
private void onBlockBroken(BlockPos pos, CallbackInfoReturnable<Boolean> cir, BlockState state, BlockEntity entity, Block block, boolean b1) {
private void onBlockBroken(BlockPos pos, CallbackInfoReturnable<Boolean> cir, BlockEntity entity, Block block, BlockState state, boolean bl) {
PlayerBlockBreakEvents.AFTER.invoker().afterBlockBreak(this.world, this.player, pos, state, entity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
public final class BlockSetTypeBuilder {
private boolean openableByHand = true;
private boolean buttonActivatedByArrows = true;
private BlockSetType.ActivationRule pressurePlateActivationRule = BlockSetType.ActivationRule.EVERYTHING;
private BlockSoundGroup soundGroup = BlockSoundGroup.WOOD;
private SoundEvent doorCloseSound = SoundEvents.BLOCK_WOODEN_DOOR_CLOSE;
private SoundEvent doorOpenSound = SoundEvents.BLOCK_WOODEN_DOOR_OPEN;
Expand All @@ -53,6 +55,30 @@ public BlockSetTypeBuilder openableByHand(boolean openableByHand) {
return this;
}

/**
* Sets whether this block set type's button can be activated by an arrow.
*
* <p>Defaults to {@code true}.
*
* @return this builder for chaining
*/
public BlockSetTypeBuilder buttonActivatedByArrows(boolean buttonActivatedByArrows) {
this.buttonActivatedByArrows = buttonActivatedByArrows;
return this;
}

/**
* Sets this block set type's pressure plate {@link BlockSetType.ActivationRule}.
*
* <p>Defaults to {@link BlockSetType.ActivationRule#EVERYTHING}.
*
* @return this builder for chaining
*/
public BlockSetTypeBuilder pressurePlateActivationRule(BlockSetType.ActivationRule activationRule) {
this.pressurePlateActivationRule = activationRule;
return this;
}

/**
* Sets this block set type's sound group.
*
Expand Down Expand Up @@ -171,6 +197,8 @@ public BlockSetTypeBuilder buttonClickOnSound(SoundEvent buttonClickOnSound) {
public static BlockSetTypeBuilder copyOf(BlockSetTypeBuilder builder) {
BlockSetTypeBuilder copy = new BlockSetTypeBuilder();
copy.openableByHand(builder.openableByHand);
copy.buttonActivatedByArrows(builder.buttonActivatedByArrows);
copy.pressurePlateActivationRule(builder.pressurePlateActivationRule);
copy.soundGroup(builder.soundGroup);
copy.doorCloseSound(builder.doorCloseSound);
copy.doorOpenSound(builder.doorOpenSound);
Expand All @@ -193,6 +221,8 @@ public static BlockSetTypeBuilder copyOf(BlockSetTypeBuilder builder) {
public static BlockSetTypeBuilder copyOf(BlockSetType setType) {
BlockSetTypeBuilder copy = new BlockSetTypeBuilder();
copy.openableByHand(setType.canOpenByHand());
copy.buttonActivatedByArrows(setType.canButtonBeActivatedByArrows());
copy.pressurePlateActivationRule(setType.pressurePlateSensitivity());
copy.soundGroup(setType.soundType());
copy.doorCloseSound(setType.doorClose());
copy.doorOpenSound(setType.doorOpen());
Expand Down Expand Up @@ -230,6 +260,6 @@ public BlockSetType register(Identifier id) {
* @return the built {@link BlockSetType}
*/
public BlockSetType build(Identifier id) {
return new BlockSetType(id.toString(), openableByHand, soundGroup, doorCloseSound, doorOpenSound, trapdoorCloseSound, trapdoorOpenSound, pressurePlateClickOffSound, pressurePlateClickOnSound, buttonClickOffSound, buttonClickOnSound);
return new BlockSetType(id.toString(), openableByHand, buttonActivatedByArrows, pressurePlateActivationRule, soundGroup, doorCloseSound, doorOpenSound, trapdoorCloseSound, trapdoorOpenSound, pressurePlateClickOffSound, pressurePlateClickOnSound, buttonClickOffSound, buttonClickOnSound);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@ public class TealSignTest implements ModInitializer {
public static final Identifier TEAL_TYPE_ID = ObjectBuilderTestConstants.id("teal");
public static final BlockSetType TEAL_BLOCK_SET_TYPE = BlockSetTypeBuilder.copyOf(BlockSetType.OAK).build(TEAL_TYPE_ID);
public static final WoodType TEAL_WOOD_TYPE = WoodTypeBuilder.copyOf(WoodType.OAK).build(TEAL_TYPE_ID, TEAL_BLOCK_SET_TYPE);
public static final SignBlock TEAL_SIGN = new SignBlock(FabricBlockSettings.copy(Blocks.OAK_SIGN), TEAL_WOOD_TYPE) {
public static final SignBlock TEAL_SIGN = new SignBlock(TEAL_WOOD_TYPE, FabricBlockSettings.copy(Blocks.OAK_SIGN)) {
@Override
public TealSign createBlockEntity(BlockPos pos, BlockState state) {
return new TealSign(pos, state);
}
};
public static final WallSignBlock TEAL_WALL_SIGN = new WallSignBlock(FabricBlockSettings.copy(Blocks.OAK_SIGN), TEAL_WOOD_TYPE) {
public static final WallSignBlock TEAL_WALL_SIGN = new WallSignBlock(TEAL_WOOD_TYPE, FabricBlockSettings.copy(Blocks.OAK_SIGN)) {
@Override
public TealSign createBlockEntity(BlockPos pos, BlockState state) {
return new TealSign(pos, state);
}
};
public static final HangingSignBlock TEAL_HANGING_SIGN = new HangingSignBlock(FabricBlockSettings.copy(Blocks.OAK_HANGING_SIGN), TEAL_WOOD_TYPE) {
public static final HangingSignBlock TEAL_HANGING_SIGN = new HangingSignBlock(TEAL_WOOD_TYPE, FabricBlockSettings.copy(Blocks.OAK_HANGING_SIGN)) {
@Override
public TealHangingSign createBlockEntity(BlockPos pos, BlockState state) {
return new TealHangingSign(pos, state);
}
};
public static final WallHangingSignBlock TEAL_WALL_HANGING_SIGN = new WallHangingSignBlock(FabricBlockSettings.copy(Blocks.OAK_HANGING_SIGN), TEAL_WOOD_TYPE) {
public static final WallHangingSignBlock TEAL_WALL_HANGING_SIGN = new WallHangingSignBlock(TEAL_WOOD_TYPE, FabricBlockSettings.copy(Blocks.OAK_HANGING_SIGN)) {
@Override
public TealHangingSign createBlockEntity(BlockPos pos, BlockState state) {
return new TealHangingSign(pos, state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import it.unimi.dsi.fastutil.ints.Int2IntMap;
import it.unimi.dsi.fastutil.ints.Int2IntMaps;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Reference2IntMap;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -37,7 +37,7 @@ public class IdListMixin<T> implements RemovableIdList<T> {
private int nextId;
@Final
@Shadow
private Object2IntMap<T> idMap;
private Reference2IntMap<T> idMap;
@Final
@Shadow
private List<T> list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectList;
import it.unimi.dsi.fastutil.objects.Reference2IntMap;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -76,7 +77,7 @@ public abstract class SimpleRegistryMixin<T> implements MutableRegistry<T>, Rema
private ObjectList<RegistryEntry.Reference<T>> rawIdToEntry;
@Shadow
@Final
private Object2IntMap<T> entryToRawId;
private Reference2IntMap<T> entryToRawId;
@Shadow
@Final
private Map<Identifier, RegistryEntry.Reference<T>> idToEntry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package net.fabricmc.fabric.test.screenhandler.block;

import com.mojang.serialization.MapCodec;

import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity;
Expand All @@ -36,6 +38,11 @@ public BoxBlock(Settings settings) {
super(settings);
}

@Override
protected MapCodec<? extends BlockWithEntity> method_53969() {
throw new UnsupportedOperationException("not implemented yet");
}

@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!world.isClient) {
Expand Down
Loading

0 comments on commit 10292b9

Please sign in to comment.