Skip to content

Commit

Permalink
tweaks to scribe glass cycle, gargoyle particles
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Sep 10, 2024
1 parent 66fc331 commit 423cc13
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/main/java/galena/oreganized/Oreganized.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ private void setup(FMLCommonSetupEvent event) {

PotionBrewing.addMix(Potions.WATER, OItems.LEAD_INGOT.get(), OPotions.STUNNING.get());
PotionBrewing.addMix(OPotions.STUNNING.get(), Items.REDSTONE, OPotions.LONG_STUNNING.get());
PotionBrewing.addMix(OPotions.STUNNING.get(), Items.GLOWSTONE_DUST, OPotions.STRONG_STUNNING.get());

FireBlock fire = (FireBlock) Blocks.FIRE;
fire.setFlammable(OBlocks.SHRAPNEL_BOMB.get(), 15, 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static Vec3 offset(BlockState state, BlockPos pos, double spread) {
double offsetZ = facing.getAxis() == Direction.Axis.Z ? facing.getStepZ() * attachment.horizontalOffset : spread;

double x = pos.getX() + 0.5 + offsetX;
double y = pos.getY() + attachment.verticalOffset;
double y = pos.getY() + attachment.verticalOffset + 0.05;
double z = pos.getZ() + 0.5 + offsetZ;

return new Vec3(x, y, z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ default int getType(BlockPlaceContext context) {
if (above.getValue(TYPE) == NORMAL && below.getValue(TYPE) == ROTATED) return INNER;
}

return context.getPlayer() != null && context.getPlayer().isCrouching() ? ROTATED : NORMAL;
return context.getPlayer() != null && context.getPlayer().isShiftKeyDown() ? ROTATED : NORMAL;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import galena.oreganized.network.packet.GargoyleParticlePacket;
import galena.oreganized.world.ScaredOfGargoyleGoal;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -19,19 +20,16 @@
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.MobType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.network.PacketDistributor;
import org.checkerframework.checker.units.qual.C;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
Expand All @@ -47,8 +45,17 @@ public class GargoyleBlockEntity extends BlockEntity {

private ParticleOptions drippingFluid;

private final Direction fluidOffset;

public GargoyleBlockEntity(BlockPos pos, BlockState state) {
super(OBlockEntities.GARGOYLE.get(), pos, state);
var attachment = state.getValue(GargoyleBlock.ATTACHMENT);
var facing = state.getValue(GargoyleBlock.FACING);
if (attachment == GargoyleBlock.AttachmentType.FLOOR) {
fluidOffset = Direction.DOWN;
} else {
fluidOffset = facing;
}
}

private static Collection<Mob> getTargets(Level level, BlockPos pos) {
Expand Down Expand Up @@ -89,13 +96,21 @@ public static void tick(Level level, BlockPos pos, BlockState state, GargoyleBlo

private void updateDripParticles(Level level, BlockPos pos, BlockState state) {
for (int i = 1; i <= 2; i++) {
var targetPos = pos.below(i);
var targetPos = pos.relative(fluidOffset, i);
var targetState = level.getBlockState(targetPos);
var fluid = targetState.getFluidState();
if (!fluid.isEmpty()) {
drippingFluid = fluid.getDripParticle();
return;
}

if(!targetState.isRedstoneConductor(level, pos)) {
break;
}

if (!targetState.isFaceSturdy(level, pos, Direction.UP) || !targetState.isFaceSturdy(level, pos, Direction.DOWN)) {
break;
}
}

if (level.isRainingAt(pos.above())) {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/galena/oreganized/content/item/ScribeItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import galena.oreganized.content.block.ICrystalGlass;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.BlockParticleOption;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -14,6 +17,7 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.Vec3;

import static galena.oreganized.index.OTags.Blocks.MINEABLE_WITH_SCRIBE;
import static galena.oreganized.index.OTags.Blocks.SILKTOUCH_WITH_SCRIBE;
Expand Down Expand Up @@ -69,13 +73,23 @@ public InteractionResult useOn(UseOnContext context) {

if (state.hasProperty(ICrystalGlass.TYPE)) {
var type = state.getValue(ICrystalGlass.TYPE);

level.setBlockAndUpdate(pos, state.setValue(ICrystalGlass.TYPE, (type + 1) % (ICrystalGlass.MAX_TYPE + 1)));
level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(context.getPlayer(), state));
level.addDestroyBlockEffect(pos, state);

var vec = Vec3.atCenterOf(pos);
level.addParticle(new BlockParticleOption(ParticleTypes.BLOCK, state), vec.x, vec.y + 1, vec.z, 0.0, 0.0, 0.0);

if (context.getPlayer() != null) {
context.getPlayer().playSound(SoundEvents.GRINDSTONE_USE, 1F, 1.5F);

context.getItemInHand().hurtAndBreak(1, context.getPlayer(), player -> {
player.broadcastBreakEvent(context.getHand());
});
}

return InteractionResult.sidedSuccess(level.isClientSide);
}

return super.useOn(context);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/galena/oreganized/index/OPotions.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class OPotions {

public static final DeferredRegister<Potion> POTIONS = DeferredRegister.create(ForgeRegistries.POTIONS, Oreganized.MOD_ID);

public static final RegistryObject<Potion> STUNNING = POTIONS.register("stunning", () -> new Potion("stunning", new MobEffectInstance(OEffects.STUNNING.get(), 900)));
public static final RegistryObject<Potion> LONG_STUNNING = POTIONS.register("long_stunning", () -> new Potion("stunning", new MobEffectInstance(OEffects.STUNNING.get(), 1800)));
public static final RegistryObject<Potion> STRONG_STUNNING = POTIONS.register("strong_stunning", () -> new Potion("stunning", new MobEffectInstance(OEffects.STUNNING.get(), 900, 1)));
public static final RegistryObject<Potion> STUNNING = POTIONS.register("stunning", () -> new Potion("stunning", new MobEffectInstance(OEffects.STUNNING.get(), 1800)));
public static final RegistryObject<Potion> LONG_STUNNING = POTIONS.register("long_stunning", () -> new Potion("stunning", new MobEffectInstance(OEffects.STUNNING.get(), 3600)));
}
3 changes: 3 additions & 0 deletions src/main/java/galena/oreganized/world/event/PlayerEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.ToolAction;
import net.minecraftforge.common.ToolActions;
Expand Down Expand Up @@ -94,6 +95,8 @@ public static void blockItemInteractions(final PlayerInteractEvent.RightClickBlo
player.drop(newDisc, false);
//return;
}

world.setBlockAndUpdate(pos, Blocks.CAULDRON.defaultBlockState());
}
}

Expand Down

0 comments on commit 423cc13

Please sign in to comment.