Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Jan 27, 2024
2 parents 6d538dd + 628058f commit aea2287
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.content.tweaks.module.SimpleHarvestModule;

/**
* Used primarily for double crops which need extra checks before they are considered ready.
Expand All @@ -15,62 +19,58 @@
@Cancelable
public class SimpleHarvestEvent extends Event {

public final BlockState blockState;
public final BlockPos pos;
public final InteractionHand hand;
public final Player player;
public final Source type;
private BlockPos newTarget;
private ActionType action;
public final BlockState blockState;
public final BlockPos pos;
public final Level level;
public final @Nullable InteractionHand hand;
public final @Nullable Entity entity;
private BlockPos newTarget;
private ActionType action;

public SimpleHarvestEvent(BlockState blockState, BlockPos pos, InteractionHand hand,
Player player, boolean isHoe, ActionType actionType) {
this.blockState = blockState;
this.pos = pos;
this.hand = hand;
this.player = player;
this.newTarget = pos;
this.type = isHoe ? Source.HOE : Source.RIGHT_CLICK;
this.action = actionType;
}
//Note that entity could be a player or villager
public SimpleHarvestEvent(BlockState blockState, BlockPos pos, Level level, @Nullable InteractionHand hand,
@Nullable Entity entity, ActionType originalActionType) {
this.blockState = blockState;
this.pos = pos;
this.hand = hand;
this.level = level;
this.entity = entity;
this.newTarget = pos;
this.action = originalActionType;
}

/**
* Used for double crops and the like. Pass a new position which should be broken instead
*
* @param pos new target position
*/
public void setTargetPos(BlockPos pos) {
this.newTarget = pos;
}
/**
* Used for double crops and the like. Pass a new position which should be broken instead
*
* @param pos new target position
*/
public void setTargetPos(BlockPos pos) {
this.newTarget = pos;
}

public Source getInteractionSource() {
return type;
}
@Override
public void setCanceled(boolean cancel) {
if (cancel)
action = ActionType.NONE;
super.setCanceled(cancel);
}

@Override
public void setCanceled(boolean cancel) {
if(cancel)
action = ActionType.NONE;
super.setCanceled(cancel);
}
//Click will work just for players!
public enum ActionType {
NONE, CLICK, HARVEST;
}

public enum ActionType {
NONE, CLICK, HARVEST;
}
public ActionType getAction() {
return action;
}

public ActionType getAction() {
return action;
}
public void setAction(ActionType action) {
this.action = action;
}

public void setAction(ActionType action) {
this.action = action;
}
public BlockPos getTargetPos() {
return newTarget;
}

public BlockPos getTargetPos() {
return newTarget;
}

public enum Source {
RIGHT_CLICK, HOE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockSt
}

@Override
public SoundType getSoundTypeZeta(BlockState state, LevelReader world, BlockPos pos, @Nullable Entity entity) {
if(state.getValue(FULL))
public SoundType getSoundType(BlockState pState) {
if(pState.getValue(FULL))
return WOOD_WITH_PLANT_STEP;
return super.getSoundTypeZeta(state, world, pos, entity);
return super.getSoundType(pState);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public FeedResult tryFeedingAnimal(Animal animal) {
ItemStack stack = this.getItem(i);
if(animal.isFood(stack)) {
SoundEvent soundEvent = animal.getEatingSound(stack);
if (soundEvent != null) { // Null check is kinda required, don't remove :)
if (soundEvent != null) { // Null check is kinda required, don't remove :) (why tho, intellij says its never null)
animal.playSound(soundEvent, 0.5F + 0.5F * level.random.nextInt(2), (level.random.nextFloat() - level.random.nextFloat()) * 0.2F + 1.0F);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ boolean valid(Animal animal) {
void tryEatingOrTickCooldown(Animal animal) {
giveUpCooldown--;
if (eatCooldown == 0) {
float feedDistance = animal.getBbWidth()*1.8f;
float feedDistance = 0.5f +animal.getBbWidth()*1.8f;
if (pos.distToCenterSqr(animal.position()) < (feedDistance * feedDistance)) {
if (animal.level().getBlockEntity(pos) instanceof FeedingTroughBlockEntity trough) {
switch (trough.tryFeedingAnimal(animal)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package org.violetmoon.quark.content.mobs.module;

import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.core.registries.Registries;
import net.minecraft.tags.BiomeTags;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.SpawnPlacements.Type;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraftforge.common.Tags;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.content.mobs.client.render.entity.StonelingRenderer;
import org.violetmoon.quark.content.mobs.entity.Stoneling;
import org.violetmoon.quark.content.mobs.item.DiamondHeartItem;
import org.violetmoon.quark.content.world.module.GlimmeringWealdModule;
import org.violetmoon.zeta.advancement.ManualTrigger;
import org.violetmoon.zeta.client.event.load.ZClientSetup;
import org.violetmoon.zeta.config.Config;
Expand All @@ -17,17 +25,6 @@
import org.violetmoon.zeta.module.ZetaLoadModule;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.util.Hint;
import org.violetmoon.zeta.world.EntitySpawnHandler;

import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.core.registries.Registries;
import net.minecraft.tags.BiomeTags;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.SpawnPlacements.Type;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraftforge.common.Tags;

@ZetaLoadModule(category = "mobs")
public class StonelingsModule extends ZetaModule {
Expand Down Expand Up @@ -72,11 +69,7 @@ public final void register(ZRegister event) {
makeStonelingTrigger = event.getAdvancementModifierRegistry().registerManualTrigger("make_stoneling");

Quark.ZETA.entitySpawn.registerSpawn(stonelingType, MobCategory.MONSTER, Type.ON_GROUND, Types.MOTION_BLOCKING_NO_LEAVES, Stoneling::spawnPredicate, spawnConfig);
// Hardcoded AF yay
if(spawnConfig.isEnabled()) {
var GWConfig = new EntitySpawnConfig(200, 1, 4, CompoundBiomeConfig.fromBiomeReslocs(false, GlimmeringWealdModule.BIOME_NAME.toString()));
Quark.ZETA.entitySpawn.track(stonelingType, MobCategory.MONSTER, GWConfig, false);
}
//secondary placement is done in GW biome definition json.
Quark.ZETA.entitySpawn.addEgg(this, stonelingType, 0xA1A1A1, 0x505050, spawnConfig);
}

Expand Down
Loading

0 comments on commit aea2287

Please sign in to comment.