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

Too much stuff that I should have split up b2.2.0 final push #791

Merged
merged 25 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from 24 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
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ val satinVersion: String by properties
val clothConfigVersion: String by properties

plugins {
id("fabric-loom") version "0.12-SNAPSHOT"
id("fabric-loom") version "1.0-SNAPSHOT"
id("com.modrinth.minotaur") version "1.2.1"
id("de.guntram.mcmod.crowdin-translate") version "1.4+1.19"
`maven-publish`
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# suppress inspection "UnusedProperty" for whole file
org.gradle.jvmargs=-Xmx2G

paradiseLostVersion=2.1.0-beta+1.19.2
paradiseLostVersion=2.2.0-beta+1.19.2

minecraftVersion=1.19.2
yarnVersion=1.19.2+build.28
loaderVersion=0.15.7
javaVersion=17

fabricApiVersion=0.77.0+1.19.2
incubusCoreVersion=1.9.4
incubusCoreVersion=2.0.0
customportalapiVersion=0.0.1-beta63.5-1.19.X
cardinalComponentsVersion=5.0.1
trinketsVersion=3.4.0
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/net/id/paradiselost/ParadiseLost.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import net.id.paradiselost.client.rendering.util.ParadiseLostColorProviders;
import net.id.paradiselost.commands.ParadiseLostCommands;
import net.id.paradiselost.config.ParadiseLostConfig;
import net.id.paradiselost.effect.ParadiseLostStatusEffects;
import net.id.paradiselost.effect.condition.Conditions;
import net.id.paradiselost.entities.ParadiseLostEntityTypes;
import net.id.paradiselost.entities.passive.moa.MoaRaces;
import net.id.paradiselost.fluids.ParadiseLostFluids;
Expand Down Expand Up @@ -83,7 +81,6 @@ public void onInitialize() {
ParadiseLostFeatures.init();
ParadiseLostBiomes.init();
ParadiseLostDimension.init();
ParadiseLostStatusEffects.init();
ParadiseLostBlocks.init();
ParadiseLostFluids.init();
ParadiseLostEntityTypes.init();
Expand All @@ -94,7 +91,6 @@ public void onInitialize() {
ParadiseLostGameRules.init();
ParadiseLostLootNumberProviderTypes.init();
ParadiseLostSoundEvents.init();
Conditions.init();
MoaRaces.init();
ParadiseLostScreens.init();
ParadiseLostLore.init();
Expand Down Expand Up @@ -123,7 +119,6 @@ public void onInitializeClient() {
ParadiseLostBlocks.initClient();
ParadiseLostItemRenderers.initClient();
ParadiseLostScreens.initClient();
Conditions.clientInit();
ParadiseLostScreens.clientInit();
}

Expand Down
291 changes: 291 additions & 0 deletions src/main/java/net/id/paradiselost/blocks/BlockRegistration.java

Large diffs are not rendered by default.

286 changes: 62 additions & 224 deletions src/main/java/net/id/paradiselost/blocks/ParadiseLostBlocks.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.id.paradiselost.blocks.blockentity;

import net.id.paradiselost.blocks.mechanical.FoodBowlBlock;
import net.id.incubus_core.be.InventoryBlockEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.ItemEntity;
Expand All @@ -11,11 +10,8 @@
import net.minecraft.util.Hand;
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;

public class FoodBowlBlockEntity extends BlockEntity implements InventoryBlockEntity {
public class FoodBowlBlockEntity extends BlockEntity {
private final DefaultedList<ItemStack> inventory;

public FoodBowlBlockEntity(BlockPos pos, BlockState state) {
Expand Down Expand Up @@ -57,19 +53,7 @@ private void updateState() {
world.setBlockState(pos, getCachedState().with(FoodBowlBlock.FULL, !inventory.get(0).isEmpty()));
}

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

@SuppressWarnings("ConstantConditions")
@Override
public boolean canInsert(int slot, ItemStack stack, @Nullable Direction dir) {
return InventoryBlockEntity.super.canInsert(slot, stack, dir) && stack.isFood() && stack.getItem().getFoodComponent().isMeat();
}

@Override
public DefaultedList<ItemStack> getItems() {
return inventory;
public ItemStack getContainedItem() {
return inventory.get(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.id.paradiselost.component.MoaGenes;
import net.id.paradiselost.items.ParadiseLostItems;
import net.id.paradiselost.util.ParadiseLostSoundEvents;
import net.id.incubus_core.be.InventoryBlockEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
Expand All @@ -14,11 +13,10 @@
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.jetbrains.annotations.NotNull;

import java.util.UUID;

public class IncubatorBlockEntity extends BlockEntity implements InventoryBlockEntity {
public class IncubatorBlockEntity extends BlockEntity {

private UUID owner;
private int hatchTicks = 100;
Expand Down Expand Up @@ -52,9 +50,12 @@ public void handleUse(PlayerEntity player, Hand hand, ItemStack handStack) {
hatchTicks = (int) (12000 / world.getBiome(pos).value().getTemperature());
}

@Override
public DefaultedList<ItemStack> getItems() {
return inventory;
public boolean hasItem() {
return !inventory.isEmpty();
}

public ItemStack getItem() {
return inventory.get(0);
}

@Override
Expand All @@ -69,8 +70,4 @@ public void readNbt(NbtCompound nbt) {
hatchTicks = nbt.getInt("hatchTicks");
}

@Override
public @NotNull HopperStrategy getHopperStrategy() {
return HopperStrategy.ALL_PASS;
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
package net.id.paradiselost.blocks.blockentity;

import net.id.incubus_core.be.InventoryBlockEntity;
import net.id.paradiselost.recipe.ParadiseLostRecipeTypes;
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.block.entity.LootableContainerBlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SidedInventory;
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.screen.ScreenHandler;
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.text.Text;
import net.minecraft.util.Hand;
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;

import java.util.List;
import java.util.Optional;

public class TreeTapBlockEntity extends BlockEntity implements InventoryBlockEntity {
public class TreeTapBlockEntity extends LootableContainerBlockEntity implements SidedInventory {

private final DefaultedList<ItemStack> inventory;

Expand All @@ -47,24 +51,27 @@ public void handleUse(PlayerEntity player, Hand hand, ItemStack handStack) {
markDirty();
}

public int[] getAvailableSlots(Direction side) {
return new int[1];
}
MBatt1 marked this conversation as resolved.
Show resolved Hide resolved

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

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

@Override
public @NotNull HopperStrategy getHopperStrategy() {
return HopperStrategy.IN_ANY;
public DefaultedList<ItemStack> getItems() {
return inventory;
}

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

@Override
Expand All @@ -76,6 +83,16 @@ public void setStack(int slot, ItemStack stack) {
inventoryChanged();
}

@Override
protected DefaultedList<ItemStack> getInvStackList() {
return inventory;
}

@Override
protected void setInvStackList(DefaultedList<ItemStack> list) {
inventory.set(0, list.get(0));
}

private void inventoryChanged() {
markDirty();
if (world != null && !world.isClient) updateInClientWorld();
Expand All @@ -94,7 +111,17 @@ public void writeNbt(NbtCompound nbt) {
Inventories.writeNbt(nbt, inventory);
}

public BlockState getTappedState() {
@Override
protected Text getContainerName() {
return null;
}

@Override
protected ScreenHandler createScreenHandler(int syncId, PlayerInventory playerInventory) {
return null;
}

public BlockState getTappedState() {
return this.world.getBlockState(this.pos.offset(getCachedState().get(Properties.HORIZONTAL_FACING).getOpposite()));
}

Expand All @@ -111,15 +138,27 @@ public void tryCraft() {

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);
inventoryChanged();
}
tryTansferItemsOut();
}

public void tryTansferItemsOut() {
ItemStack stack = getStack(0);
if (stack.isEmpty()) {
return;
}

ItemStack contents = this.inventory.get(0);
BlockEntity possibleHopper = world.getBlockEntity(pos.down());
if (possibleHopper instanceof Inventory) {
contents = HopperBlockEntity.transfer(this, (Inventory) possibleHopper, contents, Direction.UP);
}
this.inventory.set(0, contents);
inventoryChanged();
}
MBatt1 marked this conversation as resolved.
Show resolved Hide resolved

@Override
public NbtCompound toInitialChunkDataNbt() {
NbtCompound nbtCompound = new NbtCompound();
Expand Down
Loading
Loading