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

2.2.0 prep cleanup: Tree tap and various tweaking #784

Merged
merged 13 commits into from
Mar 23, 2024
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
10 changes: 3 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.internal.impldep.org.junit.experimental.categories.Categories.CategoryFilter.exclude

val paradiseLostVersion: String by properties

val minecraftVersion: String by properties
Expand Down Expand Up @@ -118,7 +120,7 @@ dependencies {
group = "net.kyrptonaught",
name = "customportalapi",
version = customportalapiVersion,
).also(::include)
).also(::include).exclude(module = "sodium")

modImplementation(
group = "net.fabricmc.fabric-api",
Expand All @@ -138,12 +140,6 @@ dependencies {
version = entityAttributesVersion,
).also(::include)

modImplementation(
group = "io.github.ladysnake",
name = "satin",
version = satinVersion,
).also(::include)

modImplementation(
group = "dev.emi",
name = "trinkets",
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ entityAttributesVersion=2.3.0
modmenuVersion=4.0.6
reiVersion=9.1.530
moreTagsVersion=3.0.5
satinVersion=1.8.0
clothConfigVersion=8.2.88
2 changes: 0 additions & 2 deletions src/main/java/net/id/paradiselost/ParadiseLost.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.id.paradiselost.client.rendering.entity.ParadiseLostEntityRenderers;
import net.id.paradiselost.client.rendering.item.ParadiseLostItemRenderers;
import net.id.paradiselost.client.rendering.particle.ParadiseLostParticles;
import net.id.paradiselost.client.rendering.shader.ParadiseLostShaders;
import net.id.paradiselost.client.rendering.texture.ParadiseLostTextures;
import net.id.paradiselost.client.rendering.util.ParadiseLostColorProviders;
import net.id.paradiselost.commands.ParadiseLostCommands;
Expand Down Expand Up @@ -125,7 +124,6 @@ public void onInitializeClient() {
ParadiseLostItemRenderers.initClient();
ParadiseLostScreens.initClient();
Conditions.clientInit();
ParadiseLostShaders.init();
ParadiseLostScreens.clientInit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ protected static Action<Block> flammable(int spread, int burn) {
protected static final Action<Block> translucentRenderLayer = onClient((id, block) -> RenderUtils.transparentRenderLayer(block));
protected static final Action<Block> cutoutRenderLayer = onClient((id, block) -> RenderUtils.cutoutRenderLayer(block));
protected static final Action<Block> cutoutMippedRenderLayer = onClient((id, block) -> RenderUtils.cutoutMippedRenderLayer(block));
protected static final Action<Block> auralRenderLayer = onClient((id, block) -> RenderUtils.auralRenderLayer(block));
protected static final Action<Block> auralCutoutMippedRenderLayer = onClient((id, block) -> RenderUtils.auralCutoutMippedRenderLayer(block));

protected static Action<Block> stripsTo(Block stripped) {
return (id, original) -> StrippableBlockRegistry.register(original, stripped);
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/net/id/paradiselost/blocks/ParadiseLostBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import net.id.paradiselost.items.ParadiseLostItems;
import net.id.paradiselost.registry.ParadiseLostRegistryQueues;
import net.id.paradiselost.tag.ParadiseLostBlockTags;
import net.id.paradiselost.util.RenderUtils;
import net.id.paradiselost.world.feature.tree.generator.*;
import net.id.incubus_core.util.RegistryQueue.Action;
import net.id.incubus_core.woodtypefactory.api.WoodSettingsFactory;
Expand All @@ -40,7 +39,6 @@
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.property.Properties;
import net.minecraft.tag.BlockTags;
import net.minecraft.util.math.Vec3i;
import net.minecraft.util.math.intprovider.UniformIntProvider;
import net.minecraft.util.registry.Registry;

Expand Down Expand Up @@ -283,13 +281,6 @@ protected static Settings flowerPot() {
public static final FlowerPotBlock POTTED_LAVENDER_WISTERIA_SAPLING = add("potted_lavender_wisteria_sapling", new FlowerPotBlock(LAVENDER_WISTERIA_SAPLING, flowerPot()), cutoutRenderLayer);
public static final ParadiseLostHangerBlock LAVENDER_WISTERIA_HANGER = add("lavender_wisteria_hanger", new ParadiseLostHangerBlock(lavenderWisteriaColors.hanger()), flammableLeaves, cutoutRenderLayer);

private static final WoodSettingsFactory borealWisteriaColors = wisteriaColors.withLeafColor(MapColor.CYAN);
private static final Vec3i[] auralLeafColors = new Vec3i[]{RenderUtils.toRGB(0xa6ffdd), RenderUtils.toRGB(0x96e5ff), RenderUtils.toRGB(0xd6b3ff), RenderUtils.toRGB(0xffadc6)};
public static final AuralLeavesBlock BOREAL_WISTERIA_LEAVES = add("boreal_wisteria_leaves", new AuralLeavesBlock(borealWisteriaColors.auralNoCollideLeaves(), false, auralLeafColors), flammableLeaves);
public static final SaplingBlock BOREAL_WISTERIA_SAPLING = add("boreal_wisteria_sapling", new ParadiseLostSaplingBlock(new BorealWisteriaSaplingGenerator(), borealWisteriaColors.sapling().luminance(state -> 5)), cutoutRenderLayer);
public static final FlowerPotBlock POTTED_BOREAL_WISTERIA_SAPLING = add("potted_boreal_wisteria_sapling", new FlowerPotBlock(BOREAL_WISTERIA_SAPLING, flowerPot().luminance(state -> 5)), cutoutRenderLayer);
public static final AuralHangerBlock BOREAL_WISTERIA_HANGER = add("boreal_wisteria_hanger", new AuralHangerBlock(borealWisteriaColors.auralHanger(), auralLeafColors), flammableLeaves, auralCutoutMippedRenderLayer);

// Grasses
private static Settings shrub() {
return copy(Blocks.GRASS).mapColor(MapColor.PALE_GREEN);
Expand Down Expand Up @@ -383,8 +374,8 @@ private static Settings cherineTorch() {
return copy(TORCH).ticksRandomly().luminance(state -> 15);
}

public static final CherineTorchBlock CHERINE_TORCH = addImmediately("cherine_torch", new CherineTorchBlock(cherineTorch()), cutoutRenderLayer);
public static final CherineWallTorchBlock CHERINE_TORCH_WALL = addImmediately("cherine_wall_torch", new CherineWallTorchBlock(cherineTorch().dropsLike(CHERINE_TORCH)), cutoutRenderLayer);
public static final CherineTorchBlock CHERINE_TORCH = add("cherine_torch", new CherineTorchBlock(cherineTorch()), cutoutRenderLayer);
public static final CherineWallTorchBlock CHERINE_TORCH_WALL = add("cherine_wall_torch", new CherineWallTorchBlock(cherineTorch().dropsLike(CHERINE_TORCH)), cutoutRenderLayer);

// Usables
public static final IncubatorBlock INCUBATOR = add("incubator", new IncubatorBlock(of(Material.WOOD, MapColor.DULL_RED).strength(2.5f).sounds(BlockSoundGroup.WOOD).nonOpaque()), cutoutMippedRenderLayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
import net.id.paradiselost.recipe.TreeTapRecipe;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.HopperBlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.Packet;
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.state.property.Properties;
import net.minecraft.util.Hand;
import net.minecraft.util.ItemScatterer;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -33,26 +37,54 @@ public TreeTapBlockEntity(BlockPos pos, BlockState state) {
}

public void handleUse(PlayerEntity player, Hand hand, ItemStack handStack) {
ItemStack stored = inventory.get(0);
inventory.set(0, handStack);
player.setStackInHand(hand, stored);
markDirty();
ItemStack stored = inventory.get(0);
if (!handStack.isEmpty() && inventory.get(0).isEmpty()) {
inventory.set(0, handStack.split(1));
} else {
player.giveItemStack(stored);
inventory.set(0, ItemStack.EMPTY);
}
markDirty();
}

@Override
public boolean canInsert(int slot, ItemStack stack, @Nullable Direction dir) {
return this.getHopperStrategy().canInsert(dir) && this.inventory.get(0).isEmpty();
}

@Override
public boolean canExtract(int slot, ItemStack stack, Direction dir) {
return this.getHopperStrategy().canExtract(dir);
}

@Override
public @NotNull HopperStrategy getHopperStrategy() {
return HopperStrategy.IN_ANY_OUT_BOTTOM;
return HopperStrategy.IN_ANY;
}

@Override
public DefaultedList<ItemStack> getItems() {
return inventory;
}

@Override
public void setStack(int slot, ItemStack stack) {
getItems().set(slot, stack);
if (stack.getCount() > 1) {
stack.setCount(1);
}
inventoryChanged();
}

private void inventoryChanged() {
markDirty();
if (world != null && !world.isClient) updateInClientWorld();
}

@Override
public void readNbt(NbtCompound nbt) {
super.readNbt(nbt);

this.inventory.clear();
Inventories.readNbt(nbt, inventory);
}

Expand All @@ -73,17 +105,18 @@ public void tryCraft() {
}

Optional<TreeTapRecipe> recipe = this.world.getRecipeManager().getFirstMatch(ParadiseLostRecipeTypes.TREE_TAP_RECIPE_TYPE, this, this.world);
if (recipe.isPresent()) {
if (recipe.isPresent() && world.random.nextInt(recipe.get().getChance()) == 0) {
ItemStack output = recipe.get().craft(this);
stack.decrement(1);

// TODO: play a sound?
if (stack.isEmpty()) {
this.inventory.set(0, output);
updateInClientWorld();
} else {
ItemScatterer.spawn(world, pos.getX(), pos.getY(), pos.getZ(), output);
}
if (!world.isClient) world.playSound(null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, 0.5f, world.getRandom().nextFloat() * 0.4f + 0.8f);

inventoryChanged();
BlockEntity possibleHopper = world.getBlockEntity(pos.down());
if (possibleHopper instanceof Inventory) {
output = HopperBlockEntity.transfer(this, (Inventory) possibleHopper, output, Direction.UP);
}
this.inventory.set(0, output);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public BlockState getPlacementState(ItemPlacementContext ctx) {
if (!direction.getAxis().isHorizontal()) {
return null;
}

return this.getDefaultState().with(FACING, direction);
}

Expand All @@ -98,7 +97,6 @@ public BlockState mirror(BlockState state, BlockMirror mirror) {
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
super.randomTick(state, world, pos, random);

if (!world.isClient && world.getBlockEntity(pos) instanceof TreeTapBlockEntity treeTapBlockEntity) {
treeTapBlockEntity.tryCraft();
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public static BlockState getHanger(BlockState state) {
return ParadiseLostBlocks.LAVENDER_WISTERIA_HANGER.getDefaultState();
} else if (state.isOf(ParadiseLostBlocks.FROST_WISTERIA_LEAVES)) {
return ParadiseLostBlocks.FROST_WISTERIA_HANGER.getDefaultState();
} else if (state.isOf(ParadiseLostBlocks.BOREAL_WISTERIA_LEAVES)) {
return ParadiseLostBlocks.BOREAL_WISTERIA_HANGER.getDefaultState();
}
return Blocks.AIR.getDefaultState();
}
Expand Down
Loading
Loading