Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API8 fixes #2609

Merged
merged 47 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
727b149
fix SqlServiceImpl
Faithcaio May 12, 2020
5a275e0
fix incompatible types compile errors
Faithcaio May 12, 2020
b72c3a1
fix SpongeTriggerBuilder missing from()
Faithcaio May 12, 2020
cd1d9c0
Block DyeColors
Faithcaio May 12, 2020
0ab27d5
fix most EntityUtil compile errors
Faithcaio May 12, 2020
b8e281c
fix Tracker PhaseStates
Faithcaio May 12, 2020
ab5ddcf
fix PacketPhaseUtil main hand slot restoration
Faithcaio May 12, 2020
e1605c1
fix SpongeEntityDamageSourceBuilder
Faithcaio May 12, 2020
114ecf0
notifier is data
Faithcaio May 12, 2020
87f12af
fix SmeltingRecipe mixin
Faithcaio May 13, 2020
80c816e
remove SpongeUser raw data
Faithcaio May 13, 2020
6160b63
a bunch of easy mixin fixes
Faithcaio May 13, 2020
22abade
pr comments
Faithcaio May 14, 2020
693c009
fix furnace toContainer
Faithcaio May 14, 2020
02b58b6
fix jukebox mixin
Faithcaio May 14, 2020
a54af90
fix sign TE mixin
Faithcaio May 14, 2020
f8236a0
fix SoundEvent Mixin
Faithcaio May 14, 2020
020ab7a
move invalid Text mixins
Faithcaio May 14, 2020
1253924
fix dyecolor again
Faithcaio May 14, 2020
7203d7d
fix FallingBlock mixin
Faithcaio May 14, 2020
97120df
fix FarmlandBlock mixin
Faithcaio May 14, 2020
ef04f9c
fix FireBlock mixin targets
Faithcaio May 14, 2020
ad42162
fix TNTBlock mixin
Faithcaio May 14, 2020
e533bd7
fix SpongeUser mixin
Faithcaio May 14, 2020
e87fa11
fix ProjectileDispenseBehavior mixin
Faithcaio May 14, 2020
44d3732
fix ArmorStandEntity overwrite
Faithcaio May 14, 2020
5d87e62
not invalid anymore
Faithcaio May 14, 2020
3428635
partial fix CreeperEntity mixin
Faithcaio May 14, 2020
5449564
fix FishingBobberEntity mixin
Faithcaio May 14, 2020
809075c
fix projectile mixins
Faithcaio May 14, 2020
dfcddd9
was this a performance fix?
Faithcaio May 14, 2020
2ab55fe
fix SScoreboardObjectivePacket mixin
Faithcaio May 14, 2020
182abdb
mostly fix Scoreboard mixins
Faithcaio May 14, 2020
81a3af7
fix BeaconTileEntity mixin
Faithcaio May 16, 2020
2a14e52
Update/Fix tileentity ticking optimization based on PaperMC patch:
Faithcaio May 16, 2020
1093821
fix HopperTileEntity mixin
Faithcaio May 16, 2020
1454e4d
removed it
Faithcaio May 16, 2020
80df9d4
fix some Text mixins
Faithcaio May 16, 2020
0e9ecb2
fix id -> key usage
Faithcaio May 16, 2020
857aaff
fix entity collision mixins
Faithcaio May 16, 2020
eaf1cbe
fix WorkbenchContainerMixin
Faithcaio May 16, 2020
0a8b9f1
fix ItemFrameEntityMixin_Optimization_Map
Faithcaio May 16, 2020
11d9861
fix FilledMapItem_Optimization_Map
Faithcaio May 16, 2020
bf9e6d3
fix collision optimization mixinw
Faithcaio May 16, 2020
3cb8f1e
fix real time mixins
Faithcaio May 16, 2020
5f3a029
fix ServerPlayerEntityMixin_Tracker
Faithcaio May 16, 2020
f8a4a77
fix tracker mixins
Faithcaio May 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.core.api.text;
package org.spongepowered.common.mixin.invalid.core.api.text;

import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.common.mixin.core.api.text.TextMixin;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.core.api.text;
package org.spongepowered.common.mixin.invalid.core.api.text;

import net.minecraft.util.text.SelectorTextComponent;
import net.minecraft.util.text.TextComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.core.api.text;
package org.spongepowered.common.mixin.invalid.core.api.text;

import com.google.common.collect.ImmutableList;
import net.minecraft.util.text.ITextComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.core.api.text;
package org.spongepowered.common.mixin.invalid.core.api.text;

import com.google.common.collect.ImmutableList;
import net.minecraft.util.text.TextComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.core.api.text.title;
package org.spongepowered.common.mixin.invalid.core.api.text.title;

import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.title.Title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,16 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.core.util.registry;
package org.spongepowered.common.accessor.block;

import net.minecraft.util.registry.Bootstrap;
import org.apache.logging.log4j.Logger;
import net.minecraft.block.JukeboxBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(Bootstrap.class)
public abstract class BootstrapMixin {
@Mixin(JukeboxBlock.class)
public interface JukeboxBlockAccessor {

// TODO(kashike): remove me with 1.13
@Redirect(
method = "register",
at = @At(
value = "INVOKE",
target = "Lorg/apache/logging/log4j/Logger;isDebugEnabled()Z",
remap = false
)
)
private static boolean no(final Logger logger) {
return false;
}
@Invoker("dropRecord") void accessor$dropRecord(World worldIn, BlockPos pos);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,15 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.api.item.recipe.smelting;
package org.spongepowered.common.accessor.entity.player;

import org.spongepowered.api.CatalogType;
import org.spongepowered.api.item.recipe.smelting.SmeltingRecipe;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.common.item.recipe.smelting.CustomSmeltingRecipeIds;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(value = SmeltingRecipe.class, remap = false)
public interface SmeltingRecipeMixin extends CatalogType {
@Mixin(ServerPlayerEntity.class)
public interface ServerPlayerEntityAccessor {
Faithcaio marked this conversation as resolved.
Show resolved Hide resolved

/**
* @author Cybermaxke
* @reason Use id's from custom registry
*/
@Overwrite(remap = false)
@Override
default String getId() {
return CustomSmeltingRecipeIds.getDefaultId((SmeltingRecipe) this);
}
@Accessor("enteredNetherPosition") Vec3d accessor$getEnteredNetherPosition();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
public interface SlotAccessor {

@Accessor("slotNumber") int accessor$getSlotNumber();
@Accessor("slotIndex") int accessor$getSlotIndex();
}
2 changes: 2 additions & 0 deletions src/accessors/resources/mixins.common.accessor.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"block.BedBlockAccessor",
"block.BlockAccessor",
"block.FireBlockAccessor",
"block.JukeboxBlockAccessor",
"block.PistonBlockAccessor",
"block.RedstoneWireBlockAccessor",
"crash.CrashReportAccessor",
Expand Down Expand Up @@ -65,6 +66,7 @@
"entity.passive.horse.TraderLlamaEntityAccessor",
"entity.player.PlayerAbilitiesAccessor",
"entity.player.PlayerEntityAccessor",
"entity.player.ServerPlayerEntityAccessor",
"entity.projectile.AbstractArrowEntityAccessor",
"entity.projectile.ArrowEntityAccessor",
"entity.projectile.DamagingProjectileEntityAccessor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,18 @@ public Trigger<C> build() {
new ResourceLocation(plugin.getId(), this.id), (Consumer) this.eventHandler, name);
}

@Override
public Trigger.Builder<C> from(Trigger<C> value) {
this.id = value.getKey().getValue();
this.configType = value.getConfigurationType();
if (value instanceof SpongeTrigger) {
this.constructor = (Function<JsonObject, C>) ((SpongeTrigger) value).constructor;
this.eventHandler = (Consumer) ((SpongeTrigger) value).getEventHandler();
this.name = ((SpongeTrigger) value).getName();
}
return this;
}

@Override
public Trigger.Builder<C> reset() {
this.configType = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
*/
package org.spongepowered.common.bridge.block;

import net.minecraft.item.DyeColor;
import org.spongepowered.api.data.type.DyeColor;

public interface DyeableBlockBridge {
import java.util.Optional;

public interface DyeColorBlockBridge {

void bridge$setDyeColor(DyeColor dyeColor);
Optional<DyeColor> bridge$getDyeColor();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import org.spongepowered.common.launch.SpongeLaunch;

import java.io.IOException;

@ConfigSerializable
public class OptimizationCategory extends ConfigCategory {

Expand Down Expand Up @@ -108,6 +106,11 @@ public class OptimizationCategory extends ConfigCategory {
+ "chunks are loaded.")
private boolean useActiveChunkForCollisions = false;

@Setting(value = "tileentity-ticking-optimization", comment = "Based on Paper's TileEntity Ticking optimization\n"
+ "setting this to 'true' prevents unnecessary ticking in Chests and EnderChests\n"
+ "See https://github.com/PaperMC/Paper/blob/bb4002d82e355f033906fc894cc2320f665ba72d/Spigot-Server-Patches/0022-Optimize-TileEntity-Ticking.patch")
private boolean optimizeTileEntityTicking = true;

@Setting(value = "disable-failing-deserialization-log-spam", comment = "Occasionally, some built in advancements, \n" +
"recipes, etc. can fail to deserialize properly\n" +
"which ends up potentially spamming the server log\n" +
Expand Down Expand Up @@ -184,8 +187,11 @@ public boolean isUseActiveChunkForCollisions() {
return this.useActiveChunkForCollisions;
}

public boolean isOptimizedTileEntityTicking() {
return this.optimizeTileEntityTicking;
}

public boolean disableFailingAdvancementDeserialization() {
return this.disableFailingAdvancementDeserialization;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ default <V extends Value<E>, E> DataProvider<V, E> getProviderFor(Key<V> key) {
}

@Override
@SuppressWarnings(value = {"unchecked", "rawtypes"})
default boolean supports(Key<?> key) {
return this.getProviderFor(key).isSupported(this);
return this.getProviderFor((Key) key).isSupported(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ default Optional<I> with(Value<?> value) {
}

@Override
@SuppressWarnings("rawtypes")
default Optional<I> without(Key<?> key) {
return this.getProviderFor(key).without((I) this);
return this.getProviderFor((Key)key).without((I) this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ default DataTransactionResult removeAll(MapValue<?, ?> value) {

@Override
default DataTransactionResult remove(Key<?> key) {
return this.getProviderFor(key).remove(this);
return this.getProviderFor((Key) key).remove(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ public boolean supports(final Key<?> key) {
}

@Override
@SuppressWarnings("rawtypes")
public Set<Value.Immutable<?>> getValues() {
return this.values.entrySet().stream()
.map(entry -> Value.immutableOf((Key) entry.getKey(), CopyHelper.copy(entry.getValue())).asImmutable())
.map(entry -> (Value.Immutable<?>)Value.immutableOf((Key) entry.getKey(), CopyHelper.copy(entry.getValue())).asImmutable())
.collect(ImmutableSet.toImmutableSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public final class DataProviderRegistry {

Expand Down Expand Up @@ -99,11 +100,13 @@ private DataProvider<?,?> loadProvider(LookupKey key) {
return this.buildDelegate((Key<Value<Object>>) key.key, provider -> filterHolderType(provider, key.holderType));
}

@SuppressWarnings(value = {"unchecked", "rawtypes"})
private DataProviderLookup loadProviderLookup(Class<?> holderType) {
return new DataProviderLookup(this.dataProviders.keySet().stream()
.map(key -> this.getProvider(key, holderType))
.filter(provider -> !(provider instanceof EmptyDataProvider))
.collect(Collectors.toMap(DataProvider::getKey, Function.identity())));
final Stream<DataProvider> stream = this.dataProviders.keySet().stream()
.map(key -> this.getProvider((Key) key, holderType))
.filter(provider -> !(provider instanceof EmptyDataProvider));
final Map<Key<?>, DataProvider<?, ?>> map = stream.collect(Collectors.toMap(p -> (Key<?>) p.getKey(), p -> (DataProvider<?, ?>) p));
return new DataProviderLookup(map);
}

/**
Expand Down Expand Up @@ -143,10 +146,10 @@ public DataProviderLookup getProviderLookup(Class<?> dataHolderType) {
*/
public DataProviderLookup buildLookup(Predicate<DataProvider<?,?>> predicate) {
//noinspection unchecked,rawtypes
final Map<Key<?>, DataProvider<?,?>> dataProviders = this.dataProviders.keySet().stream()
.map(key -> buildDelegateProvider(key, (List) this.dataProviders.get(key).stream().filter(predicate)))
.collect(Collectors.toMap(DataProvider::getKey, Function.identity()));
return new DataProviderLookup(dataProviders);
final Stream<DataProvider> stream = this.dataProviders.keySet().stream()
.map(key -> buildDelegateProvider((Key) key, (List) this.dataProviders.get(key).stream().filter(predicate)));
final Map<Key<?>, DataProvider<?, ?>> map = stream.collect(Collectors.toMap(p -> (Key<?>) p.getKey(), p -> (DataProvider<?, ?>) p));
return new DataProviderLookup(map);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
package org.spongepowered.common.data.provider.item.stack;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.type.DyeColor;
import org.spongepowered.common.bridge.block.DyeColorBlockBridge;
import org.spongepowered.common.data.provider.item.ItemStackDataProvider;

import java.util.Optional;
Expand All @@ -40,17 +41,18 @@ public ItemStackDyeColorProvider() {
super(Keys.DYE_COLOR);
}

/**
* Maybe try mixin injection in {@link Block.Properties#create(Material, net.minecraft.item.DyeColor)}
* to capture DyeColor.
*/
@Override
protected Optional<DyeColor> getFrom(ItemStack dataHolder) {
return ((DyeColorItemBrige)dataHolder).bridge$getDyeColor();
Item item = dataHolder.getItem();
if (item instanceof BlockItem) {
final Block block = ((BlockItem) item).getBlock();
return ((DyeColorBlockBridge) block).bridge$getDyeColor();
}
return Optional.empty();
}

@Override
protected boolean supports(Item item) {
return item instanceof DyeColorItemBridge;
return item instanceof BlockItem;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@

import java.util.Map;

@SuppressWarnings("unchecked")
@SuppressWarnings(value = {"unchecked", "rawtypes"})
public class StateHelper {

public static <O, S extends StateHolder<O, S>> S copyStatesFrom(S original, StateHolder<?,?> from) {
for (final Map.Entry<IProperty<?>, Comparable<?>> entry : from.getValues().entrySet()) {
if (original.has(entry.getKey())) {
original = (S) original.with(entry.getKey(), (Comparable) entry.getValue());
original = (S) original.with((IProperty) entry.getKey(), (Comparable) entry.getValue());
Faithcaio marked this conversation as resolved.
Show resolved Hide resolved
}
}
return original;
Expand Down
Loading