Skip to content

Commit

Permalink
Merge branch '1.18' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Buuz135 committed Aug 29, 2022
2 parents d109adb + 7c52df7 commit fdce055
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle'

group = 'com.buuz135'
version = '1.19.2-1.0.4'
version = '1.19.2-1.0.6'

java {
archivesBaseName = 'functionalstorage'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
"recipe": {
"type": "minecraft:crafting_shaped",
"key": {
<<<<<<< HEAD
=======
"S": {
"item": "minecraft:iron_nugget"
},
"P": {
"item": "minecraft:piston"
},
>>>>>>> 1.18
"D": [
{
"item": "functionalstorage:framed_1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,13 @@ public List<ItemStack> getDrops(BlockState p_60537_, LootContext.Builder builder
NonNullList<ItemStack> stacks = NonNullList.create();
ItemStack stack = new ItemStack(this);
BlockEntity drawerTile = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
if (drawerTile instanceof ControllableDrawerTile) {
if (!((ControllableDrawerTile<?>) drawerTile).isEverythingEmpty()) {
if (drawerTile instanceof ControllableDrawerTile tile) {
if (!tile.isEverythingEmpty()) {
stack.getOrCreateTag().put("Tile", drawerTile.saveWithoutMetadata());
}
if (tile.isLocked()){
stack.getOrCreateTag().putBoolean("Locked", tile.isLocked());
}
}
stacks.add(stack);
return stacks;
Expand All @@ -183,10 +186,18 @@ public NonNullList<ItemStack> getDynamicDrops(BlockState state, Level worldIn, B
public void setPlacedBy(Level level, BlockPos pos, BlockState p_49849_, @Nullable LivingEntity p_49850_, ItemStack stack) {
super.setPlacedBy(level, pos, p_49849_, p_49850_, stack);
if (stack.hasTag()) {
BlockEntity entity = level.getBlockEntity(pos);
if (entity instanceof ControllableDrawerTile && stack.getTag().contains("Tile")) {
entity.load(stack.getTag().getCompound("Tile"));
((ControllableDrawerTile<?>) entity).markForUpdate();
if (stack.getTag().contains("Tile")){
BlockEntity entity = level.getBlockEntity(pos);
if (entity instanceof ControllableDrawerTile tile) {
entity.load(stack.getTag().getCompound("Tile"));
tile.markForUpdate();
}
}
if (stack.getTag().contains("Locked")){
BlockEntity entity = level.getBlockEntity(pos);
if (entity instanceof ControllableDrawerTile tile) {
tile.setLocked(stack.getTag().getBoolean("Locked"));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.BlockGetter;
Expand Down Expand Up @@ -68,6 +69,9 @@ public List<ItemStack> getDrops(BlockState p_60537_, LootContext.Builder builder
if (framedDrawerTile.getFramedDrawerModelData() != null) {
stack.getOrCreateTag().put("Style", framedDrawerTile.getFramedDrawerModelData().serializeNBT());
}
if (framedDrawerTile.isLocked()){
stack.getOrCreateTag().putBoolean("Locked", framedDrawerTile.isLocked());
}
}
stacks.add(stack);
return stacks;
Expand All @@ -88,7 +92,7 @@ public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGett
public void registerRecipe(Consumer<FinishedRecipe> consumer) {
TitaniumShapedRecipeBuilder.shapedRecipe(this)
.pattern("SSS").pattern("PDP").pattern("SIS")
.define('S', Blocks.STONE)
.define('S', Items.IRON_NUGGET)
.define('P', Blocks.PISTON)
.define('D', Ingredient.of(FRAMED.stream().map(itemSupplier -> new ItemStack(itemSupplier.get()))))
.define('I', Tags.Items.INGOTS_IRON)
Expand Down
25 changes: 18 additions & 7 deletions src/main/java/com/buuz135/functionalstorage/block/DrawerBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,13 @@ public List<ItemStack> getDrops(BlockState p_60537_, LootContext.Builder builder
NonNullList<ItemStack> stacks = NonNullList.create();
ItemStack stack = new ItemStack(this);
BlockEntity drawerTile = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY);
if (drawerTile instanceof DrawerTile) {
if (!((DrawerTile) drawerTile).isEverythingEmpty()) {
if (drawerTile instanceof DrawerTile tile) {
if (!tile.isEverythingEmpty()) {
stack.getOrCreateTag().put("Tile", drawerTile.saveWithoutMetadata());
}
if (tile.isLocked()){
stack.getOrCreateTag().putBoolean("Locked", tile.isLocked());
}
}
stacks.add(stack);
return stacks;
Expand All @@ -235,11 +238,19 @@ public NonNullList<ItemStack> getDynamicDrops(BlockState state, Level worldIn, B
@Override
public void setPlacedBy(Level level, BlockPos pos, BlockState p_49849_, @Nullable LivingEntity p_49850_, ItemStack stack) {
super.setPlacedBy(level, pos, p_49849_, p_49850_, stack);
if (stack.hasTag() && stack.getTag().contains("Tile")) {
BlockEntity entity = level.getBlockEntity(pos);
if (entity instanceof DrawerTile) {
entity.load(stack.getTag().getCompound("Tile"));
((DrawerTile) entity).markForUpdate();
if (stack.hasTag()) {
if (stack.getTag().contains("Tile")){
BlockEntity entity = level.getBlockEntity(pos);
if (entity instanceof ControllableDrawerTile tile) {
entity.load(stack.getTag().getCompound("Tile"));
tile.markForUpdate();
}
}
if (stack.getTag().contains("Locked")){
BlockEntity entity = level.getBlockEntity(pos);
if (entity instanceof ControllableDrawerTile tile) {
tile.setLocked(stack.getTag().getBoolean("Locked"));
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public List<ItemStack> getDrops(BlockState p_60537_, LootContext.Builder builder
if (framedDrawerTile.getFramedDrawerModelData() != null) {
stack.getOrCreateTag().put("Style", framedDrawerTile.getFramedDrawerModelData().serializeNBT());
}
if (framedDrawerTile.isLocked()){
stack.getOrCreateTag().putBoolean("Locked", framedDrawerTile.isLocked());
}
}
stacks.add(stack);
return stacks;
Expand Down

0 comments on commit fdce055

Please sign in to comment.