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

Updating 1.19.4 branch #88

Merged
merged 6 commits into from
Apr 15, 2023
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ org.gradle.parallel = true
# Mod Properties
mod_name = Jineric Mod
mod_id = jineric
version = b4.2.0+1.19.4
version = b4.3.0+1.19.4
maven_group = jingy.jineric
22 changes: 11 additions & 11 deletions src/main/java/jingy/jineric/block/JinericBlocks.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package jingy.jineric.block;

import jingy.jineric.base.JinericMain;
import jingy.jineric.block.enums.JinericChestType;
import jingy.jineric.registry.JinericBlockEntityType;
import jingy.jineric.registry.JinericBlockSettings;
import jingy.jineric.sound.JinericSoundGroups;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
Expand Down Expand Up @@ -280,16 +280,16 @@ public class JinericBlocks {
public static final Block WAXED_OXIDIZED_CUT_COPPER_WALL = register("waxed_oxidized_cut_copper_wall", new OxidizableCopperWallBlock(Oxidizable.OxidationLevel.OXIDIZED, FabricBlockSettings.copy(OXIDIZED_CUT_COPPER)));

//CHESTS
public static final Block ACACIA_CHEST = register("acacia_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.ACACIA));
public static final Block BIRCH_CHEST = register("birch_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.BIRCH));
// public static final Block BOREAL_CHEST = register("boreal_chest", new FabricBlockSettingsBase(FabricBlockSettings.copy(CHEST), JinericChestType.BOREAL));
public static final Block CRIMSON_CHEST = register("crimson_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.CRIMSON) );
public static final Block DARK_OAK_CHEST = register("dark_oak_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.DARK_OAK));
public static final Block JUNGLE_CHEST = register("jungle_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.JUNGLE));
public static final Block SHULKER_CHEST = register("shulker_chest", new ShulkerChestBlock(FabricBlockSettings.of(Material.STONE), JinericChestType.SHULKER));
public static final Block SPRUCE_CHEST = register("spruce_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.SPRUCE));
public static final Block WARPED_CHEST = register("warped_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.WARPED));
public static final Block MANGROVE_CHEST = register("mangrove_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), JinericChestType.MANGROVE));
public static final Block ACACIA_CHEST = register("acacia_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.ACACIA));
public static final Block BIRCH_CHEST = register("birch_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.BIRCH));
//// public static final Block BOREAL_CHEST = register("boreal_chest", new FabricBlockSettingsBase(FabricBlockSettings.copy(CHEST), JinericChestType.BOREAL));
public static final Block CRIMSON_CHEST = register("crimson_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.CRIMSON) );
public static final Block DARK_OAK_CHEST = register("dark_oak_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.DARK_OAK));
public static final Block JUNGLE_CHEST = register("jungle_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.JUNGLE));
// public static final Block SHULKER_CHEST = register("shulker_chest", new ShulkerChestBlock(FabricBlockSettings.of(Material.STONE), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.SHULKER));
public static final Block SPRUCE_CHEST = register("spruce_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.SPRUCE));
public static final Block WARPED_CHEST = register("warped_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.WARPED));
public static final Block MANGROVE_CHEST = register("mangrove_chest", new JinericChestBlock(FabricBlockSettings.copy(CHEST), () -> JinericBlockEntityType.JINERIC_CHEST, WoodType.MANGROVE));

public static final Block REFINERY = register("refinery", new RefineryBlock(FabricBlockSettings.copy(FURNACE).luminance(state -> 13)));

Expand Down
41 changes: 24 additions & 17 deletions src/main/java/jingy/jineric/block/JinericChestBlock.java
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
package jingy.jineric.block;

import jingy.jineric.block.entity.JinericChestBlockEntity;
import jingy.jineric.block.enums.JinericChestType;
import net.minecraft.block.BlockState;
import net.minecraft.block.ChestBlock;
import net.minecraft.block.DoubleBlockProperties;
import jingy.jineric.registry.JinericBlockEntityType;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.ChestBlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.DoubleInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.screen.GenericContainerScreenHandler;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;
import java.util.function.BiPredicate;
import java.util.function.Supplier;

public class JinericChestBlock extends ChestBlock {
private final JinericChestType type;
private final WoodType type;

public JinericChestBlock(Settings settings, JinericChestType type) {
super(settings, type::getBlockEntityType);
public JinericChestBlock(Settings settings, Supplier<BlockEntityType<? extends ChestBlockEntity>> supplier, WoodType type) {
super(settings, supplier);
this.type = type;
}

@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return this.type.getEntity(pos, state);
return new JinericChestBlockEntity(JinericBlockEntityType.JINERIC_CHEST, pos, state);
}

private static final DoubleBlockProperties.PropertyRetriever<JinericChestBlockEntity, Optional<NamedScreenHandlerFactory>> NAME_RETRIEVER = new DoubleBlockProperties.PropertyRetriever<>() {

public Optional<NamedScreenHandlerFactory> getFromBoth(JinericChestBlockEntity jinericChestBlockEntity, JinericChestBlockEntity jinericChestBlockEntity2) {
final Inventory inventory = new DoubleInventory(jinericChestBlockEntity, jinericChestBlockEntity2);
return Optional.of(new NamedScreenHandlerFactory() {
Expand All @@ -53,29 +51,39 @@ public ScreenHandler createMenu(int i, PlayerInventory playerInventory, PlayerEn
return null;
}
}

@Override
public net.minecraft.text.Text getDisplayName() {
if (jinericChestBlockEntity.hasCustomName()) {
return jinericChestBlockEntity.getDisplayName();
} else {
return (Text) (jinericChestBlockEntity2.hasCustomName() ? jinericChestBlockEntity2.getDisplayName() : jinericChestBlockEntity.getChestTypeKey());
BlockState blockState = jinericChestBlockEntity.getCachedState();
WoodType woodType = JinericChestBlock.getWoodType(blockState.getBlock());
return (jinericChestBlockEntity2.hasCustomName() ? jinericChestBlockEntity2.getDisplayName() : jinericChestBlockEntity.getChestTypeKey(woodType));
}
}
});
}

public Optional<NamedScreenHandlerFactory> getFrom(JinericChestBlockEntity chestBlockEntity) {
return Optional.of(chestBlockEntity);
}

public Optional<NamedScreenHandlerFactory> getFallback() {
return Optional.empty();
}
};

public JinericChestType getType() {
return type;
public WoodType getWoodType() {
return this.type;
}

public static WoodType getWoodType(Block block) {
WoodType woodType;
if (block instanceof JinericChestBlock) {
woodType = ((JinericChestBlock)block).getWoodType();
}
else {
woodType = WoodType.OAK;
}
return woodType;
}

public BlockEntityType<? extends JinericChestBlockEntity> getExpectedEntityType() {
Expand All @@ -92,7 +100,6 @@ public DoubleBlockProperties.PropertySource<? extends JinericChestBlockEntity> g
} else {
biPredicate = JinericChestBlock::isChestBlocked;
}

return DoubleBlockProperties.toPropertySource(
(BlockEntityType<? extends JinericChestBlockEntity>)this.entityTypeRetriever.get(),
JinericChestBlock::getDoubleBlockType, JinericChestBlock::getFacing,
Expand Down
25 changes: 11 additions & 14 deletions src/main/java/jingy/jineric/block/ShulkerChestBlock.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package jingy.jineric.block;

import jingy.jineric.block.entity.ShulkerChestBlockEntity;
import jingy.jineric.block.enums.JinericChestType;
import jingy.jineric.registry.JinericBlockEntityType;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.WoodType;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.ChestBlockEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.function.Supplier;

public class ShulkerChestBlock extends JinericChestBlock {
public ShulkerChestBlock(FabricBlockSettings settings, JinericChestType type) {
super(settings, type);
public ShulkerChestBlock(FabricBlockSettings settings, Supplier<BlockEntityType<? extends ChestBlockEntity>> supplier, WoodType type) {
super(settings, supplier, type);
}

@Override
Expand All @@ -27,9 +24,9 @@ public BlockState getPlacementState(ItemPlacementContext ctx) {
.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER);
}

@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return world.isClient ? checkType(type, JinericBlockEntityType.SHULKER_CHEST, ShulkerChestBlockEntity::clientTick) : null;
}
// @Nullable
// @Override
// public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
// return world.isClient ? checkType(type, JinericBlockEntityType.SHULKER_CHEST, ShulkerChestBlockEntity::clientTick) : null;
// }
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,52 @@
package jingy.jineric.block.entity;

import jingy.jineric.block.enums.JinericChestType;
import jingy.jineric.registry.JinericBlockEntityType;
import net.minecraft.block.BlockState;
import net.minecraft.block.WoodType;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.ChestBlockEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;

public class JinericChestBlockEntity extends ChestBlockEntity {
private final JinericChestType type;
import static net.minecraft.block.WoodType.*;

public JinericChestBlockEntity(JinericChestType type, BlockPos blockPos, BlockState blockState) {
super(type.getBlockEntityType(), blockPos, blockState);
this.type = type;
public class JinericChestBlockEntity extends ChestBlockEntity {
public JinericChestBlockEntity(BlockEntityType<?> type, BlockPos blockPos, BlockState blockState) {
super(type, blockPos, blockState);
this.setInvStackList(DefaultedList.ofSize(this.size(), ItemStack.EMPTY));
}

public JinericChestType getChestType() {
return type;
public JinericChestBlockEntity(BlockPos blockPos, BlockState state) {
super(JinericBlockEntityType.JINERIC_CHEST, blockPos, state);
}

@Override
public int size() {
return type.size;
return 27;
}

public Text getChestTypeKey() {
return switch (getChestType()) {
case ACACIA -> Text.translatable("container.chestAcaciaDouble");
case BIRCH -> Text.translatable("container.chestBirchDouble");
case CRIMSON -> Text.translatable("container.chestCrimsonDouble");
case DARK_OAK -> Text.translatable("container.chestDarkOakDouble");
case JUNGLE -> Text.translatable("container.chestJungleDouble");
case SPRUCE -> Text.translatable("container.chestSpruceDouble");
case WARPED -> Text.translatable("container.chestWarpedDouble");
case MANGROVE -> Text.translatable("container.chestMangroveDouble");
case SHULKER -> null;
};
public Text getChestTypeKey(WoodType woodType) {
if (woodType == ACACIA) {
return Text.translatable("container.chestAcaciaDouble");
} else if (woodType == BIRCH) {
return Text.translatable("container.chestBirchDouble");
} else if (woodType == CRIMSON) {
return Text.translatable("container.chestCrimsonDouble");
} else if (woodType == DARK_OAK) {
return Text.translatable("container.chestDarkOakDouble");
} else if (woodType == JUNGLE) {
return Text.translatable("container.chestJungleDouble");
} else if (woodType == SPRUCE) {
return Text.translatable("container.chestSpruceDouble");
} else if (woodType == WARPED) {
return Text.translatable("container.chestWarpedDouble");
} else if (woodType == MANGROVE) {
return Text.translatable("container.chestMangroveDouble");
} else {
return Text.literal("No Display Name Set");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package jingy.jineric.block.entity;

import jingy.jineric.block.enums.JinericChestType;
import jingy.jineric.registry.JinericBlockEntityType;
import jingy.jineric.screen.ShulkerChestScreenHandler;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.ChestBlockEntity;
import net.minecraft.block.entity.ChestLidAnimator;
import net.minecraft.block.entity.ViewerCountManager;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -17,15 +18,16 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class ShulkerChestBlockEntity extends JinericChestBlockEntity {
public class ShulkerChestBlockEntity extends ChestBlockEntity {
private final ChestLidAnimator lidAnimator = new ChestLidAnimator();

// @Nullable
// private final DyeColor color;

public ShulkerChestBlockEntity(
// @Nullable DyeColor color,
BlockPos blockPos, BlockState blockState) {
super(JinericChestType.SHULKER, blockPos, blockState);
super(JinericBlockEntityType.JINERIC_CHEST, blockPos, blockState);
// this.color = color;
this.setInvStackList(DefaultedList.ofSize(this.size(), ItemStack.EMPTY));
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading