Skip to content

Commit

Permalink
Merge pull request #4419 from Siuolplex/zeta120
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr authored Nov 24, 2023
2 parents 2b6f29b + 8a50523 commit bfd5ce9
Show file tree
Hide file tree
Showing 17 changed files with 661 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.DynamicGameEventListener;
import net.minecraft.world.level.gameevent.EntityPositionSource;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.gameevent.*;
import net.minecraft.world.level.gameevent.GameEvent.Context;
import net.minecraft.world.level.gameevent.GameEventListener;
import net.minecraft.world.level.gameevent.vibrations.VibrationListener;
import net.minecraft.world.level.gameevent.vibrations.VibrationListener.VibrationListenerConfig;
import net.minecraft.world.level.gameevent.vibrations.VibrationSystem;
import net.minecraft.world.phys.Vec3;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.content.tools.config.PickarangType;
Expand All @@ -30,22 +27,24 @@

import java.util.function.BiConsumer;

public class Echorang extends AbstractPickarang<Echorang> implements VibrationListenerConfig {
public class Echorang extends AbstractPickarang<Echorang> implements VibrationSystem {
private final EchorangVibrationUser user = new EchorangVibrationUser();
private Data data = new Data();

private final DynamicGameEventListener<VibrationListener> dynamicGameEventListener;
private final DynamicGameEventListener<VibrationSystem.Listener> vibrationListener;

public Echorang(EntityType<Echorang> type, Level worldIn) {
super(type, worldIn);
dynamicGameEventListener = makeListener();
vibrationListener = makeListener();
}

public Echorang(EntityType<Echorang> type, Level worldIn, Player thrower) {
super(type, worldIn, thrower);
dynamicGameEventListener = makeListener();
vibrationListener = makeListener();
}

private DynamicGameEventListener<VibrationListener> makeListener() {
return new DynamicGameEventListener<>(new VibrationListener(new EntityPositionSource(this, this.getEyeHeight()), 16, this, (VibrationListener.ReceivingEvent) null, 0.0F, 0));
private DynamicGameEventListener<VibrationSystem.Listener> makeListener() {
return new DynamicGameEventListener<>(new VibrationSystem.Listener(this));
}

@Override
Expand All @@ -70,34 +69,14 @@ public boolean hasDrag() {
return false;
}

@Override
public TagKey<GameEvent> getListenableEvents() {
return PickarangModule.echorangCanListenTag;
}

@Override
public boolean isValidVibration(GameEvent p_223878_, Context p_223879_) {
return p_223878_.is(getListenableEvents()) && p_223879_.sourceEntity() == getOwner();
}

@Override
public boolean shouldListen(ServerLevel level, GameEventListener listener, BlockPos pos, GameEvent event, Context context) {
return !isReturning() && level.getWorldBorder().isWithinBounds(pos) && !isRemoved() && this.level() == level;
}

@Override
public void onSignalReceive(ServerLevel level, GameEventListener listener, BlockPos pos, GameEvent event, @Nullable Entity receiving, @Nullable Entity projectileOwner, float distance) {
liveTime = 0;
}

@Override
public void tick() {
super.tick();

gameEvent(GameEvent.PROJECTILE_SHOOT);

if (level() instanceof ServerLevel serverlevel)
this.dynamicGameEventListener.getListener().tick(serverlevel);
VibrationSystem.Ticker.tick(serverlevel, getVibrationData(), getVibrationUser());
}

@Override
Expand All @@ -106,28 +85,65 @@ public PickarangType<Echorang> getPickarangType() {
}

@Override
public void addAdditionalSaveData(CompoundTag compound) {
public void addAdditionalSaveData(@NotNull CompoundTag compound) {
super.addAdditionalSaveData(compound);

VibrationListener.codec(this).encodeStart(NbtOps.INSTANCE, dynamicGameEventListener.getListener()).resultOrPartial(Quark.LOG::error).ifPresent((nbt) -> {
compound.put("listener", nbt);
});
Data.CODEC.encodeStart(NbtOps.INSTANCE, data).resultOrPartial(Quark.LOG::error).ifPresent((nbt) -> compound.put("listener", nbt));
}

@Override
public void readAdditionalSaveData(CompoundTag compound) {
public void readAdditionalSaveData(@NotNull CompoundTag compound) {
super.readAdditionalSaveData(compound);

if(compound.contains("listener", 10))
VibrationListener.codec(this).parse(new Dynamic<>(NbtOps.INSTANCE, compound.getCompound("listener"))).resultOrPartial(Quark.LOG::error).ifPresent((nbt) -> {
dynamicGameEventListener.updateListener(nbt, level());
});
Data.CODEC.parse(new Dynamic<>(NbtOps.INSTANCE, compound.getCompound("listener"))).resultOrPartial(Quark.LOG::error).ifPresent((nbt) -> data = nbt);
}

@Override
public void updateDynamicGameEventListener(BiConsumer<DynamicGameEventListener<?>, ServerLevel> consumer) {
public void updateDynamicGameEventListener(@NotNull BiConsumer<DynamicGameEventListener<?>, ServerLevel> consumer) {
if (level() instanceof ServerLevel serverlevel)
consumer.accept(this.dynamicGameEventListener, serverlevel);
consumer.accept(this.vibrationListener, serverlevel);
}

@Override
public @NotNull Data getVibrationData() {
return data;
}

@Override
public @NotNull User getVibrationUser() {
return user;
}

public class EchorangVibrationUser implements VibrationSystem.User {
@Override
public int getListenerRadius() {
return 16;
}

@Override
public @NotNull PositionSource getPositionSource() {
return new EntityPositionSource(Echorang.this, Echorang.this.getEyeHeight());
}

@Override
public boolean canReceiveVibration(ServerLevel level, BlockPos pos, GameEvent event, Context context) {
return !isReturning() && level.getWorldBorder().isWithinBounds(pos) && !isRemoved() && Echorang.this.level() == level;
}

@Override
public void onReceiveVibration(ServerLevel level, BlockPos pos, GameEvent event, @Nullable Entity receiving, @Nullable Entity projectileOwner, float distance) {
liveTime = 0;
}

@Override
public TagKey<GameEvent> getListenableEvents() {
return PickarangModule.echorangCanListenTag;
}

@Override
public boolean isValidVibration(GameEvent gameEvent, Context context) {
return gameEvent.is(getListenableEvents()) && context.sourceEntity() == getOwner();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public int getLimitMatches(int curr) {
return MoreBannerLayersModule.getLimit(curr);
}

@ModifyConstant(method = "assemble(Lnet/minecraft/world/inventory/CraftingContainer;)Lnet/minecraft/world/item/ItemStack;", constant = @Constant(intValue = 6))
@ModifyConstant(method = "assemble(Lnet/minecraft/world/inventory/CraftingContainer;Lnet/minecraft/core/RegistryAccess;)Lnet/minecraft/world/item/ItemStack;", constant = @Constant(intValue = 6))
public int getLimitAssemble(int curr) {
return MoreBannerLayersModule.getLimit(curr);
}
Expand Down
19 changes: 0 additions & 19 deletions src/main/java/org/violetmoon/quark/mixin/ItemsMixin.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ public net.minecraft.client.gui.Gui f_279580_ # GUI_ICONS_LOCATION
public net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase f_283893_ # mapColor
protected net.minecraft.world.level.block.CropBlock m_7959_()Lnet/minecraft/world/level/block/state/properties/IntegerProperty; # getAgeProperty TODO fix me beautiful
public net.minecraft.data.worldgen.biome.OverworldBiomes m_264144_(ZFFLnet/minecraft/world/level/biome/MobSpawnSettings$Builder;Lnet/minecraft/world/level/biome/BiomeGenerationSettings$Builder;Lnet/minecraft/sounds/Music;)Lnet/minecraft/world/level/biome/Biome; # biome
public net.minecraft.advancements.critereon.ItemUsedOnLocationTrigger$TriggerInstance f_285570_ # location
public-f net.minecraft.advancements.critereon.ItemUsedOnLocationTrigger$TriggerInstance f_285570_ # location
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"type": "minecraft:tree",
"config": {
"decorators": [],
"dirt_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "minecraft:dirt"
}
},
"foliage_placer": {
"type": "minecraft:fancy_foliage_placer",
"height": 4,
"offset": 1,
"radius": 3
},
"foliage_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "quark:blue_blossom_leaves",
"Properties": {
"distance": "7",
"persistent": "false",
"waterlogged": "false"
}
}
},
"force_dirt": false,
"ignore_vines": true,
"minimum_size": {
"type": "minecraft:two_layers_feature_size",
"limit": 0,
"lower_size": 0,
"min_clipped_height": 4,
"upper_size": 0
},
"trunk_placer": {
"type": "minecraft:fancy_trunk_placer",
"base_height": 8,
"height_rand_a": 10,
"height_rand_b": 10
},
"trunk_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "quark:blossom_log",
"Properties": {
"axis": "y"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"type": "minecraft:tree",
"config": {
"decorators": [],
"dirt_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "minecraft:dirt"
}
},
"foliage_placer": {
"type": "minecraft:fancy_foliage_placer",
"height": 4,
"offset": 1,
"radius": 3
},
"foliage_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "quark:lavender_blossom_leaves",
"Properties": {
"distance": "7",
"persistent": "false",
"waterlogged": "false"
}
}
},
"force_dirt": false,
"ignore_vines": true,
"minimum_size": {
"type": "minecraft:two_layers_feature_size",
"limit": 0,
"lower_size": 0,
"min_clipped_height": 4,
"upper_size": 0
},
"trunk_placer": {
"type": "minecraft:fancy_trunk_placer",
"base_height": 8,
"height_rand_a": 10,
"height_rand_b": 10
},
"trunk_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "quark:blossom_log",
"Properties": {
"axis": "y"
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"type": "minecraft:tree",
"config": {
"decorators": [],
"dirt_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "minecraft:dirt"
}
},
"foliage_placer": {
"type": "minecraft:fancy_foliage_placer",
"height": 4,
"offset": 1,
"radius": 3
},
"foliage_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "quark:orange_blossom_leaves",
"Properties": {
"distance": "7",
"persistent": "false",
"waterlogged": "false"
}
}
},
"force_dirt": false,
"ignore_vines": true,
"minimum_size": {
"type": "minecraft:two_layers_feature_size",
"limit": 0,
"lower_size": 0,
"min_clipped_height": 4,
"upper_size": 0
},
"trunk_placer": {
"type": "minecraft:fancy_trunk_placer",
"base_height": 8,
"height_rand_a": 10,
"height_rand_b": 10
},
"trunk_provider": {
"type": "minecraft:simple_state_provider",
"state": {
"Name": "quark:blossom_log",
"Properties": {
"axis": "y"
}
}
}
}
}
Loading

0 comments on commit bfd5ce9

Please sign in to comment.