Skip to content

Commit

Permalink
mc1.18.2-v1.1.3 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
EDToaster committed Mar 18, 2022
2 parents 03d0111 + 18582d6 commit 18449ee
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.jvmargs = -Xmx3G
org.gradle.daemon = false

# Core properties
mod_version = 1.1.2
mod_version = 1.1.3
mod_group = dev.murad.littlelogistics
mod_id = littlelogistics
mod_title = Little Logistics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,54 @@
import java.util.function.IntSupplier;

public class EnergyTugDataAccessor extends DataAccessor {
private static final int SHORT_MASK = 0xFFFF;

public EnergyTugDataAccessor(ContainerData data) {
super(data);
}

/**
* Lil-endian
*/

public int getEnergy() {
return this.data.get(1);
int lo = this.data.get(1) & SHORT_MASK;
int hi = this.data.get(2) & SHORT_MASK;
return lo | hi << 16;
}

public int getCapacity() {
return this.data.get(2);
int lo = this.data.get(3) & SHORT_MASK;
int hi = this.data.get(4) & SHORT_MASK;
return lo | hi << 16;
}

public boolean isLit() {
return this.data.get(3) == 1;
return this.data.get(5) == 1;
}

public static class Builder {
SupplierIntArray arr;

public Builder(int uuid) {
this.arr = new SupplierIntArray(4);
this.arr = new SupplierIntArray(6);
this.arr.set(0, uuid);
}

public Builder withEnergy(IntSupplier energy) {
this.arr.setSupplier(1, energy);
this.arr.setSupplier(1, () -> energy.getAsInt() & SHORT_MASK);
this.arr.setSupplier(2, () -> (energy.getAsInt() >> 16) & SHORT_MASK);
return this;
}

public Builder withCapacity(IntSupplier capacity) {
this.arr.setSupplier(2, capacity);
this.arr.setSupplier(3, () -> capacity.getAsInt() & SHORT_MASK);
this.arr.setSupplier(4, () -> (capacity.getAsInt() >> 16) & SHORT_MASK);
return this;
}

public Builder withLit(BooleanSupplier lit) {
this.arr.setSupplier(3, () -> lit.getAsBoolean() ? 1 : -1);
this.arr.setSupplier(5, () -> lit.getAsBoolean() ? 1 : -1);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
package dev.murad.shipping.entity.container;

import dev.murad.shipping.ShippingMod;
import dev.murad.shipping.entity.accessor.DataAccessor;
import dev.murad.shipping.entity.custom.tug.AbstractTugEntity;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.level.Level;

import javax.annotation.Nullable;

public abstract class AbstractTugContainer<T extends DataAccessor> extends AbstractItemHandlerContainer {
public static final ResourceLocation EMPTY_TUG_ROUTE = new ResourceLocation(ShippingMod.MOD_ID, "item/empty_tug_route");
public static final ResourceLocation EMPTY_ENERGY = new ResourceLocation(ShippingMod.MOD_ID, "item/empty_energy");
public static final ResourceLocation EMPTY_ATLAS_LOC = InventoryMenu.BLOCK_ATLAS;

protected T data;
protected AbstractTugEntity tugEntity;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public EnergyTugContainer(int windowId, Level world, EnergyTugDataAccessor data,
if(tugEntity != null) {
tugEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h -> {
addSlot(new SlotItemHandler(h, 0, 116, 35)
.setBackground(ModClientEventHandler.EMPTY_ATLAS_LOC, ModClientEventHandler.EMPTY_TUG_ROUTE));
.setBackground(EMPTY_ATLAS_LOC, EMPTY_TUG_ROUTE));
addSlot(new SlotItemHandler(h, 1, 32, 35)
.setBackground(ModClientEventHandler.EMPTY_ATLAS_LOC, ModClientEventHandler.EMPTY_ENERGY));
.setBackground(EMPTY_ATLAS_LOC, EMPTY_ENERGY));
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public SteamTugContainer(int windowId, Level world, SteamTugDataAccessor data,
if(tugEntity != null) {
tugEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h -> {
addSlot(new SlotItemHandler(h, 0, 116, 35)
.setBackground(ModClientEventHandler.EMPTY_ATLAS_LOC, ModClientEventHandler.EMPTY_TUG_ROUTE));
.setBackground(EMPTY_ATLAS_LOC, EMPTY_TUG_ROUTE));
addSlot(new SlotItemHandler(h, 1, 42, 40));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dev.murad.shipping.ShippingMod;
import dev.murad.shipping.block.fluid.render.FluidHopperTileEntityRenderer;
import dev.murad.shipping.entity.container.AbstractTugContainer;
import dev.murad.shipping.entity.models.*;
import dev.murad.shipping.entity.render.DummyEntityRenderer;
import dev.murad.shipping.entity.render.barge.FishingBargeRenderer;
Expand All @@ -13,7 +14,6 @@
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
Expand All @@ -27,15 +27,12 @@
*/
@Mod.EventBusSubscriber(modid = ShippingMod.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ModClientEventHandler {
public static final ResourceLocation EMPTY_TUG_ROUTE = new ResourceLocation(ShippingMod.MOD_ID, "item/empty_tug_route");
public static final ResourceLocation EMPTY_ENERGY = new ResourceLocation(ShippingMod.MOD_ID, "item/empty_energy");
public static final ResourceLocation EMPTY_ATLAS_LOC = InventoryMenu.BLOCK_ATLAS;

@SubscribeEvent
public static void onTextureStitchEventPre(TextureStitchEvent.Pre event) {
if (event.getAtlas().location() != EMPTY_ATLAS_LOC) return;
event.addSprite(EMPTY_TUG_ROUTE);
event.addSprite(EMPTY_ENERGY);
if (event.getAtlas().location() != AbstractTugContainer.EMPTY_ATLAS_LOC) return;
event.addSprite(AbstractTugContainer.EMPTY_TUG_ROUTE);
event.addSprite(AbstractTugContainer.EMPTY_ENERGY);
}

@SubscribeEvent
Expand Down

0 comments on commit 18449ee

Please sign in to comment.