Skip to content

Commit

Permalink
Address a lot of simple TODO items. Fix netherbrick fencegate open/cl…
Browse files Browse the repository at this point in the history
…ose sounds.
  • Loading branch information
quat1024 committed Jan 2, 2024
1 parent 9d9779e commit 07a274c
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name
CreativeTabManager.daisyChain();

//TODO 1.20: maybe expose stuff like canOpenByHand, sound types, etc
// builder api might be in order since there's a lot of parameters now :skull:
BlockSetType setType = new BlockSetType(Quark.MOD_ID + ":" + name);
SoundType sound = SoundType.WOOD;

Expand All @@ -107,7 +108,7 @@ public static WoodSet addWoodSet(ZRegister event, ZetaModule module, String name
set.stairs = event.getVariantRegistry().addStairs((IZetaBlock) set.planks, null).getBlock();

set.fence = new ZetaFenceBlock(name + "_fence", module, OldMaterials.wood().mapColor(color).strength(2.0F, 3.0F).sound(SoundType.WOOD));
set.fenceGate = new ZetaFenceGateBlock(name + "_fence_gate", module, OldMaterials.wood().mapColor(color).strength(2.0F, 3.0F).sound(SoundType.WOOD)).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS);
set.fenceGate = new ZetaFenceGateBlock(name + "_fence_gate", module, type, OldMaterials.wood().mapColor(color).strength(2.0F, 3.0F).sound(SoundType.WOOD)).setCreativeTab(CreativeModeTabs.BUILDING_BLOCKS);

set.door = new ZetaDoorBlock(setType, name + "_door", module, OldMaterials.wood().mapColor(color).strength(3.0F).sound(SoundType.WOOD).noOcclusion());
set.trapdoor = new ZetaTrapdoorBlock(setType, name + "_trapdoor", module, OldMaterials.wood().mapColor(color).strength(3.0F).sound(SoundType.WOOD).noOcclusion().isValidSpawn((s, g, p, e) -> false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ public void configChanged(ModConfigEvent event) {
handleQuarkConfigChange();
}

//TODO: probably find a better spot for this? It's not *only* fired when the
// config file is externally changed, but also when it's changed through config GUI,
// which means we roundtrip through the on-disk representation for no good reason
public void handleQuarkConfigChange() {
Quark.ZETA.configManager.onReload();
Quark.ZETA.loadBus.fire(new ZConfigChanged());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

import java.util.function.BooleanSupplier;

// TODO ZETA: extend QuarkFenceBlock
// TODO ZETA: extend ZetaFenceBlock
public class HedgeBlock extends FenceBlock implements IZetaBlock, IZetaBlockColorProvider {

private static final VoxelShape WOOD_SHAPE = box(6F, 0F, 6F, 10F, 15F, 10F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ public InteractionResult use(@NotNull BlockState state, @NotNull Level worldIn,
worldIn.playSound(null, pos, soundType.getPlaceSound(), SoundSource.BLOCKS, 0.5F, 1F);
return InteractionResult.SUCCESS;
}
} else if(stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).isPresent()) {
} else if(stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).isPresent()) { //TODO: Forge extension
return FluidUtil.interactWithFluidHandler(player, hand, worldIn, getBottomPos(worldIn, pos), Direction.UP) ? InteractionResult.SUCCESS : InteractionResult.PASS;
} else if(stack.getItem() == Items.GLASS_BOTTLE) {
BlockPos bottomPos = getBottomPos(worldIn, pos);
BlockState stateAt = worldIn.getBlockState(bottomPos);
if(stateAt.getFluidState().is(Fluids.WATER)) { //TODO 1.20: material -> fluidState check
if(stateAt.getFluidState().is(Fluids.WATER)) {
Vec3 playerPos = player.position();
worldIn.playSound(player, playerPos.x, playerPos.y, playerPos.z, SoundEvents.BOTTLE_FILL, SoundSource.NEUTRAL, 1.0F, 1.0F);
stack.shrink(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ public VoxelShape getShape(BlockState state, @NotNull BlockGetter worldIn, @NotN
return state.getValue(TYPE).shape;
}

//TODO: doesn't actually work, "parent" is a slab block, and in vanilla slabs are never conduit frames
@Override
public boolean isConduitFrameZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos conduit) {
BlockState parentState = parent.get().defaultBlockState();
return Quark.ZETA.blockExtensions.get(parentState).isConduitFrameZeta(parentState, world, pos, conduit);
}

@Override
@Nullable
public BlockState getStateForPlacement(BlockPlaceContext context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.violetmoon.quark.content.building.module;

import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
Expand All @@ -20,7 +21,7 @@
public class NetherBrickFenceGateModule extends ZetaModule {
@LoadEvent
public final void register(ZRegister event) {
new ZetaFenceGateBlock("nether_brick_fence_gate", this,
new ZetaFenceGateBlock("nether_brick_fence_gate", this, SoundEvents.NETHER_WOOD_FENCE_GATE_OPEN, SoundEvents.NETHER_WOOD_FENCE_GATE_CLOSE,
OldMaterials.stone()
.mapColor(MapColor.NETHER)
.requiresCorrectToolForDrops()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,6 @@ public boolean namesMatch(ItemStack stack, String search) {
// if(tab != null && matcher.test(tab.getDisplayName().getString().toLowerCase(Locale.ROOT), search))
// return true;

// if(search.matches("favou?rites?") && FavoriteItems.isItemFavorited(stack))
// return true;

ResourceLocation itemName = BuiltInRegistries.ITEM.getKey(item);
@Nullable
String modDisplayName = zeta.getModDisplayName(itemName.getNamespace());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(Equip
UUID uuid = UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150");
builder.put(Attributes.ARMOR, new AttributeModifier(uuid, "Armor modifier", 1, AttributeModifier.Operation.ADDITION));
builder.put(Attributes.LUCK, new AttributeModifier(uuid, "Armor luck modifier", 1, AttributeModifier.Operation.ADDITION));
//Todo: Check me ig

//TODO: Forge extension attributes (but these are on the way out, i guess)
builder.put(ForgeMod.ENTITY_REACH.get(), new AttributeModifier(uuid, "Armor entity reach modifier", 2, AttributeModifier.Operation.ADDITION));
builder.put(ForgeMod.BLOCK_REACH.get(), new AttributeModifier(uuid, "Armor block reach modifier", 2, AttributeModifier.Operation.ADDITION));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ protected void onHit(@NotNull HitResult result) {
BlockPos hit = blockHitResult.getBlockPos();
BlockState state = level().getBlockState(hit);

// TODO find replacement for BlockState#isSolid
// TODO find replacement for BlockState#isSolid since it's deprecated. Vanilla uses it everywhere though
if(getPiercingModifier() == 0 || state.isSolid())
addHit();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.function.BiConsumer;
import java.util.stream.Collectors;

// for Ancient Saplings, TODO register me
// for Ancient Saplings
public class MultiFoliageStraightTrunkPlacer extends TrunkPlacer {
final int foliageDistance;
final int maxBlobs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public WaxModifier(ZetaModule module, Set<Block> unwaxed, Set<Block> waxed) {
public Set<ResourceLocation> getTargets() {
return ImmutableSet.of(TARGET_ON, TARGET_OFF);
}
//

@Override
public boolean apply(ResourceLocation res, IMutableAdvancement adv) {
String title = res.getPath().replaceAll(".+/", "");
Expand All @@ -63,15 +63,4 @@ public boolean apply(ResourceLocation res, IMutableAdvancement adv) {
return true;
}

//todo: Im thinking this goes byebye, but we should see if it is somehow still needed.
private static boolean addToBlockSet(Set<Block> blockSet, Set<Block> ourSet) {
try {
blockSet.addAll(ourSet);
} catch(Exception e) {
return false;
}

return true;
}

}
15 changes: 14 additions & 1 deletion src/main/java/org/violetmoon/zeta/block/ZetaFenceGateBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.function.BooleanSupplier;

import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.level.block.state.properties.WoodType;
import org.jetbrains.annotations.Nullable;

Expand All @@ -18,8 +19,20 @@ public class ZetaFenceGateBlock extends FenceGateBlock implements IZetaBlock {
private final @Nullable ZetaModule module;
private BooleanSupplier enabledSupplier = BooleanSuppliers.TRUE;

/**
* @deprecated Older versions didn't thread the WoodType/SoundEvent constructor parameters thru; do that pls
*/
@Deprecated
public ZetaFenceGateBlock(String regname, @Nullable ZetaModule module, Properties properties) {
super(properties, WoodType.OAK); //TODO 1.20: change parameter or pass SoundType parameters thru
this(regname, module, WoodType.OAK, properties);
}

public ZetaFenceGateBlock(String regname, @Nullable ZetaModule module, WoodType woodType, Properties properties) {
this(regname, module, woodType.fenceGateOpen(), woodType.fenceGateClose(), properties);
}

public ZetaFenceGateBlock(String regname, @Nullable ZetaModule module, SoundEvent open, SoundEvent close, Properties properties) {
super(properties, open, close);
this.module = module;

if(module == null) //auto registration below this line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void render(@NotNull GuiGraphics guiGraphics, int index, int rowTop, int

guiGraphics.drawString(minecraft.font, name, left, top, 0xFFFFFF, true);
if(ext != null)
guiGraphics.drawString(minecraft.font, ext.getSubtitle(changes, def), left, top + 10, 0x999999, true); //TODO: getSubtitle
guiGraphics.drawString(minecraft.font, ext.getSubtitle(changes, def), left, top + 10, 0x999999, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
import org.violetmoon.zeta.event.bus.IZetaPlayEvent;

import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.vertex.PoseStack;

//TODO ZETA: only used for the network profiler
/**
* This event is not fired anymore (quark doesn't need it).
*/
@Deprecated(forRemoval = true)
public interface ZCustomizeDebugText extends IZetaPlayEvent {
@Deprecated
List<String> getLeft();
@Deprecated
List<String> getRight();
@Deprecated
Window getWindow();
@Deprecated
GuiGraphics getGuiGraphics();
@Deprecated
float getPartialTick();
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private void setCategoryEnabled(ZetaCategory cat, boolean enabled) {
else
enabledCategories.remove(cat);

//TODO TODO bad bad bad, just forcing setEnabled to rerun since it checks category enablement
//TODO: hacky, just forcing setEnabled to rerun since it checks category enablement
for(ZetaModule mod : z.modules.modulesInCategory(cat)) {
mod.setEnabled(z, mod.enabled);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

//TODO: maybe we need "boolean equals(T thing1, T thing2)"
public class ValueDefinition<T> extends Definition {
public final @NotNull T defaultValue;
public final @Nullable Predicate<Object> validator;
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/org/violetmoon/zeta/event/bus/ZetaEventBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@

/**
* A polymorphic event bus. Events can be fired under one of their supertypes, allowing a sort of API/impl split of events.
*/
/*
* TODO: No support for generic events (like forge's RegistryEvent<T>). It would be nice.
* - Hellish to reflect these apparently
* TODO: No support for Consumer events (like forge's addListener).
* - I also think these are hard to reflect
*
* Due to implementation complexity, there is unfortunately no support for:
* - generic events (like Forge's RegistryEvent<T>)
* - registering an anonymous `Consumer` (like Forge's "addListener" method)
* Supported Java reflection APIs don't expose this information. Forge can only get at it with a library internally using sun.misc.Unsafe.
*/
public class ZetaEventBus<E> {
private final Zeta z;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public static TentativeModule from(ZetaLoadModuleAnnotationData data, Function<S
} else {
keyClass = clazz;

//leaving the category out of the annotation is only valid for client replacements
//TODO: maybe guess the category from the package name isntead ^^
//Only client replacement modules are allowed to leave off a category annotation (since it uses the same category as the module it's replacing)
if(data.category() == null || data.category().isEmpty())
throw new RuntimeException("Module " + clazz.getName() + " should specify a category");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
Expand All @@ -11,7 +10,6 @@
import java.util.Map;
import java.util.Optional;

import org.jetbrains.annotations.Nullable;
import org.violetmoon.zeta.Zeta;
import org.violetmoon.zeta.event.load.ZModulesReady;
import org.violetmoon.zeta.util.ZetaSide;
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/org/violetmoon/zeta/util/RegistryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ public static <T> List<T> massRegistryGet(Collection<String> coll, Registry<T> r
}

public static <T> List<T> getTagValues(RegistryAccess access, TagKey<T> tag) {
Registry<T> registry = access.registryOrThrow(tag.registry());
//HolderSet<T> holderSet = registry.getTag(tag).orElse(new HolderSet.Named<>(registry, tag)); //TODO 1.20 i dont know what the shit is going on
HolderSet<T> holderSet = registry.getTag(tag).orElse(null);
if(holderSet == null)
return Collections.emptyList();

return holderSet.stream().map(Holder::value).toList();
return access.registryOrThrow(tag.registry())
.getTag(tag)
.map(holderset -> holderset.stream().map(Holder::value).toList()) //tag exists, grab all items from it
.orElseGet(Collections::emptyList); //tag doesn't exist
}

//TODO: Can be made more 'static' when there's a nicer way to get a block's ID, instead of having to consult a particular Zeta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ public void start() {
MinecraftForge.EVENT_BUS.addListener(this::renderBlockHighlight);
MinecraftForge.EVENT_BUS.addListener(this::gatherTooltipComponents);

MinecraftForge.EVENT_BUS.addListener(this::customizeF3);

MinecraftForge.EVENT_BUS.addListener(this::renderContainerScreenForeground);
MinecraftForge.EVENT_BUS.addListener(this::renderContainerScreenBackground);

Expand Down Expand Up @@ -237,10 +235,6 @@ public void gatherTooltipComponents(RenderTooltipEvent.GatherComponents e) {
playBus.fire(new ForgeZGatherTooltipComponents(e), ZGatherTooltipComponents.class);
}

public void customizeF3(CustomizeGuiOverlayEvent.DebugText e) {
playBus.fire(new ForgeZCustomizeDebugText(e), ZCustomizeDebugText.class);
}

public void renderContainerScreenForeground(ContainerScreenEvent.Render.Foreground e) {
playBus.fire(new ForgeZRenderContainerScreen.Foreground(e), ZRenderContainerScreen.Foreground.class);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public <T extends ZetaHandshakeMessage> void registerLogin(Class<T> clazz, ZetaN
else
builder = builder.consumerNetworkThread((BiConsumer<T, Supplier<NetworkEvent.Context>>) (msg, ctxS) -> handlePacket(msg, ctxS, forgeDir)); //Yes you need the cast

//TODO is this strictly needed
if(!hasResponse)
builder = builder.noResponse();

Expand Down

0 comments on commit 07a274c

Please sign in to comment.