-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1445d2
commit 066a757
Showing
10 changed files
with
243 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...ricacid/touhoulittlemaid/client/gui/entity/maid/backpack/TankBackpackContainerScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.client.gui.entity.maid.backpack; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.client.gui.entity.maid.AbstractMaidContainerGui; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.inventory.container.backpack.TankBackpackContainer; | ||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Inventory; | ||
|
||
public class TankBackpackContainerScreen extends AbstractMaidContainerGui<TankBackpackContainer> implements IBackpackContainerScreen { | ||
private static final ResourceLocation BACKPACK = new ResourceLocation(TouhouLittleMaid.MOD_ID, "textures/gui/maid_gui_backpack.png"); | ||
private final EntityMaid maid; | ||
|
||
public TankBackpackContainerScreen(TankBackpackContainer container, Inventory inv, Component titleIn) { | ||
super(container, inv, titleIn); | ||
this.imageHeight = 256; | ||
this.imageWidth = 256; | ||
this.maid = menu.getMaid(); | ||
} | ||
|
||
@Override | ||
protected void renderBg(GuiGraphics graphics, float partialTicks, int x, int y) { | ||
super.renderBg(graphics, partialTicks, x, y); | ||
RenderSystem.setShader(GameRenderer::getPositionTexShader); | ||
RenderSystem.setShaderTexture(0, BACKPACK); | ||
graphics.blit(BACKPACK, leftPos + 85, topPos + 36, 0, 0, 165, 128); | ||
graphics.fill(leftPos + 142, topPos + 81, leftPos + 250, topPos + 117, 0xaa222222); | ||
graphics.blit(BACKPACK, leftPos + 190, topPos + 92, 165, 0, 11, 11); | ||
graphics.fill(leftPos + 142, topPos + 122, leftPos + 250, topPos + 158, 0xaa222222); | ||
graphics.blit(BACKPACK, leftPos + 190, topPos + 133, 165, 0, 11, 11); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/backpack/TankBackpack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.entity.backpack; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.TouhouLittleMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.api.backpack.IBackpackData; | ||
import com.github.tartaricacid.touhoulittlemaid.api.backpack.IMaidBackpack; | ||
import com.github.tartaricacid.touhoulittlemaid.client.model.backpack.MiddleBackpackModel; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.backpack.data.TankBackpackData; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.item.EntityTombstone; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; | ||
import com.github.tartaricacid.touhoulittlemaid.inventory.container.AbstractMaidContainer; | ||
import com.github.tartaricacid.touhoulittlemaid.inventory.container.backpack.TankBackpackContainer; | ||
import com.github.tartaricacid.touhoulittlemaid.item.BackpackLevel; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.math.Axis; | ||
import net.minecraft.client.model.EntityModel; | ||
import net.minecraft.client.model.geom.EntityModelSet; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.MenuProvider; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class TankBackpack extends IMaidBackpack { | ||
public static final ResourceLocation ID = new ResourceLocation(TouhouLittleMaid.MOD_ID, "tank"); | ||
|
||
@Override | ||
public ResourceLocation getId() { | ||
return ID; | ||
} | ||
|
||
@Override | ||
public Item getItem() { | ||
return Items.BUCKET; | ||
} | ||
|
||
@Override | ||
public void onPutOn(ItemStack stack, Player player, EntityMaid maid) { | ||
} | ||
|
||
@Override | ||
public void onTakeOff(ItemStack stack, Player player, EntityMaid maid) { | ||
} | ||
|
||
@Override | ||
public void onSpawnTombstone(EntityMaid maid, EntityTombstone tombstone) { | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public IBackpackData getBackpackData(EntityMaid maid) { | ||
return new TankBackpackData(); | ||
} | ||
|
||
@Override | ||
public MenuProvider getGuiProvider(int entityId) { | ||
return new MenuProvider() { | ||
@Override | ||
public Component getDisplayName() { | ||
return Component.literal("Maid Tank Container"); | ||
} | ||
|
||
@Override | ||
public AbstractMaidContainer createMenu(int index, Inventory playerInventory, Player player) { | ||
return new TankBackpackContainer(index, playerInventory, entityId); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public int getAvailableMaxContainerIndex() { | ||
return BackpackLevel.TANK_CAPACITY; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
@OnlyIn(Dist.CLIENT) | ||
public EntityModel<EntityMaid> getBackpackModel(EntityModelSet modelSet) { | ||
return new MiddleBackpackModel(modelSet.bakeLayer(MiddleBackpackModel.LAYER)); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
@OnlyIn(Dist.CLIENT) | ||
public ResourceLocation getBackpackTexture() { | ||
return new ResourceLocation(TouhouLittleMaid.MOD_ID, "textures/entity/maid_backpack_middle.png"); | ||
} | ||
|
||
@OnlyIn(Dist.CLIENT) | ||
public void offsetBackpackItem(PoseStack poseStack) { | ||
poseStack.mulPose(Axis.XP.rotationDegrees(-7.5F)); | ||
poseStack.translate(0, 0.625, -0.25); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
.../java/com/github/tartaricacid/touhoulittlemaid/entity/backpack/data/TankBackpackData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.entity.backpack.data; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.api.backpack.IBackpackData; | ||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.nbt.Tag; | ||
import net.minecraft.world.SimpleContainer; | ||
import net.minecraft.world.inventory.ContainerData; | ||
import net.minecraftforge.fluids.FluidType; | ||
import net.minecraftforge.fluids.capability.templates.FluidTank; | ||
|
||
public class TankBackpackData extends SimpleContainer implements IBackpackData { | ||
public static final int CAPACITY = 10 * FluidType.BUCKET_VOLUME; | ||
private final FluidTank tank = new FluidTank(CAPACITY); | ||
private final ContainerData dataAccess = new ContainerData() { | ||
public int get(int index) { | ||
if (index == 0) { | ||
TankBackpackData.this.tank.getFluidAmount(); | ||
} | ||
return 0; | ||
} | ||
|
||
public void set(int index, int value) { | ||
if (index == 0) { | ||
TankBackpackData.this.tank.getFluid().setAmount(value); | ||
} | ||
} | ||
|
||
public int getCount() { | ||
return 2; | ||
} | ||
}; | ||
|
||
public TankBackpackData() { | ||
super(2); | ||
} | ||
|
||
@Override | ||
public ContainerData getDataAccess() { | ||
return dataAccess; | ||
} | ||
|
||
@Override | ||
public void load(CompoundTag tag, EntityMaid maid) { | ||
tank.readFromNBT(tag.getCompound("Tanks")); | ||
this.fromTag(tag.getList("Items", Tag.TAG_COMPOUND)); | ||
} | ||
|
||
@Override | ||
public void save(CompoundTag tag, EntityMaid maid) { | ||
tag.put("Tanks", tank.writeToNBT(new CompoundTag())); | ||
tag.put("Items", this.createTag()); | ||
} | ||
|
||
@Override | ||
public void serverTick(EntityMaid maid) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...hub/tartaricacid/touhoulittlemaid/inventory/container/backpack/TankBackpackContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.github.tartaricacid.touhoulittlemaid.inventory.container.backpack; | ||
|
||
import com.github.tartaricacid.touhoulittlemaid.entity.backpack.data.TankBackpackData; | ||
import com.github.tartaricacid.touhoulittlemaid.inventory.container.MaidMainContainer; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.inventory.ContainerData; | ||
import net.minecraft.world.inventory.MenuType; | ||
import net.minecraft.world.inventory.Slot; | ||
import net.minecraftforge.common.extensions.IForgeMenuType; | ||
import net.minecraftforge.items.IItemHandler; | ||
import net.minecraftforge.items.SlotItemHandler; | ||
|
||
public class TankBackpackContainer extends MaidMainContainer { | ||
public static final MenuType<TankBackpackContainer> TYPE = IForgeMenuType.create((windowId, inv, data) -> new TankBackpackContainer(windowId, inv, data.readInt())); | ||
private final ContainerData data; | ||
|
||
public TankBackpackContainer(int id, Inventory inventory, int entityId) { | ||
super(TYPE, id, inventory, entityId); | ||
TankBackpackData tankData; | ||
if (this.getMaid().getBackpackData() instanceof TankBackpackData) { | ||
tankData = (TankBackpackData) this.getMaid().getBackpackData(); | ||
} else { | ||
tankData = new TankBackpackData(); | ||
} | ||
this.data = tankData.getDataAccess(); | ||
this.addSlot(new Slot(tankData, 0, 161, 101)); | ||
this.addSlot(new Slot(tankData, 1, 161, 142)); | ||
this.addDataSlots(this.data); | ||
} | ||
|
||
@Override | ||
protected void addBackpackInv(Inventory inventory) { | ||
IItemHandler itemHandler = maid.getMaidInv(); | ||
for (int i = 0; i < 6; i++) { | ||
addSlot(new SlotItemHandler(itemHandler, 6 + i, 143 + 18 * i, 57)); | ||
} | ||
for (int i = 0; i < 6; i++) { | ||
addSlot(new SlotItemHandler(itemHandler, 12 + i, 143 + 18 * i, 75)); | ||
} | ||
} | ||
|
||
public int getTankPercent() { | ||
return this.data.get(0) / TankBackpackData.CAPACITY; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+15.5 KB
src/main/resources/assets/touhou_little_maid/textures/gui/maid_tank.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.