Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.21.1 #38

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -46,7 +46,7 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
it.options.release = 17
it.options.release = 21
}

java {
Expand All @@ -55,8 +55,8 @@ java {
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
loader_version=0.14.24
yarn_mappings=1.20.1+build.10
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.15.11

# Mod Properties
mod_version=1.0.2-fabric
mod_version=1.1.0-fabric
maven_group=com.ninni.dye_depot
archives_base_name=dye_depot

# Dependencies
fabric_version=0.90.4+1.20.1
fabric_version=0.103.0+1.21.1
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
32 changes: 21 additions & 11 deletions src/main/java/com/ninni/dye_depot/DyeDepot.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
package com.ninni.dye_depot;

import com.google.common.reflect.Reflection;
import com.ninni.dye_depot.registry.*;
import net.fabricmc.api.ModInitializer;
import net.minecraft.resources.ResourceLocation;

public class DyeDepot implements ModInitializer {
public static final String MOD_ID = "dye_depot";

private static boolean initialized = false;
@Override
public void onInitialize() {
initialized = true;

DDVanillaIntegration.serverInit();
Reflection.initialize(
DDItems.class,
DDBlocks.class,
DDBlockEntityType.class,
DDParticles.class,
DDSoundEvents.class,
DDLootTables.class,
DDCreativeModeTabs.class
);

DDItems.init();
DDBlocks.init();
DDBlockEntityTypes.init();
DDParticles.init();
DDSoundEvents.init();
DDCreativeModeTabs.init();
DDMapDecorationTypes.init();

}

public static boolean isInitialized() {
return initialized;
}

public static ResourceLocation id(String name) {
return ResourceLocation.fromNamespaceAndPath(MOD_ID, name);
}
}
58 changes: 57 additions & 1 deletion src/main/java/com/ninni/dye_depot/DyeDepotClient.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,69 @@
package com.ninni.dye_depot;

import com.ninni.dye_depot.client.particles.PoofParticle;
import com.ninni.dye_depot.client.renderer.DDBannerRenderer;
import com.ninni.dye_depot.registry.DDBlockEntityTypes;
import com.ninni.dye_depot.registry.DDBlocks;
import com.ninni.dye_depot.registry.DDParticles;
import com.ninni.dye_depot.registry.DDVanillaIntegration;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;


public class DyeDepotClient implements ClientModInitializer {

@Override
public void onInitializeClient() {
DDVanillaIntegration.Client.clientInit();
registerModelLayers();
registerBlockRenderLayers();
registerParticles();
}

private static void registerModelLayers() {
BlockEntityRenderers.register(DDBlockEntityTypes.BANNER, DDBannerRenderer::new);
}

private static void registerParticles() {
ParticleFactoryRegistry.getInstance().register(DDParticles.DYE_POOF, PoofParticle.Provider::new);
}

private static void registerBlockRenderLayers() {
BlockRenderLayerMap.INSTANCE.putBlocks(RenderType.translucent(),
DDBlocks.MAROON_STAINED_GLASS,
DDBlocks.ROSE_STAINED_GLASS,
DDBlocks.CORAL_STAINED_GLASS,
DDBlocks.INDIGO_STAINED_GLASS,
DDBlocks.NAVY_STAINED_GLASS,
DDBlocks.SLATE_STAINED_GLASS,
DDBlocks.OLIVE_STAINED_GLASS,
DDBlocks.AMBER_STAINED_GLASS,
DDBlocks.BEIGE_STAINED_GLASS,
DDBlocks.TEAL_STAINED_GLASS,
DDBlocks.MINT_STAINED_GLASS,
DDBlocks.AQUA_STAINED_GLASS,
DDBlocks.VERDANT_STAINED_GLASS,
DDBlocks.FOREST_STAINED_GLASS,
DDBlocks.GINGER_STAINED_GLASS,
DDBlocks.TAN_STAINED_GLASS,
DDBlocks.MAROON_STAINED_GLASS_PANE,
DDBlocks.ROSE_STAINED_GLASS_PANE,
DDBlocks.CORAL_STAINED_GLASS_PANE,
DDBlocks.INDIGO_STAINED_GLASS_PANE,
DDBlocks.NAVY_STAINED_GLASS_PANE,
DDBlocks.SLATE_STAINED_GLASS_PANE,
DDBlocks.OLIVE_STAINED_GLASS_PANE,
DDBlocks.AMBER_STAINED_GLASS_PANE,
DDBlocks.BEIGE_STAINED_GLASS_PANE,
DDBlocks.TEAL_STAINED_GLASS_PANE,
DDBlocks.MINT_STAINED_GLASS_PANE,
DDBlocks.AQUA_STAINED_GLASS_PANE,
DDBlocks.VERDANT_STAINED_GLASS_PANE,
DDBlocks.FOREST_STAINED_GLASS_PANE,
DDBlocks.GINGER_STAINED_GLASS_PANE,
DDBlocks.TAN_STAINED_GLASS_PANE
);
}
}
31 changes: 11 additions & 20 deletions src/main/java/com/ninni/dye_depot/block/DDAbstractBannerBlock.java
Original file line number Diff line number Diff line change
@@ -1,46 +1,37 @@
package com.ninni.dye_depot.block;

import com.ninni.dye_depot.registry.DDBlockEntityType;
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.AbstractBannerBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

public class DDAbstractBannerBlock extends AbstractBannerBlock {
public abstract class DDAbstractBannerBlock extends AbstractBannerBlock {
private final DyeColor color;

protected DDAbstractBannerBlock(DyeColor dyeColor, Properties properties) {
super(dyeColor, properties);
this.color = dyeColor;
}

protected abstract MapCodec<? extends AbstractBannerBlock> codec();

@Override
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
return new DDBannerBlockEntity(blockPos, blockState, this.getColor());
}

@Override
public void setPlacedBy(Level level, BlockPos blockPos, BlockState blockState, @Nullable LivingEntity livingEntity, ItemStack itemStack) {
if (level.isClientSide) {
level.getBlockEntity(blockPos, DDBlockEntityType.BANNER).ifPresent(bannerBlockEntity -> bannerBlockEntity.fromItem(itemStack));
} else if (itemStack.hasCustomHoverName()) {
level.getBlockEntity(blockPos, DDBlockEntityType.BANNER).ifPresent(bannerBlockEntity -> bannerBlockEntity.setCustomName(itemStack.getHoverName()));
}
}

@Override
public ItemStack getCloneItemStack(BlockGetter blockGetter, BlockPos blockPos, BlockState blockState) {
BlockEntity blockEntity = blockGetter.getBlockEntity(blockPos);
if (blockEntity instanceof DDBannerBlockEntity) {
return ((DDBannerBlockEntity)blockEntity).getItem();
public ItemStack getCloneItemStack(LevelReader levelReader, BlockPos blockPos, BlockState blockState) {
BlockEntity var5 = levelReader.getBlockEntity(blockPos);
if (var5 instanceof DDBannerBlockEntity blockEntity) {
return blockEntity.getItem();
} else {
return super.getCloneItemStack(levelReader, blockPos, blockState);
}
return super.getCloneItemStack(blockGetter, blockPos, blockState);
}

public DyeColor getColor() {
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/ninni/dye_depot/block/DDBannerBlock.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.ninni.dye_depot.block;

import com.google.common.collect.Maps;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.ninni.dye_depot.registry.DDBlocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand All @@ -20,8 +22,14 @@
import net.minecraft.world.phys.shapes.VoxelShape;

import java.util.Map;
import java.util.function.BiFunction;

public class DDBannerBlock extends DDAbstractBannerBlock {
public static final MapCodec<DDBannerBlock> CODEC = RecordCodecBuilder.mapCodec(instance -> instance.group(
DyeColor.CODEC.fieldOf("color").forGetter(DDAbstractBannerBlock::getColor),
propertiesCodec()
).apply(instance, (DDBannerBlock::new)));

public static final IntegerProperty ROTATION = BlockStateProperties.ROTATION_16;
private static final Map<DyeColor, Block> BY_COLOR = Maps.newHashMap();
private static final VoxelShape SHAPE = Block.box(4.0, 0.0, 4.0, 12.0, 16.0, 12.0);
Expand All @@ -32,6 +40,11 @@ public DDBannerBlock(DyeColor dyeColor, BlockBehaviour.Properties properties) {
BY_COLOR.put(dyeColor, this);
}

@Override
protected MapCodec<DDBannerBlock> codec() {
return CODEC;
}

@Override
public boolean canSurvive(BlockState blockState, LevelReader levelReader, BlockPos blockPos) {
return levelReader.getBlockState(blockPos.below()).isSolid();
Expand Down
Loading