Skip to content

Commit

Permalink
merge/1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Nov 4, 2024
2 parents 2c6c4d8 + 0688009 commit 0626bdf
Show file tree
Hide file tree
Showing 119 changed files with 1,197 additions and 340 deletions.
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ dependencies {
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${mc_version}-${patchouli_version}")


// implementation fg.deobf("curse.maven:autoreglib-250363:3642382")
// implementation fg.deobf("curse.maven:quark-243121:3840125")
// implementation fg.deobf("curse.maven:more-villagers-484954:3843498")
// implementation fg.deobf("curse.maven:yungs-api-421850:4428184")
// implementation fg.deobf("curse.maven:yungs-better-strongholds-465575:3778231")
// implementation fg.deobf("curse.maven:mekanism-268560:3875976")

// implementation fg.deobf("curse.maven:jade-324717:5079263")


}
Expand All @@ -107,7 +115,7 @@ repositories {
maven { url 'https://maven.theillusivec4.top/' }
maven { url 'https://maven.blamejared.com' }
maven { url 'https://modmaven.dev' }
// maven { url 'https://www.cursemaven.com' }
maven { url 'https://www.cursemaven.com' }
}
// Example for how to get properties into the manifest for reading by the runtime..
jar {
Expand Down
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ org.gradle.daemon=false
# as needed run/server.properties : online-mode=false

curse_id=239286
mod_version=1.8.5
mod_version=1.9.0



mc_version=1.19.2
forge_version=43.2.14



# optional dependencies
jei_version=11.4.0.285
curios_version=5.1.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,11 @@ public void setFluid(FluidStack fluid) {}
/************************** IInventory needed for IRecipe **********************************/
@Deprecated
@Override
public int getContainerSize() {
public int getContainerSize() { // was getSizeInventory
IItemHandler invo = this.getCapability(ForgeCapabilities.ITEM_HANDLER).orElse(null);
if (invo != null) {
return invo.getSlots();
}
return 0;
}

Expand All @@ -532,7 +536,14 @@ public boolean isEmpty() {

@Deprecated
@Override
public ItemStack getItem(int index) {
public ItemStack getItem(int index) { // was getStackInSlot
IItemHandler invo = this.getCapability(ForgeCapabilities.ITEM_HANDLER).orElse(null);
try {
if (invo != null && index < invo.getSlots()) {
return invo.getStackInSlot(index);
}
}
catch (Exception e) {}
return ItemStack.EMPTY;
}

Expand Down Expand Up @@ -667,4 +678,30 @@ else if (beaconblockentity$beaconbeamsection != null) {
beamStuff.beamSections = beamStuff.checkingBeamSections;
}
}

// was getTargetCenter
protected BlockPos getFacingShapeCenter(int radiusIn) {
BlockPos center = null;
if (this.getCurrentFacing() != null) {
if (this.getCurrentFacing().getAxis().isVertical()) {
//vertical center point
center = this.getCurrentFacingPos(1);
}
else { //horizontal center point
center = this.getCurrentFacingPos(radiusIn + 1);
}
}
return center;
}

public boolean getBlockStateVertical() {
if (this.getBlockState().hasProperty(BlockStateProperties.FACING))
return this.getBlockState().getValue(BlockStateProperties.FACING).getAxis().isVertical();
return false;
}

public void updateComparatorOutputLevel() {
//was updateComparatorOutputLevel()
level.updateNeighbourForOutputSignal(worldPosition, this.getBlockState().getBlock());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.items.SlotItemHandler;

public class ContainerBreaker extends ContainerBase {

Expand All @@ -18,6 +20,10 @@ public ContainerBreaker(int windowId, Level world, BlockPos pos, Inventory playe
tile = (TileBreaker) world.getBlockEntity(pos);
this.playerEntity = player;
this.playerInventory = playerInventory;
tile.getCapability(ForgeCapabilities.ITEM_HANDLER).ifPresent(h -> {
this.endInv = h.getSlots();
addSlot(new SlotItemHandler(h, 0, 81, 31));
});
layoutPlayerInventorySlots(8, 84);
trackEnergy(tile);
this.trackAllIntFields(tile, TileBreaker.Fields.values().length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ protected void renderLabels(PoseStack ms, int mouseX, int mouseY) {
@Override
protected void renderBg(PoseStack ms, float partialTicks, int mouseX, int mouseY) {
this.drawBackground(ms, TextureRegistry.INVENTORY);
this.drawSlot(ms, 80, 30, TextureRegistry.SLOT_BSDATA);
}
}
88 changes: 81 additions & 7 deletions src/main/java/com/lothrazar/cyclic/block/breaker/TileBreaker.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
package com.lothrazar.cyclic.block.breaker;

import com.lothrazar.cyclic.ModCyclic;
import com.lothrazar.cyclic.block.TileBlockEntityCyclic;
import com.lothrazar.cyclic.data.DataTags;
import com.lothrazar.cyclic.item.datacard.BlockStateMatcher;
import com.lothrazar.cyclic.item.datacard.BlockstateCard;
import com.lothrazar.cyclic.registry.BlockRegistry;
import com.lothrazar.cyclic.registry.ItemRegistry;
import com.lothrazar.cyclic.registry.TileRegistry;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ForgeCapabilities;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemStackHandler;

public class TileBreaker extends TileBlockEntityCyclic implements MenuProvider {

Expand All @@ -22,6 +35,19 @@ static enum Fields {

static final int MAX = 64000;
public static final int TIMER_FULL = 500;
ItemStackHandler inventory = new ItemStackHandler() {

@Override
public int getSlotLimit(int slot) {
return 1;
}

@Override
public boolean isItemValid(int slot, ItemStack stack) {
return stack.getItem() == ItemRegistry.STATECARD.get();
}
};
private LazyOptional<IItemHandler> inventoryCap = LazyOptional.of(() -> inventory);

public TileBreaker(BlockPos pos, BlockState state) {
super(TileRegistry.BREAKER.get(), pos, state);
Expand All @@ -35,6 +61,14 @@ public static <E extends BlockEntity> void clientTick(Level level, BlockPos bloc
e.tick();
}

@Override
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
if (cap == ForgeCapabilities.ITEM_HANDLER) {
return inventoryCap.cast();
}
return super.getCapability(cap, side);
}

public void tick() {
if (this.requiresRedstone() && !this.isPowered()) {
setLitProperty(false);
Expand All @@ -45,32 +79,60 @@ public void tick() {
return;
}
BlockPos target = this.worldPosition.relative(this.getCurrentFacing()); // offset -> relative
if (this.isValid(target)) {
if (this.isTargetValid(target)) {
this.level.destroyBlock(target, true);
}
}

@Override
public void invalidateCaps() {
inventoryCap.invalidate();
super.invalidateCaps();
}

/**
* Avoid mining source liquid blocks and unbreakable
*/
private boolean isValid(BlockPos target) {
BlockState state = level.getBlockState(target);
if (state.isAir()) {
private boolean isTargetValid(BlockPos targetPos) {
BlockState targetState = level.getBlockState(targetPos);
if (targetState.isAir()) {
return false;
}
if (targetState.getDestroySpeed(level, targetPos) < 0) {
return false;
}
if (state.getDestroySpeed(level, target) < 0) { //getBlockHardness -> getDestroySpeed
//check the tag ignore list so modpack/datapack can filter this
if (targetState.is(DataTags.BREAKER_IGNORED)) {
ModCyclic.LOGGER.info("breaker/ignored tag skips " + targetPos);
return false;
}
if (state.getFluidState() != null && state.getFluidState().isEmpty() == false) {
if (targetState.getFluidState() != null && targetState.getFluidState().isEmpty() == false) {
//am i a solid waterlogged state block?
if (state.hasProperty(BlockStateProperties.WATERLOGGED) == false) {
if (targetState.hasProperty(BlockStateProperties.WATERLOGGED) == false) {
//pure liquid. but this will make canHarvestBlock go true
return false;
}
}
if (!this.isValidFromDatacard(targetState)) {
return false;
}
// else filter is empty
return true;
}

private boolean isValidFromDatacard(BlockState targetState) {
ItemStack filter = inventory.getStackInSlot(0);
if (filter.isEmpty()) {
return true; //ya go
}
for (BlockStateMatcher m : BlockstateCard.getSavedStates(filter)) {
if (m.doesMatch(targetState)) {
return true; // i am allowed to mine this
}
}
return false; //filter is my allow list, and you aint in it so not allowed
}

@Override
public Component getDisplayName() {
return BlockRegistry.BREAKER.get().getName();
Expand All @@ -81,6 +143,18 @@ public AbstractContainerMenu createMenu(int i, Inventory playerInventory, Player
return new ContainerBreaker(i, level, worldPosition, playerInventory, playerEntity);
}

@Override
public void load(CompoundTag tag) {
inventory.deserializeNBT(tag.getCompound(NBTINV));
super.load(tag);
}

@Override
public void saveAdditional(CompoundTag tag) {
tag.put(NBTINV, inventory.serializeNBT());
super.saveAdditional(tag);
}

@Override
public void setField(int field, int value) {
switch (Fields.values()[field]) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.lothrazar.cyclic.block.cable.energy;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import com.google.common.collect.Maps;
import com.lothrazar.cyclic.ModCyclic;
import com.lothrazar.cyclic.block.TileBlockEntityCyclic;
import com.lothrazar.cyclic.block.cable.CableBase;
Expand All @@ -24,19 +24,21 @@

public class TileCableEnergy extends TileBlockEntityCyclic {

final CustomEnergyStorage energy;
private LazyOptional<IEnergyStorage> energyCap;
public static IntValue BUFFERSIZE;
public static IntValue TRANSFER_RATE;
CustomEnergyStorage energy;
private LazyOptional<IEnergyStorage> energyCap;
private final Map<Direction, Integer> mapIncomingEnergy = new ConcurrentHashMap<>();
private int energyLastSynced = -1; //fluid tanks have 'onchanged', energy caps do not
//
// private final ConcurrentHashMap<Direction, LazyOptional<IEnergyStorage>> flow = new ConcurrentHashMap<>();
private final Map<Direction, Integer> mapIncomingEnergy = Maps.newHashMap();
private int energyLastSynced = -1; //fluid tanks have 'onchanged', energy caps do not

public TileCableEnergy(BlockPos pos, BlockState state) {
super(TileRegistry.ENERGY_PIPE.get(), pos, state);
for (Direction f : Direction.values()) {
mapIncomingEnergy.put(f, 0);
}
energy = new CustomEnergyStorage(BUFFERSIZE.get(), BUFFERSIZE.get());
energy = new CustomEnergyStorage(BUFFERSIZE.get(), TRANSFER_RATE.get());
energyCap = LazyOptional.of(() -> energy);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level world, Block
@Override
public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity entity, ItemStack stack) {
if (entity != null) {
world.setBlock(pos, state.setValue(BlockStateProperties.HORIZONTAL_FACING, BlockstatesUtil.getFacingFromEntityHorizontal(pos, entity)), 2);
world.setBlock(pos, state.setValue(BlockStateProperties.FACING, BlockstatesUtil.getFacingFromEntity(pos, entity)), 2);
}
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(BlockStateProperties.HORIZONTAL_FACING).add(LIT);
builder.add(BlockStateProperties.FACING).add(LIT);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package com.lothrazar.cyclic.block.collectfluid;

import com.lothrazar.cyclic.config.ClientConfigCyclic;
import com.lothrazar.cyclic.data.PreviewOutlineType;
import com.lothrazar.cyclic.render.RenderUtils;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.Vec3;

public class RenderFluidCollect implements BlockEntityRenderer<TileFluidCollect> {

public RenderFluidCollect(BlockEntityRendererProvider.Context d) {}

@Override
public void render(TileFluidCollect te, float v, PoseStack matrix, MultiBufferSource ibuffer, int partialTicks, int destroyStage) {
if (1 == te.getField(TileFluidCollect.Fields.RENDER.ordinal())) {
int previewType = te.getField(TileFluidCollect.Fields.RENDER.ordinal());
if (PreviewOutlineType.SHADOW.ordinal() == previewType) {
RenderUtils.renderOutline(te.getBlockPos(), te.getShapeHollow(), matrix, 0.4F, ClientConfigCyclic.getColor(te));
}
else if (PreviewOutlineType.WIREFRAME.ordinal() == previewType) {
for (BlockPos crd : te.getShapeHollow()) {
RenderUtils.createBox(matrix, crd, Vec3.atLowerCornerOf(te.getBlockPos()));
}
}
}
}
Loading

0 comments on commit 0626bdf

Please sign in to comment.