Skip to content

Commit

Permalink
Reorganise entry points, definitions, pretty much everything
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Jul 19, 2024
1 parent d2e38e3 commit b8563e1
Show file tree
Hide file tree
Showing 24 changed files with 290 additions and 348 deletions.
4 changes: 2 additions & 2 deletions src/data/java/gripe/_90/fulleng/datagen/FullDropProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import net.minecraft.world.level.storage.loot.predicates.ExplosionCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;

import gripe._90.fulleng.definition.FullEngBlocks;
import gripe._90.fulleng.FullblockEnergistics;

public class FullDropProvider extends LootTableProvider {
public FullDropProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
Expand All @@ -40,7 +40,7 @@ public void generate(@NotNull BiConsumer<ResourceKey<LootTable>, LootTable.Build

@Override
public void generate() {
for (var block : FullEngBlocks.BLOCKS.getEntries()) {
for (var block : FullblockEnergistics.BLOCKS.getEntries()) {
add(
block.get(),
LootTable.lootTable()
Expand Down
23 changes: 12 additions & 11 deletions src/data/java/gripe/_90/fulleng/datagen/FullModelProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
import gripe._90.fulleng.FullblockEnergistics;
import gripe._90.fulleng.block.FullBlock;
import gripe._90.fulleng.block.MonitorBlock;
import gripe._90.fulleng.definition.FullEngBlocks;

public class FullModelProvider extends AE2BlockStateProvider {
private static final ResourceLocation TERMINAL_OFF = FullblockEnergistics.makeId("block/terminal_off");
private static final ResourceLocation TERMINAL_OFF =
ResourceLocation.fromNamespaceAndPath(FullblockEnergistics.MODID, "block/terminal_off");

public FullModelProvider(PackOutput output, ExistingFileHelper existing) {
super(output, FullblockEnergistics.MODID, existing);
}

@Override
protected void registerStatesAndModels() {
terminal(FullEngBlocks.TERMINAL, "ae2:part/terminal");
terminal(FullEngBlocks.CRAFTING_TERMINAL, "ae2:part/crafting_terminal");
terminal(FullEngBlocks.PATTERN_ENCODING_TERMINAL, "ae2:part/pattern_encoding_terminal");
terminal(FullEngBlocks.PATTERN_ACCESS_TERMINAL, "ae2:part/pattern_access_terminal");
terminal(FullblockEnergistics.TERMINAL, "ae2:part/terminal");
terminal(FullblockEnergistics.CRAFTING_TERMINAL, "ae2:part/crafting_terminal");
terminal(FullblockEnergistics.PATTERN_ENCODING_TERMINAL, "ae2:part/pattern_encoding_terminal");
terminal(FullblockEnergistics.PATTERN_ACCESS_TERMINAL, "ae2:part/pattern_access_terminal");

monitor(FullEngBlocks.STORAGE_MONITOR, "ae2:part/storage_monitor");
monitor(FullEngBlocks.CONVERSION_MONITOR, "ae2:part/conversion_monitor");
monitor(FullblockEnergistics.STORAGE_MONITOR, "ae2:part/storage_monitor");
monitor(FullblockEnergistics.CONVERSION_MONITOR, "ae2:part/conversion_monitor");

terminal(FullEngBlocks.REQUESTER_TERMINAL, "merequester:part/requester_terminal");
terminal(FullblockEnergistics.REQUESTER_TERMINAL, "merequester:part/requester_terminal");
}

private void terminal(DeferredBlock<?> terminal, String texturePrefix) {
Expand All @@ -43,14 +43,15 @@ private void terminal(DeferredBlock<?> terminal, String texturePrefix) {
existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_medium"), ModelProvider.TEXTURE);
existing.trackGenerated(ResourceLocation.parse(texturePrefix + "_dark"), ModelProvider.TEXTURE);

var onModel = terminal != FullEngBlocks.TERMINAL
var onModel = terminal != FullblockEnergistics.TERMINAL
? models().withExistingParent(
"block/" + terminal.getId().getPath(), FullblockEnergistics.MODID + ":block/terminal")
.texture("lightsBright", texturePrefix + "_bright")
.texture("lightsMedium", texturePrefix + "_medium")
.texture("lightsDark", texturePrefix + "_dark")
.renderType("cutout")
: models().getExistingFile(FullblockEnergistics.makeId("block/terminal"));
: models().getExistingFile(
ResourceLocation.fromNamespaceAndPath(FullblockEnergistics.MODID, "block/terminal"));

var builder = MultiVariantGenerator.multiVariant(terminal.get())
.with(createFacingSpinDispatch())
Expand Down
26 changes: 16 additions & 10 deletions src/data/java/gripe/_90/fulleng/datagen/FullRecipeProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import net.minecraft.data.recipes.RecipeOutput;
import net.minecraft.data.recipes.RecipeProvider;
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.neoforge.registries.DeferredBlock;

import gripe._90.fulleng.FullblockEnergistics;
import gripe._90.fulleng.block.FullBlock;
import gripe._90.fulleng.definition.FullEngBlocks;
import gripe._90.fulleng.integration.Addons;

public class FullRecipeProvider extends RecipeProvider {
Expand All @@ -25,16 +25,16 @@ public FullRecipeProvider(PackOutput output, CompletableFuture<HolderLookup.Prov

@Override
public void buildRecipes(@NotNull RecipeOutput output) {
block(output, FullEngBlocks.TERMINAL);
block(output, FullEngBlocks.CRAFTING_TERMINAL);
block(output, FullEngBlocks.PATTERN_ENCODING_TERMINAL);
block(output, FullEngBlocks.PATTERN_ACCESS_TERMINAL);
block(output, FullblockEnergistics.TERMINAL);
block(output, FullblockEnergistics.CRAFTING_TERMINAL);
block(output, FullblockEnergistics.PATTERN_ENCODING_TERMINAL);
block(output, FullblockEnergistics.PATTERN_ACCESS_TERMINAL);

block(output, FullEngBlocks.STORAGE_MONITOR);
block(output, FullEngBlocks.CONVERSION_MONITOR);
block(output, FullblockEnergistics.STORAGE_MONITOR);
block(output, FullblockEnergistics.CONVERSION_MONITOR);

if (Addons.MEREQUESTER.isLoaded()) {
block(Addons.MEREQUESTER.conditionalOutput(output), FullEngBlocks.REQUESTER_TERMINAL);
block(Addons.MEREQUESTER.conditionalOutput(output), FullblockEnergistics.REQUESTER_TERMINAL);
}
}

Expand All @@ -45,10 +45,16 @@ private void block(RecipeOutput output, DeferredBlock<? extends FullBlock<?>> bl
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, block)
.requires(part)
.unlockedBy("has_" + partId, has(part))
.save(output, FullblockEnergistics.makeId("terminals/block_" + partId + "_from_part"));
.save(
output,
ResourceLocation.fromNamespaceAndPath(
FullblockEnergistics.MODID, "terminals/block_" + partId + "_from_part"));
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, part)
.requires(block)
.unlockedBy("has_" + partId, has(part))
.save(output, FullblockEnergistics.makeId("terminals/part_" + partId + "_from_block"));
.save(
output,
ResourceLocation.fromNamespaceAndPath(
FullblockEnergistics.MODID, "terminals/part_" + partId + "_from_block"));
}
}
3 changes: 1 addition & 2 deletions src/data/java/gripe/_90/fulleng/datagen/FullTagProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import net.neoforged.neoforge.common.data.BlockTagsProvider;

import gripe._90.fulleng.FullblockEnergistics;
import gripe._90.fulleng.definition.FullEngBlocks;

public class FullTagProvider extends BlockTagsProvider {
public FullTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
Expand All @@ -20,7 +19,7 @@ public FullTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provide

@Override
protected void addTags(@NotNull HolderLookup.Provider provider) {
FullEngBlocks.BLOCKS.getEntries().forEach(b -> tag(BlockTags.MINEABLE_WITH_PICKAXE)
FullblockEnergistics.BLOCKS.getEntries().forEach(b -> tag(BlockTags.MINEABLE_WITH_PICKAXE)
.add(BuiltInRegistries.BLOCK.getResourceKey(b.get()).orElseThrow()));
}

Expand Down
64 changes: 64 additions & 0 deletions src/main/java/gripe/_90/fulleng/FullBlockEnergisticsClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package gripe._90.fulleng;

import java.util.Objects;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
import net.minecraft.world.phys.BlockHitResult;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.client.event.ModelEvent;
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
import net.neoforged.neoforge.network.PacketDistributor;

import appeng.api.util.AEColor;
import appeng.client.render.ColorableBlockEntityBlockColor;
import appeng.client.render.StaticItemColor;
import appeng.core.network.serverbound.PartLeftClickPacket;

import gripe._90.fulleng.block.entity.monitor.ConversionMonitorBlockEntity;
import gripe._90.fulleng.client.MonitorBERenderer;

@SuppressWarnings("unused")
@Mod(value = FullblockEnergistics.MODID, dist = Dist.CLIENT)
public class FullBlockEnergisticsClient {
public FullBlockEnergisticsClient(IEventBus eventBus) {
eventBus.addListener((ModelEvent.RegisterGeometryLoaders event) -> {
BlockEntityRenderers.register(FullblockEnergistics.STORAGE_MONITOR_BE.get(), MonitorBERenderer::new);
BlockEntityRenderers.register(FullblockEnergistics.CONVERSION_MONITOR_BE.get(), MonitorBERenderer::new);
});

eventBus.addListener((RegisterColorHandlersEvent.Block event) -> {
for (var block : FullblockEnergistics.BLOCKS.getEntries()) {
event.register(ColorableBlockEntityBlockColor.INSTANCE, block.get());
}
});

eventBus.addListener((RegisterColorHandlersEvent.Item event) -> {
for (var block : FullblockEnergistics.BLOCKS.getEntries()) {
event.register(new StaticItemColor(AEColor.TRANSPARENT), block.get());
}
});

NeoForge.EVENT_BUS.addListener((PlayerInteractEvent.LeftClickBlock event) -> {
var level = event.getLevel();

if (level.isClientSide()) {
if (!(Minecraft.getInstance().hitResult instanceof BlockHitResult hitResult)) {
return;
}

if (level.getBlockEntity(hitResult.getBlockPos()) instanceof ConversionMonitorBlockEntity monitor
&& hitResult.getDirection() == monitor.getFront()) {
PacketDistributor.sendToServer(
new PartLeftClickPacket(hitResult, event.getEntity().isShiftKeyDown()));
Objects.requireNonNull(Minecraft.getInstance().gameMode).destroyDelay = 5;
event.setCanceled(true);
}
}
});
}
}
Loading

0 comments on commit b8563e1

Please sign in to comment.