Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id 'net.minecraftforge.gradle' version '5.1.+'
}

version = '1.1.2'
version = '1.1.3'
group = 'de.mennomax' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'astikorcarts-1.19.2'

Expand Down Expand Up @@ -106,7 +106,6 @@ dependencies {
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html

}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.Container;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.SimpleMenuProvider;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.vehicle.ContainerEntity;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand All @@ -42,12 +44,13 @@
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.items.ItemStackHandler;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;

public final class SupplyCartEntity extends AbstractDrawnInventoryEntity {
public final class SupplyCartEntity extends AbstractDrawnInventoryEntity implements Container {
private static final ImmutableList<EntityDataAccessor<ItemStack>> CARGO = ImmutableList.of(
SynchedEntityData.defineId(SupplyCartEntity.class, EntityDataSerializers.ITEM_STACK),
SynchedEntityData.defineId(SupplyCartEntity.class, EntityDataSerializers.ITEM_STACK),
Expand Down Expand Up @@ -242,6 +245,58 @@ public void openContainer(final Player player) {
}
}

@Override
public int getContainerSize() {
return this.inventory.getSlots();
}

@Override
public boolean isEmpty() {
for(int i =0; i < this.inventory.getSlots(); i++){
ItemStack itemstack = this.inventory.getStackInSlot(i);
if (!itemstack.isEmpty()) {
return false;
}
}
return true;
}

@Override
public @NotNull ItemStack getItem(int slot) {
return inventory.getStackInSlot(slot);
}

@Override
public @NotNull ItemStack removeItem(int slot, int amount) {
return inventory.extractItem(slot, amount, false);
}

@Override
public @NotNull ItemStack removeItemNoUpdate(int slot) {
return inventory.extractItem(slot, 64, true);
}

@Override
public void setItem(int slot, @NotNull ItemStack stack) {
inventory.setStackInSlot(slot, stack);
}

@Override
public void setChanged() {
}

@Override
public boolean stillValid(@NotNull Player player) {
return true;
}

@Override
public void clearContent() {
for(int i =0; i < this.inventory.getSlots(); i++){
removeItemNoUpdate(i);
}
}

static class DiscTag {
static final DiscTag EMPTY = new DiscTag(ItemStack.EMPTY, new CompoundTag(), new CompoundTag(), ItemStack.EMPTY);

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ displayName="AstikorCarts"
displayURL="https://www.curseforge.com/minecraft/mc-mods/astikorcarts"
# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="examplemod.png"
authors="MennoMax, pau101"
authors="MennoMax, pau101, talhanation"
description="This mod adds carts that can be pulled by other entities to the game.\nTo attach an entity, press the \"Action Key\" specified in the controls.\n\nYou might have to add the entity in the config file first."

[[dependencies.astikorcarts]]
Expand Down