1.0.1
This commit is contained in:
1 parent
3de3a4b831
commit
958948a642
17 files changed
+244
-212
No files matched your search
-11
@@ -1,11 +0,0 @@
|
||||
package com.craisinlord.antarchy.fabric.item;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ScaffoldingBlockItem;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public final class AntimetalScaffoldingItem extends ScaffoldingBlockItem {
|
||||
public AntimetalScaffoldingItem(Block block, Item.Properties properties) {
|
||||
super(block, properties);
|
||||
}
|
||||
}
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
package com.craisinlord.antarchy.fabric.mixin;
|
||||
import com.craisinlord.antarchy.fabric.registry.AntarchyFabricBlocks;
|
||||
|
||||
import com.craisinlord.antarchy.fabric.AntarchyFabricContent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.item.FallingBlockEntity;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.ScaffoldingBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(ScaffoldingBlock.class)
|
||||
public abstract class AntimetalScaffoldingMixin {
|
||||
@Inject(method = "getStateForPlacement", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$antimetalPlacement(BlockPlaceContext context, CallbackInfoReturnable<BlockState> cir) {
|
||||
if (!antarchy$isAntimetalScaffolding()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockPos pos = context.getClickedPos();
|
||||
Level level = context.getLevel();
|
||||
int distance = antarchy$getDistance(level, pos);
|
||||
BlockState state = ((ScaffoldingBlock) (Object) this).defaultBlockState()
|
||||
.setValue(ScaffoldingBlock.WATERLOGGED, level.getFluidState(pos).getType().isSame(net.minecraft.world.level.material.Fluids.WATER))
|
||||
.setValue(ScaffoldingBlock.DISTANCE, distance)
|
||||
.setValue(ScaffoldingBlock.BOTTOM, antarchy$isBottom(level, pos, distance));
|
||||
cir.setReturnValue(state);
|
||||
}
|
||||
|
||||
@Inject(method = "canSurvive", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$antimetalCanSurvive(BlockState state, LevelReader level, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (!antarchy$isAntimetalScaffolding()) {
|
||||
return;
|
||||
}
|
||||
|
||||
cir.setReturnValue(antarchy$getDistance(level, pos) < 7);
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
private void antarchy$antimetalTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random, CallbackInfo ci) {
|
||||
if (!antarchy$isAntimetalScaffolding()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int distance = antarchy$getDistance(level, pos);
|
||||
BlockState updated = state.setValue(ScaffoldingBlock.DISTANCE, distance)
|
||||
.setValue(ScaffoldingBlock.BOTTOM, antarchy$isBottom(level, pos, distance));
|
||||
|
||||
if (updated.getValue(ScaffoldingBlock.DISTANCE) == 7) {
|
||||
if (state.getValue(ScaffoldingBlock.DISTANCE) == 7) {
|
||||
FallingBlockEntity.fall(level, pos, updated);
|
||||
} else {
|
||||
level.destroyBlock(pos, true);
|
||||
}
|
||||
} else if (state != updated) {
|
||||
level.setBlock(pos, updated, 3);
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
private boolean antarchy$isAntimetalScaffolding() {
|
||||
return ((ScaffoldingBlock) (Object) this).asItem() == AntarchyFabricBlocks.ANTIMETAL_SCAFFOLDING.get().asItem();
|
||||
}
|
||||
|
||||
private int antarchy$getDistance(BlockGetter level, BlockPos pos) {
|
||||
BlockPos.MutableBlockPos cursor = pos.mutable().move(Direction.DOWN);
|
||||
BlockState below = level.getBlockState(cursor);
|
||||
int distance = 7;
|
||||
if (below.is((ScaffoldingBlock) (Object) this)) {
|
||||
distance = below.getValue(ScaffoldingBlock.DISTANCE) + 1;
|
||||
} else if (below.isFaceSturdy(level, cursor, Direction.UP)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (Direction direction : Direction.Plane.HORIZONTAL) {
|
||||
BlockPos.MutableBlockPos neighborPos = pos.mutable().move(direction);
|
||||
BlockState neighbor = level.getBlockState(neighborPos);
|
||||
if (!neighbor.is((ScaffoldingBlock) (Object) this)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
distance = Math.min(distance, neighbor.getValue(ScaffoldingBlock.DISTANCE) + 1);
|
||||
if (distance == 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
private boolean antarchy$isBottom(BlockGetter level, BlockPos pos, int distance) {
|
||||
if (distance <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !level.getBlockState(pos.below()).is((ScaffoldingBlock) (Object) this);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -18,7 +18,7 @@ import com.craisinlord.antarchy.content.item.BasiliskDaggerItem;
|
||||
import com.craisinlord.antarchy.content.item.BigBerthaItem;
|
||||
import com.craisinlord.antarchy.content.item.KrakensGraspItem;
|
||||
import com.craisinlord.antarchy.content.item.AntimetalBlockItem;
|
||||
import com.craisinlord.antarchy.fabric.item.AntimetalScaffoldingItem;
|
||||
import com.craisinlord.antarchy.content.item.AntimetalScaffoldingItem;
|
||||
import com.craisinlord.antarchy.content.item.CloudSharkFinSoupItem;
|
||||
import com.craisinlord.antarchy.content.item.CorneaEarItem;
|
||||
import com.craisinlord.antarchy.content.item.GravityGunItem;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
"WaterlikeFluidLivingEntityMixin",
|
||||
"WaterlikeFluidItemEntityMixin",
|
||||
"AntimetalInversionMixin",
|
||||
"AntimetalScaffoldingMixin",
|
||||
"ElytraStartFlyingMixin",
|
||||
"ElytraFallFlyingMixin",
|
||||
"BloodglassEquipMixin",
|
||||
|
||||
Reference in new issue
Block a user